mirror of
https://github.com/godotengine/godot.git
synced 2025-02-11 22:35:15 +08:00
C#: Add GetAngle
and GetAxis
to Quaternion
This commit is contained in:
parent
961a086d20
commit
b526a0d824
@ -158,6 +158,22 @@ namespace Godot
|
||||
return (x * b.x) + (y * b.y) + (z * b.z) + (w * b.w);
|
||||
}
|
||||
|
||||
public real_t GetAngle()
|
||||
{
|
||||
return 2 * Mathf.Acos(w);
|
||||
}
|
||||
|
||||
public Vector3 GetAxis()
|
||||
{
|
||||
if (Mathf.Abs(w) > 1 - Mathf.Epsilon)
|
||||
{
|
||||
return new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
real_t r = 1 / Mathf.Sqrt(1 - w * w);
|
||||
return new Vector3(x * r, y * r, z * r);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns Euler angles (in the YXZ convention: when decomposing,
|
||||
/// first Z, then X, and Y last) corresponding to the rotation
|
||||
|
Loading…
Reference in New Issue
Block a user