All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
pxang3.f
Go to the documentation of this file.
1 CDECK ID>, PXANG3.
2  SUBROUTINE pxang3 (VEC1,VEC2,COST,THET,IERR)
3 *.*********************************************************
4 *. ------
5 *. PXANG3
6 *. ------
7 *. SOURCE: VECSUB (V. Blobel)
8 *. Calculate the angle beteen two 3-vectors
9 *. Usage :
10 *.
11 *. INTEGER IERR
12 *. REAL VEC1 (3.or.more),
13 *. + VEC2 (3.or.more)
14 *. REAL COST,THET
15 *.
16 *. CALL PXANG3 (VEC1,VEC2,COST,THET,IERR)
17 *.
18 *. INPUT : VEC1 The first vector
19 *. INPUT : VEC2 The second vector
20 *. OUTPUT : COST Cosine of the angle between the vectors
21 *. OUTPUT : THET The angle between the vectors (radians)
22 *. OUTPUT : IERR = 0 if all is OK ; = -1 otherwise
23 *.
24 *.*********************************************************
25  IMPLICIT NONE
26  DOUBLE PRECISION ax,bx,cx,dx
27  REAL vec1 (*),vec2 (*)
28  REAL cost,thet
29  INTEGER ix,ierr
30  ierr = 0
31  ax = 0d0
32  bx = 0d0
33  cx = 0d0
34  DO 120 ix = 1,3
35  ax = ax + vec1(ix) * vec1(ix)
36  bx = bx + vec2(ix) * vec2(ix)
37  cx = cx + vec1(ix) * vec2(ix)
38  120 CONTINUE
39  dx = dsqrt(ax * bx)
40  IF (dx.NE.0.0) THEN
41  dx = cx / dx
42  ELSE
43  WRITE (6,fmt='('' PXANG3: Error, DX='',E12.4)') dx
44  ierr = -1
45  RETURN
46  END IF
47  IF (dabs(dx).GT.1.d0) dx = dsign(1.d0,dx)
48  cost = dx
49  thet = dacos(dx)
50  RETURN
51  END
double cx[MAX_LINK]
subroutine pxang3(VEC1, VEC2, COST, THET, IERR)
Definition: pxang3.f:2