- Home /
Question by
AureliusII · Jul 20, 2019 at 06:20 PM ·
rotationmathquaternions
Cap Slerp rotation if above certain angle
I am trying to cap the angle of rotation of a Slerp if it goes above 1 degree to a quaternion which Euler angle magnitude would be 1 degree and in the same direction as the Slerp function.
This is my current attempt.
void Slerp()
{
var localRotation = rcsSpace.localRotation;
var newRot = Quaternion.SlerpUnclamped(localRotation, plannedRot, t).normalized;
var rotVector = newRot * Quaternion.Inverse(localRotation);
if (Quaternion.Angle(localRotation, newRot) < 1f)
{
rcsSpace.localRotation = newRot;
}
else
{
rcsSpace.localRotation = rotVector * localRotation;
}
}
I was thinking that I could get the magnitude of the rotVector and divide it by itself however this does not seem possible with Quaternions.
Many Thanks.
Comment
Your answer
Follow this Question
Related Questions
quaternion - rotate camera based on original facing at scene start? 0 Answers
VR: Controller rotation delta along other axis 2 Answers
Problem with Clamping Values for Object's Rotation 1 Answer
Rotation Complications + rotation with parents and children? 1 Answer
Rotating 2D sprite to match surface. 0 Answers