Rotate a 3x1 vector in space, given an axis and angle of rotation.
Type | Intent | Optional | 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] |
result
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