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
Link copied to clipboard
common
fun LineSegment(x0: Double, y0: Double, x1: Double, y1: Double)
LineSegment
Link copied to clipboard
common
fun LineSegment(start: Vector2, end: Vector2)

Functions

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

Finds the shortest distance to the LineSegment from given point.

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

Extends the length of the segment by given multiplier.

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

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

plus
Link copied to clipboard
common
open operator override fun plus(right: LineSegment): LineSegment
position
Link copied to clipboard
common
fun position(t: Double): Vector2

Calculates Vector2 position at given t value.

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

Rotates the LineSegment around a point on the segment.

split
Link copied to clipboard
common
fun split(t: Double): Array<LineSegment>

Splits line segment at given t value.

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

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

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

Properties

contour
Link copied to clipboard
common
open override val contour: ShapeContour

Returns ShapeContour representation of the LineSegment.

direction
Link copied to clipboard
common
val direction: Vector2

Direction of the line segment

end
Link copied to clipboard
common
val end: Vector2
normal
Link copied to clipboard
common
val normal: Vector2

The normal of the line segment, a unit vector.

segment
Link copied to clipboard
common
val segment: Segment

Returns Segment representation of the LineSegment.

shape
Link copied to clipboard
common
open override val shape: Shape

Returns Shape representation of the LineSegment.

start
Link copied to clipboard
common
val start: Vector2