Improve IsNormalized()

This commit is contained in:
Joyless 2025-07-25 17:53:38 +01:00
parent 0dd9178269
commit cbc7dac0d5
4 changed files with 4 additions and 4 deletions

View file

@ -338,7 +338,7 @@ namespace Godot
/// <returns>A <see langword="bool"/> for whether the quaternion is normalized or not.</returns> /// <returns>A <see langword="bool"/> for whether the quaternion is normalized or not.</returns>
public readonly bool IsNormalized() public readonly bool IsNormalized()
{ {
return Mathf.Abs(LengthSquared() - 1) <= Mathf.Epsilon; return Mathf.IsEqualApprox(LengthSquared(), 1, Mathf.Epsilon);
} }
public readonly Quaternion Log() public readonly Quaternion Log()

View file

@ -370,7 +370,7 @@ namespace Godot
/// <returns>A <see langword="bool"/> indicating whether or not the vector is normalized.</returns> /// <returns>A <see langword="bool"/> indicating whether or not the vector is normalized.</returns>
public readonly bool IsNormalized() public readonly bool IsNormalized()
{ {
return Mathf.Abs(LengthSquared() - 1.0f) < Mathf.Epsilon; return Mathf.IsEqualApprox(LengthSquared(), 1, Mathf.Epsilon);
} }
/// <summary> /// <summary>

View file

@ -368,7 +368,7 @@ namespace Godot
/// <returns>A <see langword="bool"/> indicating whether or not the vector is normalized.</returns> /// <returns>A <see langword="bool"/> indicating whether or not the vector is normalized.</returns>
public readonly bool IsNormalized() public readonly bool IsNormalized()
{ {
return Mathf.Abs(LengthSquared() - 1.0f) < Mathf.Epsilon; return Mathf.IsEqualApprox(LengthSquared(), 1, Mathf.Epsilon);
} }
/// <summary> /// <summary>

View file

@ -318,7 +318,7 @@ namespace Godot
/// <returns>A <see langword="bool"/> indicating whether or not the vector is normalized.</returns> /// <returns>A <see langword="bool"/> indicating whether or not the vector is normalized.</returns>
public readonly bool IsNormalized() public readonly bool IsNormalized()
{ {
return Mathf.Abs(LengthSquared() - 1.0f) < Mathf.Epsilon; return Mathf.IsEqualApprox(LengthSquared(), 1, Mathf.Epsilon);
} }
/// <summary> /// <summary>