# LineSegment

@Serializable
data class LineSegment(val start: Vector2, val end: Vector2) : LinearType<LineSegment> , ShapeProvider, ShapeContourProvider(source)

A strictly linear 2D segment.

Think of LineSegment as a more limited representation of the Segment2D, . While both LineSegment and Segment2D are capable of describing straight lines, LineSegment is only capable of dealing with straight lines you'd generally only use LineSegment if you strictly want to work with problems in the linear segment domain.

LineSegments are easy to extend in length thanks to their simple two-point construction.

#### Parameters

start

Start of the line segment.

end

End of the line segment.

## Constructors

constructor(start: Vector2, end: Vector2)

## Functions

fun distance(query: Vector2): Double

Finds the shortest distance to the LineSegment from given point.

open operator override fun div(scale: Double): LineSegment
fun extendBy(length: Double, anchorT: Double = 0.5): LineSegment

Extends the length of the segment by the given length.

fun extendTo(targetLength: Double, anchorT: Double = 0.5): LineSegment

Extends the length of the segment to the given targetLength.

open operator override fun minus(right: LineSegment): LineSegment
fun nearest(query: Vector2): Vector2

Finds point on the LineSegment that is nearest to the given point.

open operator override fun plus(right: LineSegment): LineSegment

Calculates the point at a given distance along this LineSegment.

Calculates Vector2 position at given t value.

fun rotateBy(degrees: Double, t: Double = 0.5): LineSegment

Rotates the LineSegment around a point on the segment.

Splits line segment at given t value.

fun sub(t0: Double, t1: Double): LineSegment

Samples a new LineSegment from the current LineSegment starting at t0 and ending at t1.

open operator override fun times(scale: Double): LineSegment

## Properties

open override val contour: ShapeContour

Returns ShapeContour representation of the LineSegment.

Direction of the line segment

The normal of the line segment, a unit vector.