5 * Revision 1.1.1.1 1995/10/24 10:20:52 cernlib
9 #include "geant321/pilot.h"
10 *CMZ : 3.21/02 29/03/94 15.41.29 by S.Giani
12 SUBROUTINE GNOELT(X,PAR,IACT,SNEXT,SNXT,SAFE)
14 C ****************************************************************
16 C * Compute distance up to intersection with 'ELTU' volume, *
17 C * from outside point X(1-3) along direction X(4-6). *
19 C * PAR (input) : volume parameters *
20 C * IACT (input) : action flag *
21 C * = 0 Compute SAFE only *
22 C * = 1 Compute SAFE, and SNXT only if SNEXT.gt.new SAFE *
23 C * = 2 Compute both SAFE and SNXT *
24 C * = 3 Compute SNXT only *
25 C * SNEXT (input) : see IACT = 1 *
26 C * SNXT (output) : distance to volume boundary *
27 C * SAFE (output) : shortest distance to any boundary *
29 C * ==>Called by : GNEXT,GTNEXT *
32 C ****************************************************************
34 #include "geant321/gconsp.inc"
36 DIMENSION X(6),PAR(3),TAU(2)
38 #if !defined(CERNLIB_SINGLE)
39 DOUBLE PRECISION SAFZ,A2,B2,X0,Y0,PHI1,PHI2,PHI3,X3,Y3
40 DOUBLE PRECISION DXY2,U,V,W,DISCR,SQDISC,TAU,TAUZ,ZI,XZ,YZ
43 SAFZ = ABS(X(3))-PAR(3)
49 C -----------------------------------
50 C | Compute safety-distance 'SAFE' |
51 C -----------------------------------
58 IF(X0*X0/A2+Y0*Y0/B2.LT.1.) GO TO 30
65 D=Y3*A2*(X0-X3)-X3*B2*(Y0-Y3)
67 * D is the (signed) distance from the point (X0,Y0)
68 * to the normal to the ellipse at the point (X3,Y3).
76 20 SAFE=SQRT((X0-X3)**2+(Y0-Y3)**2)-.01
79 * .... Combine the radial distance whit the Z-distance
81 SAFE = SQRT(SAFE**2+SAFZ**2)
84 IF(IACT.EQ.1.AND.SNEXT.LT.SAFE)GOTO 999
87 C ---------------------------------------
88 C | Compute the vector-distance 'SNXT' |
89 C ---------------------------------------
91 IF(SAFZ.GT.0.0.AND.X(3)*X(6).GE.0.0)GOTO 999
93 DXY2 = (1-X(6))*(1+X(6))
96 C .... Find the intersection of the given ray
97 C (described by array X) whit the cylider.
98 C Ray equation : X'(1-3) = X(1-3) + TAU*X(4-6)
99 C Cylinder equation : x**2/a**2 + y**2/b**2 = 1
100 C To obtain TAU,solve the quadratic equation
101 C Ut**2 + 2Vt + W = 0
103 U = X(4)*X(4)*B2+X(5)*X(5)*A2
104 V = X(1)*X(4)*B2+X(2)*X(5)*A2
105 W = X(1)*X(1)*B2+X(2)*X(2)*A2-A2*B2
107 IF(DISCR.LT.0.)GOTO 999
110 TAU(1) = (-V+SQDISC)/U
111 TAU(2) = (-V-SQDISC)/U
115 ZI = X(3)+TAU(I)*X(6)
116 IF((ABS(ZI)-PAR(3)).LT.1.E-6)THEN
118 C .... Set SNXT to the smallest positive TAU,only if
119 C the intersection point is inside the Z limits
121 SNXT = MIN(SNXT,REAL(TAU(I)))
129 C .... Check intersection whit Z planes
131 IF(X(3).GT.0.) ZI = PAR(3)
132 IF(X(3).LT.0.) ZI = -PAR(3)
134 TAUZ = (ZI-X(3))/X(6)
137 IF((XZ*XZ/A2+YZ*YZ/B2).LE.1.) SNXT = TAUZ