factr2
C FACTR2 SOURCE CHAT 05/01/12 23:55:58 5004
$ ,XN1,XN2,XN3,XINT,ITEST)
***********************************************************************
*** SP 'FACTR2' : a partir d'une face definie par des pts, permet de
*** dire si un segment (pt depart-pt arrivee) rencontre cette face.
***
*** APPELES 1 = 'TRPOSE', 'MATMAT', 'SCVECT' (fonction)
*** APPELES 2 = aucun
***
*** E = 'NDIM' dimension de l'espace
*** 'ITYG' entier caracterisant la geometrie de l'elemnt considere
*** 'PT1', 'PT2', 'PT3', 'PT4' noeuds de la face
*** 'XDEP2' coordonnees reelles de depart de la particule
*** 'XARI2' coordonnees reelles d'arrivee de la particule
*** 'XN1' vecteur unitaire normal à la face
*** 'XN2' vecteur unitaire normal à trajectoire et 'XN1'
*** 'XN3' vecteur unitaire normal à 'XN1' et 'XN2'
*** 'XINT' pt intersection plan associé à face/droite associé à trajectoire
***
*** S = 'ITEST' vaut 1 si face effectivement traversee, 0 sinon
***
*** Rq : 'XZPREC' (-INC CCREEL) erreur precision calcul machine
***
*** ORIGINE = CYRIL NOU
***********************************************************************
IMPLICIT INTEGER(I-N)
IMPLICIT REAL*8 (A-H,O-Z)
-INC CCREEL
DIMENSION XDEP2(3),XARI2(3)
DIMENSION XINT(3),XN1(3),XN2(3),XN3(3)
DIMENSION PT1(3),PT2(3),PT3(3),PT4(3)
DIMENSION X1(3),X2(3),X3(3),X4(4),XPASS(3,3)
DIMENSION PPT1(3),PPT2(3),PPT3(3),PPT4(3),XXINT(3)
DIMENSION PPPT1(3),PPPT2(3),PPPT3(3),PPPT4(3),XXXINT(3)
*** construction des vecteurs directeurs droite,plan, etc...
DO 10 I=1,NDIM
X1(I)=XARI2(I)-XDEP2(I)
X2(I)=XINT(I)-XDEP2(I)
X3(I)=PT2(I)-PT1(I)
X4(I)=XINT(I)-PT1(I)
10 CONTINUE
ITEST=0
*** 'ITEST1' teste appartenance à trajectoire, 'ITEST2' appartenance à face
ITEST1=0
ITEST2=0
**************************************************
*** PT INTERSECTION APPARTIENT À TRAJECTOIRE ? ***
**************************************************
*** calcul de la distance entre les pts départ et arrivee
X1NORM=0.D0
DO 20 I=1,NDIM
X1NORM=X1NORM+X1(I)**2
20 CONTINUE
*** verification si 'XINT' appartient au segment depart-arrivee
*******************************************
*** PT INTERSECTION APPARTIENT À FACE ? ***
*******************************************
********** CAS 2D **********
IF (NDIM.EQ.2) THEN
*** calcul de la norme de la face
X3NORM=0.D0
DO 30 I=1,NDIM
X3NORM=X3NORM+X3(I)**2
30 CONTINUE
*** verification si 'XINT' appartient au segment face
********** CAS 3D **********
ELSEIF (NDIM.EQ.3) THEN
*** matrice de passage du repere lié à la face vers repere absolu
DO 40 I=1,NDIM
XPASS(I,1)=XN1(I)
XPASS(I,2)=XN2(I)
XPASS(I,3)=XN3(I)
40 CONTINUE
*** transpose de 'XPASS' (repere absolu vers repere face)
*** passage des coordonnees des pts du repere absolu au repere face
*** test par rapport à droite ppt1-ppt2, origine repere face=ppt3
DO 50 I=1,NDIM
PPPT1(I)=PPT1(I)-PPT3(I)
PPPT2(I)=PPT2(I)-PPT3(I)
XXXINT(I)=XXINT(I)-PPT3(I)
50 CONTINUE
A=(XXXINT(2)-PPPT1(2))*(PPPT2(3)-PPPT1(3))
B=(XXXINT(3)-PPPT1(3))*(PPPT2(2)-PPPT1(2))
C=PPPT1(3)*(PPPT2(2)-PPPT1(2))
D=PPPT1(2)*(PPPT2(3)-PPPT1(3))
** test par rapport à droite ppt2-ppt3, origine repere face=ppt1
DO 60 I=1,NDIM
PPPT2(I)=PPT2(I)-PPT1(I)
PPPT3(I)=PPT3(I)-PPT1(I)
XXXINT(I)=XXINT(I)-PPT1(I)
60 CONTINUE
A=(XXXINT(2)-PPPT2(2))*(PPPT3(3)-PPPT2(3))
B=(XXXINT(3)-PPPT2(3))*(PPPT3(2)-PPPT2(2))
C=PPPT2(3)*(PPPT3(2)-PPPT2(2))
D=PPPT2(2)*(PPPT3(3)-PPPT2(3))
*** test par rapport à droite ppt3-ppt4, origine repere face=ppt2
IF ((ABS(PPT3(2)-PPT4(2)).GT.(XZPREC*SQRT(X1NORM)))
$ .OR.(ABS(PPT3(3)-PPT4(3)).GT.(XZPREC*SQRT(X1NORM)))) THEN
DO 70 I=1,NDIM
PPPT3(I)=PPT3(I)-PPT2(I)
PPPT4(I)=PPT4(I)-PPT2(I)
XXXINT(I)=XXINT(I)-PPT2(I)
70 CONTINUE
A=(XXXINT(2)-PPPT3(2))*(PPPT4(3)-PPPT3(3))
B=(XXXINT(3)-PPPT3(3))*(PPPT4(2)-PPPT3(2))
C=PPPT3(3)*(PPPT4(2)-PPPT3(2))
D=PPPT3(2)*(PPPT4(3)-PPPT3(3))
*** test par rapport à droite ppt4-ppt1, origine repere face=ppt3
DO 80 I=1,NDIM
PPPT4(I)=PPT4(I)-PPT3(I)
PPPT1(I)=PPT1(I)-PPT3(I)
XXXINT(I)=XXINT(I)-PPT3(I)
80 CONTINUE
A=(XXXINT(2)-PPPT4(2))*(PPPT1(3)-PPPT4(3))
B=(XXXINT(3)-PPPT4(3))*(PPPT1(2)-PPPT4(2))
C=PPPT4(3)*(PPPT1(2)-PPPT4(2))
D=PPPT4(2)*(PPPT1(3)-PPPT4(3))
ENDIF
ELSE
*** cas ou ppt3=ppt4 (3 pts seulement definissent la face)
*** test par rapport à droite ppt3-ppt1, origine repere face=ppt2
DO 90 I=1,NDIM
PPPT3(I)=PPT3(I)-PPT2(I)
PPPT1(I)=PPT1(I)-PPT2(I)
XXXINT(I)=XXINT(I)-PPT2(I)
90 CONTINUE
A=(XXXINT(2)-PPPT3(2))*(PPPT1(3)-PPPT3(3))
B=(XXXINT(3)-PPPT3(3))*(PPPT1(2)-PPPT3(2))
C=PPPT3(3)*(PPPT1(2)-PPPT3(2))
D=PPPT3(2)*(PPPT1(3)-PPPT3(3))
ENDIF
ENDIF
ENDIF
ENDIF
*** verification des deux conditions à la fois
IF ((ITEST1.EQ.1).AND.(ITEST2.EQ.1)) ITEST=1
RETURN
END
					© Cast3M 2003 - Tous droits réservés.
					Mentions légales