mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-09 23:35:41 +00:00
Add ToQuaternion to Rotation struct
This commit is contained in:
parent
703f099187
commit
2f3069d1bf
@ -172,6 +172,24 @@ public readonly struct Rotation : IEquatable<Rotation>, IFormattable
|
||||
return HashCode.Combine(Angle, Roll, Tilt, Yaw);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this rotation to a quaternion.
|
||||
/// </summary>
|
||||
/// <returns>An instance of <see cref="Quaternion" /> representing the same rotation as this instance.</returns>
|
||||
public Quaternion ToQuaternion()
|
||||
{
|
||||
if (double.IsPositiveInfinity(Angle))
|
||||
{
|
||||
var yaw = (float)Yaw.DegreesToRadians();
|
||||
var tilt = (float)Tilt.DegreesToRadians();
|
||||
var roll = (float)Roll.DegreesToRadians();
|
||||
return Quaternion.CreateFromYawPitchRoll(yaw, tilt, roll);
|
||||
}
|
||||
|
||||
var axis = new Vector3d(Tilt, Yaw, Roll);
|
||||
return Quaternion.CreateFromAxisAngle((Vector3)axis, (float)Angle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string representation of these coordinates.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user