add LookAt method to Quaternion

pull/14/head
cosmonaut 2021-03-26 12:07:46 -07:00
parent 984e30cc4c
commit 3b83eb41da
1 changed files with 10 additions and 0 deletions

View File

@ -881,6 +881,16 @@ namespace MoonWorks.Math
result.W = quaternion.W * num;
}
public static Quaternion LookAt(in Vector3 forward, in Vector3 up)
{
Matrix4x4 orientation = Matrix4x4.Identity;
orientation.Forward = forward;
orientation.Right = Vector3.Normalize(Vector3.Cross(forward, up));
orientation.Up = Vector3.Cross(orientation.Right, forward);
return Quaternion.CreateFromRotationMatrix(orientation);
}
#endregion
#region Public Static Operator Overloads