Quaternion Shortest Rotation helper

mail@pastecode.io avatar
unknown
csharp
3 years ago
422 B
266
Indexable
Never
public static Quaternion ShortestRotation(Quaternion to, Quaternion from)
{
    if (Quaternion.Dot(to, from) < 0)
    {
        return to * Quaternion.Inverse(Multiply(from, -1));
    }

    else return to * Quaternion.Inverse(from);
}



public static Quaternion Multiply(Quaternion input, float scalar)
{
    return new Quaternion(input.x * scalar, input.y * scalar, input.z * scalar, input.w * scalar);
}