axis_angle_rotation Subroutine

public pure subroutine axis_angle_rotation(v, k, theta, vrot)

Rotate a 3x1 vector in space, given an axis and angle of rotation.

Reference

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), dimension(3) :: v

vector to rotate

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) :: vrot

result


Calls

proc~~axis_angle_rotation~~CallsGraph proc~axis_angle_rotation vector_module::axis_angle_rotation proc~cross vector_module::cross proc~axis_angle_rotation->proc~cross proc~unit vector_module::unit proc~axis_angle_rotation->proc~unit

Called by

proc~~axis_angle_rotation~~CalledByGraph proc~axis_angle_rotation vector_module::axis_angle_rotation proc~vector_test vector_module::vector_test proc~vector_test->proc~axis_angle_rotation

Source Code

    pure subroutine axis_angle_rotation(v,k,theta,vrot)

    implicit none

    real(wp),dimension(3),intent(in)  :: v      !! vector to rotate
    real(wp),dimension(3),intent(in)  :: k      !! rotation axis
    real(wp),intent(in)               :: theta  !! rotation angle [rad]
    real(wp),dimension(3),intent(out) :: vrot   !! result

    real(wp),dimension(3) :: khat
    real(wp) :: ct,st

    ct = cos(theta)
    st = sin(theta)
    khat = unit(k)   !rotation axis unit vector

    vrot = v*ct + cross(khat,v)*st + khat*dot_product(khat,v)*(one-ct)

    end subroutine axis_angle_rotation