Skip to content

Commit

Permalink
added approximately equal checks (colors/vectors)
Browse files Browse the repository at this point in the history
  • Loading branch information
FreyaHolmer committed Jan 26, 2022
1 parent 7c95b6b commit 5ee0bf2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Mathfs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,18 @@ public static ulong BinomialCoef( uint n, uint k ) {
/// <param name="b">The second value to compare</param>
[MethodImpl( INLINE )] public static bool Approximately( float a, float b ) => Abs( b - a ) < Max( 0.000001f * Max( Abs( a ), Abs( b ) ), Epsilon * 8 );

/// <inheritdoc cref="Approximately(float,float)"/>
[MethodImpl( INLINE )] public static bool Approximately( Vector2 a, Vector2 b ) => Approximately( a.x, b.x ) && Approximately( a.y, b.y );

/// <inheritdoc cref="Approximately(float,float)"/>
[MethodImpl( INLINE )] public static bool Approximately( Vector3 a, Vector3 b ) => Approximately( a.x, b.x ) && Approximately( a.y, b.y ) && Approximately( a.z, b.z );

/// <inheritdoc cref="Approximately(float,float)"/>
[MethodImpl( INLINE )] public static bool Approximately( Vector4 a, Vector4 b ) => Approximately( a.x, b.x ) && Approximately( a.y, b.y ) && Approximately( a.z, b.z ) && Approximately( a.w, b.w );

/// <inheritdoc cref="Approximately(float,float)"/>
[MethodImpl( INLINE )] public static bool Approximately( Color a, Color b ) => Approximately( a.r, b.r ) && Approximately( a.g, b.g ) && Approximately( a.b, b.b ) && Approximately( a.a, b.a );

#endregion

#region Trigonometry
Expand Down

0 comments on commit 5ee0bf2

Please sign in to comment.