Computes the rotation matrix that corresponds to a
rotation about the axis k
by an angle theta
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(3) | :: | k |
rotation axis |
|
real(kind=wp), | intent(in) | :: | theta |
rotation angle [rad] |
||
real(kind=wp), | intent(out), | dimension(3,3) | :: | rotmat |
rotation matrix |
pure subroutine axis_angle_rotation_to_rotation_matrix(k,theta,rotmat) implicit none real(wp),dimension(3),intent(in) :: k !! rotation axis real(wp),intent(in) :: theta !! rotation angle [rad] real(wp),dimension(3,3),intent(out) :: rotmat !! rotation matrix real(wp),dimension(3,3),parameter :: I = & reshape([one,zero,zero,zero,one,zero,zero,zero,one],[3,3]) !! 3x3 identity matrix real(wp),dimension(3,3) :: w real(wp),dimension(3) :: khat real(wp) :: ct,st ct = cos(theta) st = sin(theta) khat = unit(k) w = cross_matrix(khat) rotmat = I + w*st + matmul(w,w)*(one-ct) end subroutine axis_angle_rotation_to_rotation_matrix