Home Reference Source
import {Line3} from 'math-ds'
public class | source

Line3

A line.

Constructor Summary

Public Constructor
public

constructor(start: Vector3, end: Vector3)

Constructs a new line.

Member Summary

Public Members
public

The ending point.

public

The starting point.

Method Summary

Public Methods
public

at(d: Vector3, target: Vector3): Vector3

Adjusts this line to point in the given direction.

public

Clones this line.

public

closestPointToPoint(p: Vector3, clampToLine: Boolean, target: Vector3): Vector3

Returns the closest point on the line.

public

Copies the values of the given line.

public

delta(target: Vector3): Vector3

Calculates the delta vector of this line.

public

Checks if this line equals the given one.

public

Calculates the center of this line.

public

Calculates the length of this line.

public

Calculates the squared length of this line.

public

set(start: Vector3, end: Vector3): Line3

Sets the starting and ending point of this line.

Public Constructors

public constructor(start: Vector3, end: Vector3) source

Constructs a new line.

Params:

NameTypeAttributeDescription
start Vector3
  • optional

The starting point. If none is provided, a new vector will be created.

end Vector3
  • optional

The ending point. If none is provided, a new vector will be created.

Public Members

public end: Vector3 source

The ending point.

public start: Vector3 source

The starting point.

Public Methods

public at(d: Vector3, target: Vector3): Vector3 source

Adjusts this line to point in the given direction.

Params:

NameTypeAttributeDescription
d Vector3

The direction.

target Vector3
  • optional

A target vector. If none is provided, a new one will be created.

Return:

Vector3

The length.

public clone(): Line3 source

Clones this line.

Return:

Line3

The cloned line.

public closestPointToPoint(p: Vector3, clampToLine: Boolean, target: Vector3): Vector3 source

Returns the closest point on the line.

Params:

NameTypeAttributeDescription
p Vector3

A point.

clampToLine Boolean
  • optional
  • default: false

Whether the point should be clamped to the line.

target Vector3
  • optional

A target vector. If none is provided, a new one will be created.

Return:

Vector3

The parameter.

public copy(l: Line3): Line3 source

Copies the values of the given line.

Params:

NameTypeAttributeDescription
l Line3

A line.

Return:

Line3

This line.

public delta(target: Vector3): Vector3 source

Calculates the delta vector of this line.

Params:

NameTypeAttributeDescription
target Vector3
  • optional

A target vector. If none is provided, a new one will be created.

Return:

Vector3

The delta vector of this line.

public equals(l: Line3): Boolean source

Checks if this line equals the given one.

Params:

NameTypeAttributeDescription
l Line3

A line.

Return:

Boolean

Whether the lines are equal.

public getCenter(target: Vector3): Vector3 source

Calculates the center of this line.

Params:

NameTypeAttributeDescription
target Vector3
  • optional

A target vector. If none is provided, a new one will be created.

Return:

Vector3

The center of this line.

public length(): Vector3 source

Calculates the length of this line.

Return:

Vector3

The length.

public lengthSquared(): Vector3 source

Calculates the squared length of this line.

Return:

Vector3

The squared length.

public set(start: Vector3, end: Vector3): Line3 source

Sets the starting and ending point of this line.

Params:

NameTypeAttributeDescription
start Vector3

The starting point.

end Vector3

The ending point.

Return:

Line3

This line.