rotation_matrix Function

public pure function rotation_matrix(axis, angle) result(rotmat)

The 3x3 rotation matrix for a rotation about the x, y, or z-axis.

EXAMPLE

    real(wp),dimension(3,3) :: rotmat
    real(wp),dimension(3) :: vec,vec2
    real(wp) :: ang
    ang = pi / 4.0_wp
    vec = [1.414_wp, 0.0_wp, 0.0_wp]
    rotmat = rotation_matrix(z_axis,ang)
    vec2 = matmul(rotmat,vec)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: axis

x_axis, y_axis, or z_axis

real(kind=wp), intent(in) :: angle

angle in radians

Return Value real(kind=wp), dimension(3,3)

the rotation matrix


Called by

proc~~rotation_matrix~~CalledByGraph proc~rotation_matrix vector_module::rotation_matrix proc~iau_rotation_matrix iau_orientation_module::iau_rotation_matrix proc~iau_rotation_matrix->proc~rotation_matrix proc~vector_test vector_module::vector_test proc~vector_test->proc~rotation_matrix proc~icrf_to_iau_earth iau_orientation_module::icrf_to_iau_earth proc~icrf_to_iau_earth->proc~iau_rotation_matrix proc~icrf_to_iau_moon iau_orientation_module::icrf_to_iau_moon proc~icrf_to_iau_moon->proc~iau_rotation_matrix proc~get_c_cdot_iau_earth transformation_module::iau_earth_rotating_frame%get_c_cdot_iau_earth proc~get_c_cdot_iau_earth->proc~icrf_to_iau_earth proc~get_c_cdot_iau_moon transformation_module::iau_moon_rotating_frame%get_c_cdot_iau_moon proc~get_c_cdot_iau_moon->proc~icrf_to_iau_moon proc~iau_test iau_orientation_module::iau_test proc~iau_test->proc~icrf_to_iau_earth proc~iau_test->proc~icrf_to_iau_moon

Source Code

    pure function rotation_matrix(axis,angle) result(rotmat)

    implicit none

    real(wp),dimension(3,3) :: rotmat   !! the rotation matrix
    integer,intent(in)      :: axis     !! x_axis, y_axis, or z_axis
    real(wp),intent(in)     :: angle    !! angle in radians

    real(wp) :: c,s

    !precompute these:
    c = cos(angle)
    s = sin(angle)

    select case (axis)
    case(x_axis); rotmat = reshape([one, zero, zero, zero, c, -s, zero, s, c],[3,3])
    case(y_axis); rotmat = reshape([c, zero, s, zero, one, zero, -s, zero, c],[3,3])
    case(z_axis); rotmat = reshape([c, -s, zero, s, c, zero, zero, zero, one],[3,3])
    case default; rotmat = zero
    end select

    end function rotation_matrix