From 28a8caac26f5d460715493bcfadd5b55937f7259 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Sat, 14 Jan 2023 03:43:21 +0100 Subject: C#: Make `Length` and `LengthSquared` into methods in `Quaternion`. The `Length` and `LengthSquared` members are implemented as methods in every other C# struct, `Quaternion` was the only one implementing them as properties. --- .../mono/glue/GodotSharp/GodotSharp/Core/Basis.cs | 2 +- .../glue/GodotSharp/GodotSharp/Core/Quaternion.cs | 46 +++++++++++----------- 2 files changed, 24 insertions(+), 24 deletions(-) (limited to 'modules/mono/glue') diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs index 90fdb14953..c7cdc18b21 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs @@ -797,7 +797,7 @@ namespace Godot /// The quaternion to create the basis from. 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; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs index 10116e9fa4..47106bb402 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs @@ -96,27 +96,6 @@ namespace Godot } } - /// - /// Returns the length (magnitude) of the quaternion. - /// - /// - /// Equivalent to Mathf.Sqrt(LengthSquared). - public readonly real_t Length - { - get { return Mathf.Sqrt(LengthSquared); } - } - - /// - /// Returns the squared length (squared magnitude) of the quaternion. - /// This method runs faster than , so prefer it if - /// you need to compare quaternions or need the squared length for some formula. - /// - /// Equivalent to Dot(this). - public readonly real_t LengthSquared - { - get { return Dot(this); } - } - /// /// Returns the angle between this quaternion and . /// This is the magnitude of the angle you would need to rotate @@ -355,7 +334,7 @@ namespace Godot /// A for whether the quaternion is normalized or not. 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); } + /// + /// Returns the length (magnitude) of the quaternion. + /// + /// + /// Equivalent to Mathf.Sqrt(LengthSquared). + public readonly real_t Length() + { + return Mathf.Sqrt(LengthSquared()); + } + + /// + /// Returns the squared length (squared magnitude) of the quaternion. + /// This method runs faster than , so prefer it if + /// you need to compare quaternions or need the squared length for some formula. + /// + /// Equivalent to Dot(this). + public readonly real_t LengthSquared() + { + return Dot(this); + } + /// /// Returns a copy of the quaternion, normalized to unit length. /// /// The normalized quaternion. public readonly Quaternion Normalized() { - return this / Length; + return this / Length(); } /// -- cgit v1.2.3