Line3

class Line3(val start: Vector3 = Vector3(), val end: Vector3 = Vector3())

An analytical line segment in 3D space represented by a start and end point.

The segment is mutable and not thread-safe; confine an instance (and any object graph holding it) to a single thread, exactly as in three.js.

The constructor stores the given vectors by reference (it does not copy them). Passing the same vector as both endpoints, or sharing a vector with another object, means later mutations are visible through every alias. Use set or clone when you need independent storage.

Constructors

Link copied to clipboard
constructor(start: Vector3 = Vector3(), end: Vector3 = Vector3())

Properties

Link copied to clipboard

End of the line segment.

Link copied to clipboard

Start of the line segment.

Functions

Link copied to clipboard
fun applyMatrix4(matrix: Matrix4): Line3

Applies a 4x4 transformation matrix matrix to this line segment.

Link copied to clipboard
fun at(t: Double, target: Vector3): Vector3

Writes a point at position t (in [0,1]) along the line segment into target.

Link copied to clipboard
fun clone(): Line3

Returns a new line segment with copied values from this instance.

Link copied to clipboard
fun closestPointToPoint(point: Vector3, clampToLine: Boolean, target: Vector3): Vector3

Writes the closest point on the line for a given point into target.

Link copied to clipboard

Returns a point parameter based on the closest point as projected on the line segment.

Link copied to clipboard
fun copy(line: Line3): Line3

Copies the values of the given line segment line to this instance.

Link copied to clipboard
fun delta(target: Vector3): Vector3

Writes the delta vector of the line segment's start and end point into target.

Link copied to clipboard

Returns the Euclidean distance between the line's start and end point.

Link copied to clipboard

Returns the squared Euclidean distance between the line's start and end point.

Link copied to clipboard
fun distanceSqToLine3(line: Line3, c1: Vector3 = Vector3(), c2: Vector3 = Vector3()): Double

Returns the closest squared distance between this line segment and the given one line. When provided, writes the closest point on this segment into c1 and the closest point on line into c2.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Structural equality: true when other is a Line3 with equal start and end (each compared via Vector3.equals, so NaN != NaN).

Link copied to clipboard
fun getCenter(target: Vector3): Vector3

Writes the center of the line segment into target.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun set(start: Vector3, end: Vector3): Line3

Sets the start and end values by copying the given vectors.

Link copied to clipboard
open override fun toString(): String