LineSegment(from, to)

Class representing a 3D line segment.

new LineSegment(from, to)

Constructs a new line segment with the given values.

Parameters:
Name Type Description
from Vector3

The start point of the line segment.

to Vector3

The end point of the line segment.

Author:

Members

from :Vector3

The start point of the line segment.

to :Vector3

The end point of the line segment.

Methods

at(t, result) → {Vector3}

Computes a position on the line segment according to the given t value and stores the result in the given 3D vector. The t value has usually a range of [0, 1] where 0 means start position and 1 the end position.

Parameters:
Name Type Description
t Number

A scalar value representing a position on the line segment.

result Vector3

The result vector.

Returns:
Vector3 -

The result vector.

clone() → {LineSegment}

Creates a new line segment and copies all values from this line segment.

Returns:
LineSegment -

A new line segment.

closestPointToPoint(point, clampToLine, result) → {Vector3}

Computes the closest point on an infinite line defined by the line segment. It's possible to clamp the closest point so it does not exceed the start and end position of the line segment.

Parameters:
Name Type Description
point Vector3

A point in 3D space.

clampToLine Boolean

Indicates if the results should be clamped.

result Vector3

The result vector.

Returns:
Vector3 -

The closest point.

closestPointToPointParameter(point, clampToLine) → {Number}

Computes a scalar value which represents the closest point on an infinite line defined by the line segment. It's possible to clamp this value so it does not exceed the start and end position of the line segment.

Parameters:
Name Type Default Description
point Vector3

A point in 3D space.

clampToLine Boolean true

Indicates if the results should be clamped.

Returns:
Number -

A scalar representing the closest point.

copy(lineSegment) → {LineSegment}

Copies all values from the given line segment to this line segment.

Parameters:
Name Type Description
lineSegment LineSegment

The line segment to copy.

Returns:
LineSegment -

A reference to this line segment.

delta(result) → {Vector3}

Computes the difference vector between the end and start point of this line segment and stores the result in the given vector.

Parameters:
Name Type Description
result Vector3

The result vector.

Returns:
Vector3 -

The result vector.

equals(lineSegment) → {Boolean}

Returns true if the given line segment is deep equal with this line segment.

Parameters:
Name Type Description
lineSegment LineSegment

The line segment to test.

Returns:
Boolean -

The result of the equality test.

set(from, to) → {LineSegment}

Sets the given values to this line segment.

Parameters:
Name Type Description
from Vector3

The start point of the line segment.

to Vector3

The end point of the line segment.

Returns:
LineSegment -

A reference to this line segment.