Class Slerp
java.lang.Object
org.apache.commons.numbers.quaternion.Slerp
- All Implemented Interfaces:
DoubleFunction<Quaternion>
Perform spherical linear interpolation (Slerp).
The Slerp algorithm is designed to interpolate smoothly between
two rotations/orientations, producing a constant-speed motion along an arc.
The original purpose of this algorithm was to animate 3D rotations. All output
quaternions are in positive polar form, meaning a unit quaternion with a positive
scalar component.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
Linear interpolation, used when the quaternions are too closely aligned.private class
Spherical interpolation, used when the quaternions are too closely aligned. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DoubleFunction
<Quaternion> Linear or spherical interpolation algorithm.private final Quaternion
End of the interpolation.private static final double
Threshold max value for the dot product.private final Quaternion
Start of the interpolation. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
MAX_DOT_THRESHOLD
private static final double MAX_DOT_THRESHOLDThreshold max value for the dot product. If the quaternion dot product is greater than this value (i.e. the quaternions are very close to each other), then the quaternions are linearly interpolated instead of spherically interpolated.- See Also:
-
start
Start of the interpolation. -
end
End of the interpolation. -
algo
Linear or spherical interpolation algorithm.
-
-
Constructor Details
-
Slerp
- Parameters:
start
- Start of the interpolation.end
- End of the interpolation.
-
-
Method Details
-
apply
Performs the interpolation. The rotation returned by this method is controlled by the interpolation parameter,t
. All other values are interpolated (or extrapolated ift
is outside of the[0, 1]
range). The returned quaternion is in positive polar form, meaning that it is a unit quaternion with a positive scalar component.- Specified by:
apply
in interfaceDoubleFunction<Quaternion>
- Parameters:
t
- Interpolation control parameter. Whent = 0
, a rotation equal to the start instance is returned. Whent = 1
, a rotation equal to the end instance is returned.- Returns:
- an interpolated quaternion in positive polar form.
-