16 lines
730 B
C#
16 lines
730 B
C#
namespace Syntriax.Engine.Physics2D.Primitives;
|
|
|
|
public record LineEquation(float Slope, float 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);
|
|
}
|