1 *
2 * \$Id\$
3 *
4 * \$Log\$
5 * Revision 1.1.1.1  1995/10/24 10:19:44  cernlib
6 * Geant
7 *
8 *
9 #include "geant321/pilot.h"
10 *CMZ :  3.21/02 29/03/94  15.41.31  by  S.Giani
11 *-- Author :
12       SUBROUTINE CGHPLA(IFACE,XYZ,ABCD)
13 ************************************************************************
14 *                                                                      *
15 *     Name: CGHPLA                                                     *
16 *     Author: E. Chernyaev                       Date:    08.08.88     *
17 *                                                Revised:              *
18 *                                                                      *
19 *     Function: Compute face plane equation coefficients:              *
20 *                    Ax + By + Cz + D = 0                              *
21 *                                                                      *
22 *     References: none                                                 *
23 *                                                                      *
24 *     Input: IFACE(*) - face                                           *
25 *            XYZ(3,*) - node coordinates                               *
26 *                                                                      *
27 *     Output: ABCD(4) - plane equation coefficients                    *
28 *                                                                      *
29 *     Errors: none                                                     *
30 *                                                                      *
31 ************************************************************************
32       REAL            XYZ(3,*),ABCD(4),GRAV(3)
33 *SG
34       INTEGER         IFACE(*)
35 *SG
36 *-
37       NEDGE = IFACE(1)
38       A      = 0.
39       B      = 0.
40       C      = 0.
41       GRAV(1)= 0.
42       GRAV(2)= 0.
43       GRAV(3)= 0.
44       JF     = 2
45       DO 100 NE=1,NEDGE
46         N1     = IFACE(JF)
47         N2     = IFACE(JF+1)
48         JF     = JF + 2
49         A      = A + XYZ(2,N1)*XYZ(3,N2) - XYZ(2,N2)*XYZ(3,N1)
50         B      = B + XYZ(3,N1)*XYZ(1,N2) - XYZ(3,N2)*XYZ(1,N1)
51         C      = C + XYZ(1,N1)*XYZ(2,N2) - XYZ(1,N2)*XYZ(2,N1)
52         GRAV(1)= GRAV(1) + XYZ(1,N1) + XYZ(1,N2)
53         GRAV(2)= GRAV(2) + XYZ(2,N1) + XYZ(2,N2)
54         GRAV(3)= GRAV(3) + XYZ(3,N1) + XYZ(3,N2)
55   100   CONTINUE
56       HNGRAV = 0.5/NEDGE
57       GRAV(1)= GRAV(1) * HNGRAV
58       GRAV(2)= GRAV(2) * HNGRAV
59       GRAV(3)= GRAV(3) * HNGRAV
60       IF (ABS(A) .LT. 0.000001) A=0.
61       IF (ABS(B) .LT. 0.000001) B=0.
62       IF (ABS(C) .LT. 0.000001) C=0.
63       AREAI  = 1./SQRT(A*A + B*B + C*C)
64       ABCD(1)= A * AREAI
65       ABCD(2)= B * AREAI
66       ABCD(3)= C * AREAI
67       ABCD(4)=-(A*GRAV(1) + B*GRAV(2) + C*GRAV(3)) * AREAI
68       END