Merge pull request #95269 from raulsntos/dotnet/determinant
C#: Expose `Transform2D.Determinant()`
This commit is contained in:
commit
65c6897e55
|
@ -47,7 +47,7 @@ namespace Godot
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
real_t detSign = Mathf.Sign(BasisDeterminant());
|
real_t detSign = Mathf.Sign(Determinant());
|
||||||
return new Vector2(X.Length(), detSign * Y.Length());
|
return new Vector2(X.Length(), detSign * Y.Length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ namespace Godot
|
||||||
{
|
{
|
||||||
get
|
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;
|
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>
|
/// <returns>The inverse transformation matrix.</returns>
|
||||||
public readonly Transform2D AffineInverse()
|
public readonly Transform2D AffineInverse()
|
||||||
{
|
{
|
||||||
real_t det = BasisDeterminant();
|
real_t det = Determinant();
|
||||||
|
|
||||||
if (det == 0)
|
if (det == 0)
|
||||||
throw new InvalidOperationException("Matrix determinant is zero and cannot be inverted.");
|
throw new InvalidOperationException("Matrix determinant is zero and cannot be inverted.");
|
||||||
|
@ -157,15 +157,16 @@ namespace Godot
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the determinant of the basis matrix. If the basis is
|
/// 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 negative determinant means the basis was flipped, so one part of
|
||||||
/// A zero determinant means the basis isn't invertible,
|
/// the scale is negative. A zero determinant means the basis isn't
|
||||||
/// and is usually considered invalid.
|
/// invertible, and is usually considered invalid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The determinant of the basis matrix.</returns>
|
/// <returns>The determinant of the basis matrix.</returns>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private readonly real_t BasisDeterminant()
|
public readonly real_t Determinant()
|
||||||
{
|
{
|
||||||
return (X.X * Y.Y) - (X.Y * Y.X);
|
return (X.X * Y.Y) - (X.Y * Y.X);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue