-
Notifications
You must be signed in to change notification settings - Fork 20
/
av2m.f
84 lines (75 loc) · 2.24 KB
/
av2m.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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,
* called the Euler axis. The "axial vector" supplied to this routine
* has the same direction as the Euler axis, and its magnitude is the
* amount of rotation 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.
*
* Last revision: 26 November 2005
*
* Copyright P.T.Wallace. All rights reserved.
*
* License:
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (see SLA_CONDITIONS); if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
*-
IMPLICIT NONE
REAL AXVEC(3),RMAT(3,3)
REAL X,Y,Z,PHI,S,C,W
* Rotation 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