Skip to content

Commit d8b057d

Browse files
committed
Merge pull request #108974 from Joy-less/Improve-IsNormalized()
Improve `IsNormalized()` in C#
2 parents b059849 + cbc7dac commit d8b057d

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public readonly bool IsFinite()
338338
/// <returns>A <see langword="bool"/> for whether the quaternion is normalized or not.</returns>
339339
public readonly bool IsNormalized()
340340
{
341-
return Mathf.Abs(LengthSquared() - 1) <= Mathf.Epsilon;
341+
return Mathf.IsEqualApprox(LengthSquared(), 1, Mathf.Epsilon);
342342
}
343343

344344
public readonly Quaternion Log()

modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public readonly bool IsFinite()
370370
/// <returns>A <see langword="bool"/> indicating whether or not the vector is normalized.</returns>
371371
public readonly bool IsNormalized()
372372
{
373-
return Mathf.Abs(LengthSquared() - 1.0f) < Mathf.Epsilon;
373+
return Mathf.IsEqualApprox(LengthSquared(), 1, Mathf.Epsilon);
374374
}
375375

376376
/// <summary>

modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ public readonly bool IsFinite()
368368
/// <returns>A <see langword="bool"/> indicating whether or not the vector is normalized.</returns>
369369
public readonly bool IsNormalized()
370370
{
371-
return Mathf.Abs(LengthSquared() - 1.0f) < Mathf.Epsilon;
371+
return Mathf.IsEqualApprox(LengthSquared(), 1, Mathf.Epsilon);
372372
}
373373

374374
/// <summary>

modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public readonly bool IsFinite()
318318
/// <returns>A <see langword="bool"/> indicating whether or not the vector is normalized.</returns>
319319
public readonly bool IsNormalized()
320320
{
321-
return Mathf.Abs(LengthSquared() - 1.0f) < Mathf.Epsilon;
321+
return Mathf.IsEqualApprox(LengthSquared(), 1, Mathf.Epsilon);
322322
}
323323

324324
/// <summary>

0 commit comments

Comments
 (0)