]> git.uio.no Git - u/mrichter/AliRoot.git/blob - GEANT321/ggeom/gingtr.F
Bugfix in AliPoints2Memory
[u/mrichter/AliRoot.git] / GEANT321 / ggeom / gingtr.F
1 *
2 * $Id$
3 *
4 * $Log$
5 * Revision 1.1.1.1  1995/10/24 10:20:50  cernlib
6 * Geant
7 *
8 *
9 #include "geant321/pilot.h"
10 *CMZ :  3.21/02 29/03/94  15.41.29  by  S.Giani
11 *-- Author :
12       SUBROUTINE GINGTR(X,P,IYES)
13 C.
14 C.    ******************************************************************
15 C.    *                                                                *
16 C.    *                                                                *
17 C.    *          SUBROUTINE GINGTR(X,P,IYES)                           *
18 C.    *      Routine performes GINME type function to determine        *
19 C.    *      whether the point X is in the GTRA shape with parameters  *
20 C.    *      P. IYES is returned 1 if it is 0 if not.                  *
21 C.    *          A.C.McPherson 22nd April 1985                         *
22 C.    *                                                                *
23 C.    *      Called by : GINME                                         *
24 C.    *                                                                *
25 C     ******************************************************************
26 C.
27       DIMENSION X(3),P(30),XPT(4),YPT(4)
28 C.
29 C.            ----------------------------------------
30 C.
31 C             First the range in Z is checked.
32 C
33       IYES=0
34       IF(ABS(X(3)).GT.P(1)) GO TO 30
35 C
36 C             Next the four corners at the z of the input point (X(3))
37 C             are computed as:
38 C
39       DO 10 I=1,4
40       I0=I*4+11
41       XPT(I) = P(I0)+P(I0+2)*X(3)
42       YPT(I) = P(I0+1)+P(I0+3)*X(3)
43    10 CONTINUE
44 C
45 C             Then the cross product between the vector from that
46 C             corner to the input point and the vector from that corner
47 C             to the next corner is computed and its sign is
48 C             interrogated. Since the quadralateral is convex, if any
49 C             one of these signs is wrong, the point is outside the
50 C             shape. This task is performed as follows:
51 C
52       DO 20 I=1,4
53       J = I+1
54       IF(J.EQ.5) J=1
55       CROSS = (X(1)-XPT(I))*(YPT(J)-YPT(I)) -
56      +        (X(2)-YPT(I))*(XPT(J)-XPT(I))
57       IF(CROSS.GT.0.0) GO TO 30
58    20 CONTINUE
59       IYES = 1
60    30 CONTINUE
61       RETURN
62       END