1 *
2 * \$Id\$
3 *
4 * \$Log\$
5 * Revision 1.1.1.1  1995/10/24 10:20:57  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 *
13       SUBROUTINE GVGRAD (XYZ, C, NC, GRA)
14 ************************************************************************
15 *                                                                      *
16 * GVGRAD calculates the gradient vector of a surface         VP 880314 *
17 *                                                                      *
18 * Input  : XYZ     coordinates of the point                            *
19 *          C(1)       number of non constant coefficients of the       *
20 *                        surface                                       *
21 *          C(2),C(3),... non constant coefficients of the surface      *
22 *          NC      total number of coefficients of the surface         *
23 *                                                                      *
24 * Output : GRA     gradient vector of the surface                      *
25 *                                                                      *
26 ************************************************************************
27       REAL           XYZ(3) , C(*), GRA(3)
28 *-----------------------------------------------------------------------
29 *
30 *     case with simplified surface X=C0, Y=C0, Z=C0, X*2+Y*2=C0
31 *     (happens only when initialisation is done)
32 *
33       IF (NC.EQ.2)              THEN
34         IAX = C(2)
35         IF (IAX.LE.3)           THEN
36           GRA(1) = 0
37           GRA(2) = 0
38           GRA(3) = 0
39           GRA(IAX) = 1
40         ELSE
41           GRA(1)   = 2.*XYZ(1)
42           GRA(2)   = 2.*XYZ(2)
43           GRA(3)   = 0.
44         ENDIF
45         GO TO 999
46       ENDIF
47 *
48 *     case with surfaces with 4, 7 or 10 coefficients (normal case)
49 *
50       GRA(1) = C(2)
51       GRA(2) = C(3)
52       GRA(3) = C(4)
53       IF (NC.EQ.4)              GO TO 999
54 *
55 *     case with surfaces with 7 or 10 coefficients
56 *
57       DO 100 I = 1,3
58   100   GRA(I) = GRA(I) + 2.*C(I+4)*XYZ(I)
59       IF (NC.NE.10)             GO TO 999
60 *
61 *     case with surfaces with 10 coefficients
62 *
63       GRA(1)   = GRA(1) + C(8)*XYZ(2)+C(10)*XYZ(3)
64       GRA(2)   = GRA(2) + C(8)*XYZ(1)+C( 9)*XYZ(3)
65       GRA(3)   = GRA(3) + C(9)*XYZ(2)+C(10)*XYZ(1)
67   999 RETURN
68       END