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 GNELTU(X,PAR,IACT,SNEXT,SNXT,SAFE)
14 C ****************************************************************
16 C * Compute distance up to intersection with 'ELTU' volume, *
17 C * from inside 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"
37 #if !defined(CERNLIB_SINGLE)
38 DOUBLE PRECISION SAFZ1,SAFZ2,SAFR,A2,B2,X0,Y0,A,B,D1,D2
39 DOUBLE PRECISION X1,X2,X3,Y1,Y2,Y3
40 DOUBLE PRECISION SZ,XZ,YZ,U,V,W,DISCR,SQDISC,TAU1,TAU2
52 C -----------------------------------
53 C | Compute safety-distance 'SAFE' |
54 C -----------------------------------
62 Y1=SQRT((A-X0)*(A+X0))*B/A
64 X2=SQRT((B-Y0)*(B+Y0))*A/B
65 D1=(X1-X0)**2+(Y1-Y0)**2
66 D2=(X2-X0)**2+(Y2-Y0)**2
70 Y3=SQRT((A-X3)*(A+X3))*B/A
73 X3=SQRT((B-Y3)*(B+Y3))*A/B
78 D2=(X2-X0)**2+(Y2-Y0)**2
82 D1=(X1-X0)**2+(Y1-Y0)**2
87 SAFE = MIN(SAFZ1,SAFZ2,SAFR)
89 IF(IACT.EQ.1.AND.SNEXT.LT.SAFE)GOTO 99
93 C -----------------------------------
94 C | Compute vector-distance 'SNXT' |
95 C -----------------------------------
101 ELSEIF(X(6).LT.0.)THEN
105 C .... Then,if necessary,find the intersection of
106 C the given ray(described by array X) whit
108 C Ray equation : X'(1-3) = X(1-3) + TAU*X(4-6)
109 C Cylinder equation : x**2/a**2 + y**2/b**2 = 1
110 C To obtain TAU,solve the quadratic equation
111 C Ut**2 + 2Vt + W = 0
116 IF((XZ*XZ/A2+YZ*YZ/B2).LE.1)GOTO 99
118 U = X(4)*X(4)*B2+X(5)*X(5)*A2
119 V = X(1)*X(4)*B2+X(2)*X(5)*A2
120 W = X(1)*X(1)*B2+X(2)*X(2)*A2-A2*B2
122 IF(DISCR.LT.0.)GOTO 99
128 C .... Set SNXT to the smallest positive TAU
131 IF(TAU2.LT.0.)GOTO 99
135 IF(TAU2.GT.0.0.AND.TAU2.LT.TAU1)THEN