diff options
| author | Raul Santos <raulsntos@gmail.com> | 2023-10-03 17:27:43 +0200 |
|---|---|---|
| committer | Spartan322 <Megacake1234@gmail.com> | 2024-11-01 18:09:29 -0400 |
| commit | 2c0b31c01a23a5ca2ae3fafcf108ff67ea3ce3af (patch) | |
| tree | 456f791d89ab6d387e5f3340d79593bf6e523869 | |
| parent | a4c3e1f008ccc8ad504ac0b8ce26d42282bc69bd (diff) | |
| download | redot-engine-2c0b31c01a23a5ca2ae3fafcf108ff67ea3ce3af.tar.gz | |
C#: Expose `Transform2D.Determinant()`
(cherry picked from commit 262671c64486ee8515e2e29750225778f152b16d)
| -rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs index a5fa89d3bf..f943a3049d 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs @@ -47,7 +47,7 @@ namespace Godot { get { - real_t detSign = Mathf.Sign(BasisDeterminant()); + real_t detSign = Mathf.Sign(Determinant()); return new Vector2(X.Length(), detSign * Y.Length()); } } @@ -59,7 +59,7 @@ namespace Godot { get { - real_t detSign = Mathf.Sign(BasisDeterminant()); + real_t detSign = Mathf.Sign(Determinant()); return Mathf.Acos(X.Normalized().Dot(detSign * Y.Normalized())) - Mathf.Pi * 0.5f; } } @@ -135,7 +135,7 @@ namespace Godot /// <returns>The inverse transformation matrix.</returns> public readonly Transform2D AffineInverse() { - real_t det = BasisDeterminant(); + real_t det = Determinant(); if (det == 0) throw new InvalidOperationException("Matrix determinant is zero and cannot be inverted."); @@ -157,15 +157,16 @@ namespace Godot /// <summary> /// Returns the determinant of the basis matrix. If the basis is - /// uniformly scaled, its determinant is the square of the scale. + /// uniformly scaled, then its determinant equals the square of the + /// scale factor. /// - /// A negative determinant means the Y scale is negative. - /// A zero determinant means the basis isn't invertible, - /// and is usually considered invalid. + /// A negative determinant means the basis was flipped, so one part of + /// the scale is negative. A zero determinant means the basis isn't + /// invertible, and is usually considered invalid. /// </summary> /// <returns>The determinant of the basis matrix.</returns> [MethodImpl(MethodImplOptions.AggressiveInlining)] - private readonly real_t BasisDeterminant() + public readonly real_t Determinant() { return (X.X * Y.Y) - (X.Y * Y.X); } |
