abstract class Segment

Known direct subclasses
ImmutableSegment

Represents a directed line segment between two points.

MutableSegment

Represents a mutable directed line segment between two points.


Represents a directed line segment between two points.

Summary

Public functions

ImmutableBox

Returns the minimum bounding box containing the Segment.

MutableBox

Populates outBox with the minimum bounding box containing the Segment.

ImmutableVec

Returns an ImmutableVec with the displacement from start to end.

MutableVec

Populates outVec with the displacement from start to end.

@FloatRange(from = 0.0) Float

The length of the Segment.

ImmutableVec

Returns the point on the segment at the given ratio of the segment's length, measured from the start point.

MutableVec
computeLerpPoint(ratio: Float, outVec: MutableVec)

Fills outVec with the point on the segment at the given ratio of the segment's length, measured from the start point.

ImmutableVec

Returns an ImmutableVec that lies halfway along the segment.

MutableVec

Populates outVec with the point halfway along the segment.

Boolean
isAlmostEqual(other: Segment, tolerance: @FloatRange(from = 0.0) Float)

Compares this Segment with other, and returns true if both start points are considered almost equal with the given tolerance, and likewise for both end points.

Float
project(pointToProject: Vec)

Returns the multiple of the segment's length at which the infinite extrapolation of this segment is closest to pointToProject.

Public properties

abstract Vec
abstract Vec

Public functions

computeBoundingBox

Added in 1.0.0-alpha02
fun computeBoundingBox(): ImmutableBox

Returns the minimum bounding box containing the Segment.

For performance-sensitive code, prefer to use computeBoundingBox with a pre-allocated instance of MutableBox.

computeBoundingBox

Added in 1.0.0-alpha02
fun computeBoundingBox(outBox: MutableBox): MutableBox

Populates outBox with the minimum bounding box containing the Segment.

computeDisplacement

Added in 1.0.0-alpha02
fun computeDisplacement(): ImmutableVec

Returns an ImmutableVec with the displacement from start to end. This is equivalent to subtract(end, start, output).

For performance-sensitive code, prefer to use computeDisplacement with a pre-allocated instance of MutableVec.

computeDisplacement

Added in 1.0.0-alpha02
fun computeDisplacement(outVec: MutableVec): MutableVec

Populates outVec with the displacement from start to end. This is equivalent to subtract(end, start, output). Returns outVec.

computeLength

Added in 1.0.0-alpha02
fun computeLength(): @FloatRange(from = 0.0) Float

The length of the Segment.

computeLerpPoint

Added in 1.0.0-alpha02
fun computeLerpPoint(ratio: Float): ImmutableVec

Returns the point on the segment at the given ratio of the segment's length, measured from the start point. You may also think of this as linearly interpolating from the start of the segment to the end. Values outside the interval 0, 1 will be extrapolated along the infinite line passing through this segment. This is the inverse of project.

For performance-sensitive code, prefer to use computeLerpPoint with a pre-allocated instance of MutableVec.

computeLerpPoint

Added in 1.0.0-alpha02
fun computeLerpPoint(ratio: Float, outVec: MutableVec): MutableVec

Fills outVec with the point on the segment at the given ratio of the segment's length, measured from the start point. You may also think of this as linearly interpolating from the start of the segment to the end. Values outside the interval 0, 1 will be extrapolated along the infinite line passing through this segment. This is the inverse of project.

computeMidpoint

Added in 1.0.0-alpha02
fun computeMidpoint(): ImmutableVec

Returns an ImmutableVec that lies halfway along the segment.

For performance-sensitive code, prefer to use computeMidpoint with a pre-allocated instance of MutableVec.

computeMidpoint

Added in 1.0.0-alpha02
fun computeMidpoint(outVec: MutableVec): MutableVec

Populates outVec with the point halfway along the segment.

isAlmostEqual

Added in 1.0.0-alpha02
fun isAlmostEqual(other: Segment, tolerance: @FloatRange(from = 0.0) Float): Boolean

Compares this Segment with other, and returns true if both start points are considered almost equal with the given tolerance, and likewise for both end points.

project

Added in 1.0.0-alpha02
fun project(pointToProject: Vec): Float

Returns the multiple of the segment's length at which the infinite extrapolation of this segment is closest to pointToProject. This is the inverse of computeLerpPoint. If the computeLength of this segment is zero, then the projection is undefined and this will throw an error. Note that the computeLength may be zero even if start and end are not equal, if they are sufficiently close that floating-point underflow occurs.

Public properties

end

Added in 1.0.0-alpha02
abstract val endVec

start

Added in 1.0.0-alpha02
abstract val startVec