aboutsummaryrefslogtreecommitdiff
path: root/src/slalib/av2m.f
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-03-04 21:21:30 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-03-04 21:21:30 -0500
commitd54fe7c1f704a63824c5bfa0ece65245572e9b27 (patch)
treeafc52015ffc2c74e0266653eecef1c8ef8ba5d91 /src/slalib/av2m.f
downloadcalfuse-d54fe7c1f704a63824c5bfa0ece65245572e9b27.tar.gz
Initial commit
Diffstat (limited to 'src/slalib/av2m.f')
-rw-r--r--src/slalib/av2m.f68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/slalib/av2m.f b/src/slalib/av2m.f
new file mode 100644
index 0000000..ec1967c
--- /dev/null
+++ b/src/slalib/av2m.f
@@ -0,0 +1,68 @@
+ SUBROUTINE sla_AV2M (AXVEC, RMAT)
+*+
+* - - - - -
+* A V 2 M
+* - - - - -
+*
+* Form the rotation matrix corresponding to a given axial vector.
+*
+* (single precision)
+*
+* A rotation matrix describes a rotation about some arbitrary axis.
+* The axis is called the Euler axis, and the angle through which the
+* reference frame rotates is called the Euler angle. The axial
+* vector supplied to this routine has the same direction as the
+* Euler axis, and its magnitude is the Euler angle in radians.
+*
+* Given:
+* AXVEC r(3) axial vector (radians)
+*
+* Returned:
+* RMAT r(3,3) rotation matrix
+*
+* If AXVEC is null, the unit matrix is returned.
+*
+* The reference frame rotates clockwise as seen looking along
+* the axial vector from the origin.
+*
+* P.T.Wallace Starlink June 1989
+*
+* Copyright (C) 1995 Rutherford Appleton Laboratory
+*-
+
+ IMPLICIT NONE
+
+ REAL AXVEC(3),RMAT(3,3)
+
+ REAL X,Y,Z,PHI,S,C,W
+
+
+
+* Euler angle - magnitude of axial vector - and functions
+ X = AXVEC(1)
+ Y = AXVEC(2)
+ Z = AXVEC(3)
+ PHI = SQRT(X*X+Y*Y+Z*Z)
+ S = SIN(PHI)
+ C = COS(PHI)
+ W = 1.0-C
+
+* Euler axis - direction of axial vector (perhaps null)
+ IF (PHI.NE.0.0) THEN
+ X = X/PHI
+ Y = Y/PHI
+ Z = Z/PHI
+ END IF
+
+* Compute the rotation matrix
+ RMAT(1,1) = X*X*W+C
+ RMAT(1,2) = X*Y*W+Z*S
+ RMAT(1,3) = X*Z*W-Y*S
+ RMAT(2,1) = X*Y*W-Z*S
+ RMAT(2,2) = Y*Y*W+C
+ RMAT(2,3) = Y*Z*W+X*S
+ RMAT(3,1) = X*Z*W+Y*S
+ RMAT(3,2) = Y*Z*W-X*S
+ RMAT(3,3) = Z*Z*W+C
+
+ END