axis_angle_rotation Function

private pure function axis_angle_rotation(v, k, theta) result(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 [deg]

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

result


Calls

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

Called by

proc~~axis_angle_rotation~~CalledByGraph proc~axis_angle_rotation axis_angle_rotation proc~generate_circle stl_file%generate_circle proc~generate_circle->proc~axis_angle_rotation proc~add_cone stl_file%add_cone proc~add_cone->proc~generate_circle proc~add_cylinder stl_file%add_cylinder proc~add_cylinder->proc~generate_circle proc~add_arrow stl_file%add_arrow proc~add_arrow->proc~add_cone proc~add_arrow->proc~add_cylinder proc~add_curve stl_file%add_curve proc~add_curve->proc~add_cylinder proc~add_axes stl_file%add_axes proc~add_axes->proc~add_arrow

Source Code

    pure function axis_angle_rotation(v,k,theta) result(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 [deg]
    real(wp),dimension(3)             :: vrot   !! result

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

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

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

    end function axis_angle_rotation