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.

android
MutableBox

Populates outBox with the minimum bounding box containing the Segment.

android
ImmutableVec

Returns an ImmutableVec with the displacement from start to end.

android
MutableVec

Populates outVec with the displacement from start to end.

android
@FloatRange(from = 0.0) Float

The length of the Segment.

android
ImmutableVec

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

android
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.

android
ImmutableVec

Returns an ImmutableVec that lies halfway along the segment.

android
MutableVec

Populates outVec with the point halfway along the segment.

android
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.

android
Float
project(pointToProject: Vec)

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

android

Public properties

abstract Vec
android
abstract Vec
android

Public functions

computeBoundingBox

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

fun computeBoundingBox(outBox: MutableBox): MutableBox

Populates outBox with the minimum bounding box containing the Segment.

computeDisplacement

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

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

fun computeLength(): @FloatRange(from = 0.0) Float

The length of the Segment.

computeLerpPoint

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

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

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

fun computeMidpoint(outVec: MutableVec): MutableVec

Populates outVec with the point halfway along the segment.

isAlmostEqual

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

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

abstract val endVec

start

abstract val startVec