Merge pull request #71458 from raulsntos/dotnet/quaternion
C#: Make `Length` and `LengthSquared` into methods in `Quaternion`.
This commit is contained in:
commit
ba551727ef
2 changed files with 24 additions and 24 deletions
|
@ -787,7 +787,7 @@ namespace Godot
|
|||
/// <param name="quaternion">The quaternion to create the basis from.</param>
|
||||
public Basis(Quaternion quaternion)
|
||||
{
|
||||
real_t s = 2.0f / quaternion.LengthSquared;
|
||||
real_t s = 2.0f / quaternion.LengthSquared();
|
||||
|
||||
real_t xs = quaternion.x * s;
|
||||
real_t ys = quaternion.y * s;
|
||||
|
|
|
@ -96,27 +96,6 @@ namespace Godot
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the length (magnitude) of the quaternion.
|
||||
/// </summary>
|
||||
/// <seealso cref="LengthSquared"/>
|
||||
/// <value>Equivalent to <c>Mathf.Sqrt(LengthSquared)</c>.</value>
|
||||
public readonly real_t Length
|
||||
{
|
||||
get { return Mathf.Sqrt(LengthSquared); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the squared length (squared magnitude) of the quaternion.
|
||||
/// This method runs faster than <see cref="Length"/>, so prefer it if
|
||||
/// you need to compare quaternions or need the squared length for some formula.
|
||||
/// </summary>
|
||||
/// <value>Equivalent to <c>Dot(this)</c>.</value>
|
||||
public readonly real_t LengthSquared
|
||||
{
|
||||
get { return Dot(this); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the angle between this quaternion and <paramref name="to"/>.
|
||||
/// This is the magnitude of the angle you would need to rotate
|
||||
|
@ -355,7 +334,7 @@ namespace Godot
|
|||
/// <returns>A <see langword="bool"/> for whether the quaternion is normalized or not.</returns>
|
||||
public readonly bool IsNormalized()
|
||||
{
|
||||
return Mathf.Abs(LengthSquared - 1) <= Mathf.Epsilon;
|
||||
return Mathf.Abs(LengthSquared() - 1) <= Mathf.Epsilon;
|
||||
}
|
||||
|
||||
public readonly Quaternion Log()
|
||||
|
@ -364,13 +343,34 @@ namespace Godot
|
|||
return new Quaternion(v.x, v.y, v.z, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the length (magnitude) of the quaternion.
|
||||
/// </summary>
|
||||
/// <seealso cref="LengthSquared"/>
|
||||
/// <value>Equivalent to <c>Mathf.Sqrt(LengthSquared)</c>.</value>
|
||||
public readonly real_t Length()
|
||||
{
|
||||
return Mathf.Sqrt(LengthSquared());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the squared length (squared magnitude) of the quaternion.
|
||||
/// This method runs faster than <see cref="Length"/>, so prefer it if
|
||||
/// you need to compare quaternions or need the squared length for some formula.
|
||||
/// </summary>
|
||||
/// <value>Equivalent to <c>Dot(this)</c>.</value>
|
||||
public readonly real_t LengthSquared()
|
||||
{
|
||||
return Dot(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the quaternion, normalized to unit length.
|
||||
/// </summary>
|
||||
/// <returns>The normalized quaternion.</returns>
|
||||
public readonly Quaternion Normalized()
|
||||
{
|
||||
return this / Length;
|
||||
return this / Length();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in a new issue