LineSegment

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

Link copied to clipboard
constructor(start: Vector2, end: Vector2)

Functions

Link copied to clipboard
fun distance(query: Vector2): Double

Finds the shortest distance to the LineSegment from given point.

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

Extends the length of the segment by the given length.

Link copied to clipboard
fun extendTo(targetLength: Double, anchorT: Double = 0.5): LineSegment

Extends the length of the segment to the given targetLength.

Link copied to clipboard
open operator override fun minus(right: LineSegment): LineSegment
Link copied to clipboard
fun nearest(query: Vector2): Vector2

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

Link copied to clipboard
open operator override fun plus(right: LineSegment): LineSegment
Link copied to clipboard

Calculates the point at a given distance along this LineSegment.

Link copied to clipboard

Calculates Vector2 position at given t value.

Link copied to clipboard
fun rotateBy(degrees: Double, t: Double = 0.5): LineSegment

Rotates the LineSegment around a point on the segment.

Link copied to clipboard
Link copied to clipboard

Splits line segment at given t value.

Link copied to clipboard
fun sub(t0: Double, t1: Double): LineSegment

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

Link copied to clipboard
open operator override fun times(scale: Double): LineSegment

Properties

Link copied to clipboard
open override val contour: ShapeContour

Returns ShapeContour representation of the LineSegment.

Link copied to clipboard

Direction of the line segment

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The normal of the line segment, a unit vector.

Link copied to clipboard

Returns Segment2D representation of the LineSegment.

Link copied to clipboard
open override val shape: Shape

Returns Shape representation of the LineSegment.

Link copied to clipboard
Link copied to clipboard