mirror of
https://github.com/godotengine/godot.git
synced 2025-02-23 23:15:07 +08:00
Add IsZeroApprox
to C# vectors
This commit is contained in:
parent
3c9bf4bc21
commit
14c16746f3
@ -529,7 +529,7 @@
|
|||||||
<return type="bool" />
|
<return type="bool" />
|
||||||
<param index="0" name="x" type="float" />
|
<param index="0" name="x" type="float" />
|
||||||
<description>
|
<description>
|
||||||
Returns [code]true[/code] if [param x] is zero or almost zero.
|
Returns [code]true[/code] if [param x] is zero or almost zero. The comparison is done using a tolerance calculation with a small internal epsilon.
|
||||||
This function is faster than using [method is_equal_approx] with one value as zero.
|
This function is faster than using [method is_equal_approx] with one value as zero.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
@ -460,10 +460,11 @@ namespace Godot
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns <see langword="true"/> if <paramref name="s"/> is approximately zero.
|
/// Returns <see langword="true"/> if <paramref name="s"/> is zero or almost zero.
|
||||||
/// The comparison is done using a tolerance calculation with <see cref="Epsilon"/>.
|
/// The comparison is done using a tolerance calculation with <see cref="Epsilon"/>.
|
||||||
///
|
///
|
||||||
/// This method is faster than using <see cref="IsEqualApprox(real_t, real_t)"/> with one value as zero.
|
/// This method is faster than using <see cref="IsEqualApprox(real_t, real_t)"/> with
|
||||||
|
/// one value as zero.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="s">The value to check.</param>
|
/// <param name="s">The value to check.</param>
|
||||||
/// <returns>A <see langword="bool"/> for whether or not the value is nearly zero.</returns>
|
/// <returns>A <see langword="bool"/> for whether or not the value is nearly zero.</returns>
|
||||||
|
@ -988,6 +988,18 @@ namespace Godot
|
|||||||
return Mathf.IsEqualApprox(x, other.x) && Mathf.IsEqualApprox(y, other.y);
|
return Mathf.IsEqualApprox(x, other.x) && Mathf.IsEqualApprox(y, other.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns <see langword="true"/> if this vector's values are approximately zero,
|
||||||
|
/// by running <see cref="Mathf.IsZeroApprox(real_t)"/> on each component.
|
||||||
|
/// This method is faster than using <see cref="IsEqualApprox"/> with one value
|
||||||
|
/// as a zero vector.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Whether or not the vector is approximately zero.</returns>
|
||||||
|
public readonly bool IsZeroApprox()
|
||||||
|
{
|
||||||
|
return Mathf.IsZeroApprox(x) && Mathf.IsZeroApprox(y);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serves as the hash function for <see cref="Vector2"/>.
|
/// Serves as the hash function for <see cref="Vector2"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1059,6 +1059,18 @@ namespace Godot
|
|||||||
return Mathf.IsEqualApprox(x, other.x) && Mathf.IsEqualApprox(y, other.y) && Mathf.IsEqualApprox(z, other.z);
|
return Mathf.IsEqualApprox(x, other.x) && Mathf.IsEqualApprox(y, other.y) && Mathf.IsEqualApprox(z, other.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns <see langword="true"/> if this vector's values are approximately zero,
|
||||||
|
/// by running <see cref="Mathf.IsZeroApprox(real_t)"/> on each component.
|
||||||
|
/// This method is faster than using <see cref="IsEqualApprox"/> with one value
|
||||||
|
/// as a zero vector.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Whether or not the vector is approximately zero.</returns>
|
||||||
|
public readonly bool IsZeroApprox()
|
||||||
|
{
|
||||||
|
return Mathf.IsZeroApprox(x) && Mathf.IsZeroApprox(y) && Mathf.IsZeroApprox(z);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serves as the hash function for <see cref="Vector3"/>.
|
/// Serves as the hash function for <see cref="Vector3"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -856,6 +856,18 @@ namespace Godot
|
|||||||
return Mathf.IsEqualApprox(x, other.x) && Mathf.IsEqualApprox(y, other.y) && Mathf.IsEqualApprox(z, other.z) && Mathf.IsEqualApprox(w, other.w);
|
return Mathf.IsEqualApprox(x, other.x) && Mathf.IsEqualApprox(y, other.y) && Mathf.IsEqualApprox(z, other.z) && Mathf.IsEqualApprox(w, other.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns <see langword="true"/> if this vector's values are approximately zero,
|
||||||
|
/// by running <see cref="Mathf.IsZeroApprox(real_t)"/> on each component.
|
||||||
|
/// This method is faster than using <see cref="IsEqualApprox"/> with one value
|
||||||
|
/// as a zero vector.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Whether or not the vector is approximately zero.</returns>
|
||||||
|
public readonly bool IsZeroApprox()
|
||||||
|
{
|
||||||
|
return Mathf.IsZeroApprox(x) && Mathf.IsZeroApprox(y) && Mathf.IsZeroApprox(z) && Mathf.IsZeroApprox(w);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serves as the hash function for <see cref="Vector4"/>.
|
/// Serves as the hash function for <see cref="Vector4"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user