diff --git a/Engine.Physics2D/Primitives/Line.cs b/Engine.Physics2D/Primitives/Line.cs index 10d5df7..47f4d29 100644 --- a/Engine.Physics2D/Primitives/Line.cs +++ b/Engine.Physics2D/Primitives/Line.cs @@ -202,6 +202,40 @@ public readonly struct Line(Vector2D from, Vector2D to) /// public static class LineExtensions { + /// + /// Linearly interpolates between the two endpoints of the segment using parameter 't'. + /// /// + public static Vector2D Lerp(this Line line, float t) => Line.Lerp(line, t); + + + /// + /// The equation of the defined by this segment. + /// + public static LineEquation ToLineEquation(this Line line) => Line.GetLineEquation(line); + + + /// + /// Determines whether the specified lies on the . + /// + public static bool Intersects(this Line line, Vector2D point) => Line.Intersects(line, point); + + /// + /// Calculates the parameter 't' representing the point's position on the segment. + /// + public static float GetT(this Line line, Vector2D point) => Line.GetT(line, point); + + + /// + /// Checks if the segment intersects with another segment. + /// + public static bool Intersects(this Line left, Line right) => Line.Intersects(left, right); + + + /// + /// Determines whether two segments intersect. + /// + public static bool Intersects(this Line left, Line right, [NotNullWhen(returnValue: true)] out Vector2D? point) => Line.Intersects(left, right, out point); + /// /// Checks if two s are approximately equal. ///