refactor: LineEquation
This commit is contained in:
parent
6a5d10980a
commit
3b299c947c
|
@ -2,7 +2,14 @@ namespace Syntriax.Engine.Physics2D.Primitives;
|
|||
|
||||
public record LineEquation(float Slope, float OffsetY)
|
||||
{
|
||||
public float Resolve(float x) => Slope * x + OffsetY; // y = mx + b
|
||||
public bool ApproximatelyEquals(LineEquation other)
|
||||
=> Slope.ApproximatelyEquals(other.Slope) && OffsetY.ApproximatelyEquals(other.OffsetY);
|
||||
public static float Resolve(LineEquation lineEquation, float x) => lineEquation.Slope * x + lineEquation.OffsetY; // y = mx + b
|
||||
|
||||
public static bool ApproximatelyEquals(LineEquation left, LineEquation right)
|
||||
=> left.Slope.ApproximatelyEquals(right.Slope) && left.OffsetY.ApproximatelyEquals(right.OffsetY);
|
||||
}
|
||||
|
||||
public static class LineEquationExtensions
|
||||
{
|
||||
public static float Resolve(this LineEquation lineEquation, float x) => LineEquation.Resolve(lineEquation, x);
|
||||
public static bool ApproximatelyEquals(this LineEquation left, LineEquation right) => LineEquation.ApproximatelyEquals(left, right);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue