This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / GEANT321 / ggeom / gnpara.F
1 *
2 * $Id$
3 *
4 * $Log$
5 * Revision 1.1.1.1  1995/10/24 10:20:53  cernlib
6 * Geant
7 *
8 *
9 #include "geant321/pilot.h"
10 *CMZ :  3.21/02 29/03/94  15.41.30  by  S.Giani
11 *-- Author :
12       SUBROUTINE GNPARA (X, PAR, IACT, SNEXT, SNXT, SAFE)
13 C.
14 C.    ******************************************************************
15 C.    *                                                                *
16 C.    *       COMPUTE DISTANCE UP TO INTERSECTION WITH 'PARA' VOLUME,  *
17 C.    *       FROM INSIDE POINT X(1-3) ALONG DIRECTION X(4-6)          *
18 C.    *                                                                *
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       *
28 C.    *                                                                *
29 C.    *    ==>Called by : GNEXT, GTNEXT                                *
30 C.    *         Author  A.McPherson  *********                         *
31 C.    *                                                                *
32 C.    ******************************************************************
33 C.
34 #include "geant321/gconsp.inc"
35       DIMENSION X(6), PAR(6)
36 C.
37 C.    ---------------------------------------------------
38 C.
39       SNXT = BIG
40       DN31=PAR(3)-X(3)
41       DN32=-PAR(3)-X(3)
42 C
43       YT=X(2)-PAR(6)*X(3)
44       DN21=PAR(2)-YT
45       DN22=-PAR(2)-YT
46       CTY=1.0/SQRT(1.0+PAR(6)**2)
47 C
48       XT=X(1)-PAR(5)*X(3)-PAR(4)*YT
49       DN11=PAR(1)-XT
50       DN12=-PAR(1)-XT
51       CTX=1.0/SQRT(1.0+PAR(4)**2+PAR(5)**2)
52  
53       IF (IACT .LT. 3) THEN
54  
55  
56 C       -------------------------------------------------
57 C       |  Compute safety-distance 'SAFE' (McPherson)   |
58 C       -------------------------------------------------
59  
60  
61         SAFE=MIN(DN11*CTX,-DN12*CTX,DN21*CTY,-DN22*CTY,DN31,-DN32)
62 C
63         IF (IACT .EQ. 0) GO TO 999
64         IF (IACT .EQ. 1) THEN
65           IF (SNEXT .LT. SAFE) GO TO 999
66         ENDIF
67       ENDIF
68  
69 C     ------------------------------------------------
70 C     |  Compute vector-distance 'SNXT' (McPherson)  |
71 C     ------------------------------------------------
72  
73  
74       SN3=BIG
75       SN2=BIG
76       SN1=BIG
77 C
78       IF(X(6).NE.0.0) SN3=DN31/X(6)
79       IF(SN3.LT.0.0) SN3=DN32/X(6)
80 C
81       DY=X(5)-PAR(6)*X(6)
82       IF(DY.NE.0.0) SN2=DN21/DY
83       IF(SN2.LT.0.0) SN2=DN22/DY
84 C
85       DX=X(4)-PAR(5)*X(6)-PAR(4)*DY
86       IF(DX.NE.0.0) SN1=DN11/DX
87       IF(SN1.LT.0.0) SN1=DN12/DX
88 C
89       SNXT=MIN(SN1,SN2,SN3)
90 C
91   999 CONTINUE
92       END