feat: ensured all primitives have ToString, GetHashCode & Equals methods
This commit is contained in:
@@ -38,6 +38,25 @@ public readonly struct Line2DEquation(float slope, float offsetY)
|
||||
/// <returns>True if the line equations are approximately equal; otherwise, false.</returns>
|
||||
public static bool ApproximatelyEquals(Line2DEquation left, Line2DEquation right, float epsilon = float.Epsilon)
|
||||
=> left.Slope.ApproximatelyEquals(right.Slope, epsilon) && left.OffsetY.ApproximatelyEquals(right.OffsetY, epsilon);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified object is equal to the current <see cref="Line2DEquation"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current <see cref="Line2DEquation"/>.</param>
|
||||
/// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Line2DEquation"/>; otherwise, <see cref="false"/>.</returns>
|
||||
public override bool Equals(object? obj) => obj is Line2DEquation lineEquation && Slope.Equals(lineEquation.Slope) && OffsetY.Equals(lineEquation.OffsetY);
|
||||
|
||||
/// <summary>
|
||||
/// Generates a hash code for the <see cref="Line2DEquation"/>.
|
||||
/// </summary>
|
||||
/// <returns>A hash code for the <see cref="Line2DEquation"/>.</returns>
|
||||
public override int GetHashCode() => System.HashCode.Combine(Slope, OffsetY);
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="Line2DEquation"/> to its string representation.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of the <see cref="Line2DEquation"/>.</returns>
|
||||
public override string ToString() => $"{nameof(Line2DEquation)}({Slope}, {OffsetY})";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Reference in New Issue
Block a user