OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
nearest_seg.F
Go to the documentation of this file.
1Copyright> OpenRadioss
2Copyright> Copyright (C) 1986-2025 Altair Engineering Inc.
3Copyright>
4Copyright> This program is free software: you can redistribute it and/or modify
5Copyright> it under the terms of the GNU Affero General Public License as published by
6Copyright> the Free Software Foundation, either version 3 of the License, or
7Copyright> (at your option) any later version.
8Copyright>
9Copyright> This program is distributed in the hope that it will be useful,
10Copyright> but WITHOUT ANY WARRANTY; without even the implied warranty of
11Copyright> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12Copyright> GNU Affero General Public License for more details.
13Copyright>
14Copyright> You should have received a copy of the GNU Affero General Public License
15Copyright> along with this program. If not, see <https://www.gnu.org/licenses/>.
16Copyright>
17Copyright>
18Copyright> Commercial Alternative: Altair Radioss Software
19Copyright>
20Copyright> As an alternative to this open-source version, Altair also offers Altair Radioss
21Copyright> software under a commercial license. Contact Altair to discuss further if the
22Copyright> commercial version may interest you: https://www.altair.com/radioss/.
23!||====================================================================
24!|| nearest_seg ../common_source/interf/nearest_seg.F
25!||--- called by ------------------------------------------------------
26!|| i3msr3 ../engine/source/interfaces/inter3d/i3msr3.F
27!|| invoi3 ../starter/source/interfaces/inter3d1/invoi3.F
28!||====================================================================
29 SUBROUTINE nearest_seg(X, IS, M1, M2, M3, LSEG, LSEG_NEW, BMIN, BMAX)
30C
31C COMPUTE BARYCENTRIC COORDINATES OF PROJECTION OF NODE IS ON TRIANGLE M1 M2 M3
32C WOLFGANG HEIDRICH, 2005
33C-----------------------------------------------
34C I m p l i c i t T y p e s
35C-----------------------------------------------
36#include "implicit_f.inc"
37C-----------------------------------------------
38C D u m m y A r g u m e n t s
39C-----------------------------------------------
40 INTEGER, INTENT(IN) :: IS, M1, M2, M3, LSEG
41 INTEGER, INTENT(OUT) :: LSEG_NEW
42 my_real, INTENT(IN) :: x(3,*)
43 my_real, INTENT(OUT) :: bmin
44 my_real, INTENT(INOUT) :: bmax
45C-----------------------------------------------
46C C o m m o n B l o c k s
47C-----------------------------------------------
48C-----------------------------------------------
49C L o c a l V a r i a b l e s
50C-----------------------------------------------
51 my_real n(3), u(3), v(3), w(3), uw(3), wv(3)
52 my_real b0, b1, b2, fac
53C---------------------------------------------------
54 u(1)=x(1,m2)-x(1,m1)
55 u(2)=x(2,m2)-x(2,m1)
56 u(3)=x(3,m2)-x(3,m1)
57C
58 v(1)=x(1,m3)-x(1,m1)
59 v(2)=x(2,m3)-x(2,m1)
60 v(3)=x(3,m3)-x(3,m1)
61C
62 n(1)=u(2)*v(3)-u(3)*v(2)
63 n(2)=u(3)*v(1)-u(1)*v(3)
64 n(3)=u(1)*v(2)-u(2)*v(1)
65C
66 w(1)=x(1,is)-x(1,m1)
67 w(2)=x(2,is)-x(2,m1)
68 w(3)=x(3,is)-x(3,m1)
69C
70 uw(1)=u(2)*w(3)-u(3)*w(2)
71 uw(2)=u(3)*w(1)-u(1)*w(3)
72 uw(3)=u(1)*w(2)-u(2)*w(1)
73C
74 wv(1)=w(2)*v(3)-w(3)*v(2)
75 wv(2)=w(3)*v(1)-w(1)*v(3)
76 wv(3)=w(1)*v(2)-w(2)*v(1)
77C
78 fac=one/(n(1)*n(1)+n(2)*n(2)+n(3)*n(3))
79 b2 =(uw(1)*n(1)+uw(2)*n(2)+uw(3)*n(3))*fac
80 b1 =(wv(1)*n(1)+wv(2)*n(2)+wv(3)*n(3))*fac
81 b0 = one - b1 - b2
82 bmin=min(b0,b1,b2)
83C BMIN > 0 Projection est a l'interieur du triangle
84C BMIN = 0 Projection est sur un cote du triangle
85C BMIN < 0 Projection est a l'exterieur du triangle
86 IF(bmin > bmax) THEN
87 lseg_new=lseg
88 bmax=bmin
89 ENDIF
90 RETURN
91 END
#define my_real
Definition cppsort.cpp:32
#define min(a, b)
Definition macros.h:20
subroutine nearest_seg(x, is, m1, m2, m3, lseg, lseg_new, bmin, bmax)
Definition nearest_seg.F:30