The rotation by angle (radians) about axis (need not be unit length).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | axis(3) |
rotation axis (any length; zero: the identity) |
||
| real(kind=wp), | intent(in) | :: | angle |
(radians) |
pure function quat_from_axis_angle(axis, angle) result(q) real(wp), intent(in) :: axis(3) !! rotation axis (any length; zero: the identity) real(wp), intent(in) :: angle !! (radians) real(wp) :: q(4) real(wp) :: n n = norm2(axis) if (n == 0.0_wp) then q = quat_identity else q(1:3) = axis / n * sin(0.5_wp * angle) q(4) = cos(0.5_wp * angle) end if end function quat_from_axis_angle