2024-01-24 12:42:18 +03:00
|
|
|
using Syntriax.Engine.Core;
|
|
|
|
|
2024-01-23 18:39:25 +03:00
|
|
|
namespace Syntriax.Engine.Physics2D.Primitives;
|
|
|
|
|
|
|
|
public record LineEquation(float Slope, float OffsetY)
|
|
|
|
{
|
2024-01-23 19:16:31 +03:00
|
|
|
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);
|
2024-01-23 18:39:25 +03:00
|
|
|
}
|