# Rotation Matrix

Thu Nov 24 13:40:39 EST 1994

```In article <1994Nov24.152711.1606 at inca.comlab.ox.ac.uk> smb at bioch.ox.ac.uk
(Simon Brocklehurst) writes:
> Is there a kind sole out there with easy access to  Crystallography
> Table type books?
>
> What I need is the matrix for rotation about an arbritary axis.
>
> Pleeeeeeaaaasssssseeeeee save me from having to work it out from scratch!
>
The following FORTRAN subroutine encodes something that I'm sure I found
somewhere in the International Tables years ago.
---------------------------
SUBROUTINE ROTMAT(DCOS,ANGLE,R)
C
C     Compute rotation matrix corresponding to rotation about an axis.
C     DCOS specifies direction cosines of rotation axis (i.e. a unit vector),
C     ANGLE is the rotation angle (in radians), and R is the output 3x3 matrix.
C
REAL DCOS(3),ANGLE,R(3,3),SINANG,COSANG,COSA1
SINANG = SIN(ANGLE)
COSANG = COS(ANGLE)
COSA1 = 1.0 - COSANG
R(1,1) = COSANG + DCOS(1)**2 * COSA1
R(2,2) = COSANG + DCOS(2)**2 * COSA1
R(3,3) = COSANG + DCOS(3)**2 * COSA1
R(1,2) = DCOS(1)*DCOS(2)*COSA1 - DCOS(3)*SINANG
R(1,3) = DCOS(1)*DCOS(3)*COSA1 + DCOS(2)*SINANG
R(2,1) = DCOS(2)*DCOS(1)*COSA1 + DCOS(3)*SINANG
R(2,3) = DCOS(2)*DCOS(3)*COSA1 - DCOS(1)*SINANG
R(3,1) = DCOS(3)*DCOS(1)*COSA1 - DCOS(2)*SINANG
R(3,2) = DCOS(3)*DCOS(2)*COSA1 + DCOS(1)*SINANG
RETURN
END
-----------------------------------