B.Math.Segment()

Represents a segment.

To create the object use B.Math.makeSegment().

PROPERTIES:

{B.Math.Vector3} start

Start of the segment.

{B.Math.Vector3} end

End of the segment.

METHODS:

clone()

Clones this segment to a new segment.

RETURNS:

copy(segment)

Copies a given segment into this segment.

PARAMETERS:

{B.Math.Segment} segment

RETURNS:

set(start, end)

Sets this segment from a start and a end points.

PARAMETERS:

RETURNS:

fromArray(array, offset)

Sets this segment from a part of array.

PARAMETERS:

{Array.<number>} array

{number} [offset] = 0

RETURNS:

{number}

new offset

toArray(array, offset)

Sets this segment to a part of array.

PARAMETERS:

{Array.<number>} array

{number} [offset] = 0

RETURNS:

{number}

new offset

translate(offset)

Translates this segment by a given offset.

PARAMETERS:

{B.Math.Vector3} offset

RETURNS:

transform(matrix)

Transforms this segment by a 4x4 matrix.

PARAMETERS:

{B.Math.Matrix4} matrix

RETURNS:

center(result)

Gets the center point of this segment.

PARAMETERS:

{B.Math.Vector3} [result]

omit if you want to return newly created vector

RETURNS:

delta(result)

Gets the vector from start to end.

PARAMETERS:

{B.Math.Vector3} [result]

omit if you want to return newly created vector

RETURNS:

length()

Gets the length of this segment.

RETURNS:

{number}

at(t, result)

Gets a point at this segment.

PARAMETERS:

{number} t

[0, 1]

{B.Math.Vector3} [result]

omit if you want to return newly created vector

RETURNS:

{B.Math.Vector3}

point

projectPoint(point, result)

Projects a point to this segment.

PARAMETERS:

{B.Math.Vector3} point

{B.Math.Vector3} [result]

omit if you want to return newly created vector

RETURNS:

{B.Math.Vector3}

projected point

trace(object, point)

Finds the point of intersection between this segment and an object.

PARAMETERS:

{B.Math.Plane | B.Math.Triangle | B.Math.AABox | B.Math.Sphere} object

{B.Math.Vector3} [point]

point of intersection.

RETURNS:

{number | null}

distance from start or null if no intersections.

THROWS:

{Error}

if the object argument has unsupported type

distanceTo(object)

Calculates the shortest distance between this segment and an object.

PARAMETERS:

{B.Math.Vector3} object

RETURNS:

{number}

distance

THROWS:

{Error}

if the object argument has unsupported type

equal(segment)

Checks for strict equality of this segment and another segment.

PARAMETERS:

{B.Math.Segment} segment

RETURNS:

{boolean}

PROPERTIES:

METHODS: