# LineSegment

data class LineSegment(start: Vector2, end: Vector2) : LinearType<LineSegment> , ShapeProvider, ShapeContourProvider

A strictly linear 2D segment.

Think of LineSegment as a more limited representation of the Segment, . While both LineSegment and Segment 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

LineSegment
common
fun LineSegment(x0: Double, y0: Double, x1: Double, y1: Double)
LineSegment
common
fun LineSegment(start: Vector2, end: Vector2)

## Functions

distance
common
fun distance(query: Vector2): Double

Finds the shortest distance to the LineSegment from given point.

div
common
open operator override fun div(scale: Double): LineSegment
extend
common
fun extend(times: Double): LineSegment

Extends the length of the segment by given multiplier.

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

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

plus
common
open operator override fun plus(right: LineSegment): LineSegment
pointAtLength
common
fun pointAtLength(length: Double): Vector2

Calculates the point at a given distance along this LineSegment.

position
common
fun position(t: Double): Vector2

Calculates Vector2 position at given t value.

rotate
common
fun rotate(degrees: Double, t: Double = 0.5): LineSegment

Rotates the LineSegment around a point on the segment.

side
common
fun side(v: Vector2): Double
split
common
fun split(t: Double): Array<LineSegment>

Splits line segment at given t value.

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

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

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

## Properties

contour
common
open override val contour: ShapeContour

Returns ShapeContour representation of the LineSegment.

direction
common
val direction: Vector2

Direction of the line segment

end
common
val end: Vector2
length
common
val length: Double
normal
common
val normal: Vector2

The normal of the line segment, a unit vector.

segment
common
val segment: Segment

Returns Segment representation of the LineSegment.

shape