Hide menu
Loading...
Searching...
No Matches
Direction

Defines direction in 3D space.

Constructors

new Direction()

new Direction(x?, y?, z?): Direction

Parameters

x?

number

X coordinate of 3D direction.

y?

number

Y coordinate of 3D direction.

z?

number

Z coordinate of 3D direction.

Returns

Direction

Accessors

x

Get Signature

get x(): number

Returns x coordinate of 3D direction.

Returns

number

Set Signature

set x(x): void

Sets x coordinate of 3D direction.

Parameters

x

number

X coordinate.

Returns

void


y

Get Signature

get y(): number

Returns y coordinate of 3D direction.

Returns

number

Set Signature

set y(y): void

Sets y coordinate of 3D direction.

Parameters

y

number

Y coordinate.

Returns

void


z

Get Signature

get z(): number

Returns z coordinate of 3D direction.

Returns

number

Set Signature

set z(z): void

Sets z coordinate of 3D direction.

Parameters

z

number

Z coordinate.

Returns

void

Methods

add()

add(other): this

Adds other direction coordinates to this direction coordinates.

Parameters

other

Direction

Other direction.

Returns

this


added()

added(other): Direction

Returns new Direction object with coordinates received by performing a add() operation to this object.

Parameters

other

Direction

Other direction.

Returns

Direction


angle()

angle(other): number

Returns angle between this and other directions.

Parameters

other

Direction

Other direction.

Returns

number


clone()

clone(): Direction

Creates new Direction direction with coordinates same as this.

Returns

Direction


copy()

copy(other): this

Copies the coordinates of the other direction to this.

Parameters

other

Direction

Copied object.

Returns

this


cross()

cross(other): this

Sets coordinates of this point as cross product of this and other directions.

Parameters

other

Direction

Other direction.

Returns

this


crossCross()

crossCross(coord1, coord2): this

Computes this = this.cross(coord1.cross(coord2)).

Parameters

coord1

Direction

First direction.

coord2

Direction

Second direction.

Returns

this


crossCrossed()

crossCrossed(coord1, coord2): Direction

Returns new Direction object with coordinates received by performing a crossCross() operation to this object.

Parameters

coord1

Direction

First direction.

coord2

Direction

Second direction.

Returns

Direction


crossed()

crossed(other): Direction

Returns new Direction object with coordinates received by performing a cross() operation to this object.

Parameters

other

Direction

Other direction.

Returns

Direction


dot()

dot(other): number

Returns dot product of this and other directions.

Parameters

other

Direction

Other direction.

Returns

number


isEqual()

isEqual(other, tolerance?): boolean

Returns true if other direction are equal to this direction within provided tolerance (1e-7 by default). Returns false otherwise.

Parameters

other

Direction

Other 3D direction.

tolerance?

number

Angular comparison tolerance;

Returns

boolean


isNormal()

isNormal(other, tolerance?): boolean

Returns true if other direction is perpendicular to this within provided tolerance (1e-7 by default).

Parameters

other

Direction

Other direction.

tolerance?

number

Returns

boolean


isOpposite()

isOpposite(other, tolerance?): boolean

Returns true if other direction is opposite to this within provided tolerance (1e-7 by default).

Parameters

other

Direction

Other direction.

tolerance?

number

Returns

boolean


isParallel()

isParallel(other, tolerance?): boolean

Returns true if other direction is parallel to this within provided tolerance (1e-7 by default).

Parameters

other

Direction

Other direction.

tolerance?

number

Returns

boolean


mirror()

Call Signature

mirror(direction): this

Mirrors this 3D direction relative to other direction.

Parameters

direction

Direction

Other direction.

Returns

this

Call Signature

mirror(axis): this

Mirrors this 3D point relative to axis.

Parameters

axis

Axis1d

Axis.

Returns

this

Call Signature

mirror(axis): this

Mirrors this 3D point relative to axis.

Parameters

axis

Axis3d

Axis.

Returns

this


mirrored()

Call Signature

mirrored(direction): Direction

Returns new Direction object with coordinates received by performing a mirror() operation to this object.

Parameters

direction

Direction

Direction.

Returns

Direction

Call Signature

mirrored(axis): Direction

Returns new Direction object with coordinates received by performing a mirror() operation to this object.

Parameters

axis

Axis1d

Axis.

Returns

Direction

Call Signature

mirrored(axis): Direction

Returns new Direction object with coordinates received by performing a mirror() operation to this object.

Parameters

axis

Axis3d

Axis.

Returns

Direction


multiplied()

Call Signature

multiplied(other): Direction

Returns new Direction object with coordinates received by performing a multiply() operation to this object.

Parameters

other

Direction

Other direction.

Returns

Direction

Call Signature

multiplied(matrix): Direction

Returns new Direction object with coordinates received by performing a multiply() operation to this object.

Parameters

matrix

Matrix3d

3D matrix.

Returns

Direction


multiply()

Call Signature

multiply(other): this

Multiplies this direction coordinates with other direction coordinates.

Parameters

other

Direction

Other direction.

Returns

this

Call Signature

multiply(matrix): this

Multiplies this direction coordinates with matrix.

Parameters

matrix

Matrix3d

3D matrix.

Returns

this


reverse()

reverse(): this

Reverses coordinates of this direction.

Returns

this


reversed()

reversed(): Direction

Returns new Direction object with coordinates received by performing a reverse() operation to this object.

Returns

Direction


rotate()

rotate(axis, angle): this

Rotates this 3D direction around axis on angle.

Parameters

axis

Axis1d

Rotation axis.

angle

number

Rotation angle.

Returns

this


rotated()

rotated(axis, angle): Direction

Returns new Direction object with coordinates received by performing a rotate() operation to this object.

Parameters

axis

Axis1d

Rotation axis.

angle

number

Rotation angle.

Returns

Direction


setCoord()

setCoord(x?, y?, z?): this

Sets x and y coordinates of this object and normalizes these coordinates.

Parameters

x?

number

X coordinate of 3D direction.

y?

number

Y coordinate of 3D direction.

z?

number

Returns

this


setX()

setX(x): this

Sets x coordinate of 3D direction.

Parameters

x

number

X coordinate.

Returns

this


setY()

setY(y): this

Sets y coordinate of 3D direction.

Parameters

y

number

Y coordinate.

Returns

this


setZ()

setZ(z): this

Sets z coordinate of 3D direction.

Parameters

z

number

Z coordinate.

Returns

this


subtract()

subtract(other): this

Subtracts other direction coordinates from this direction coordinates.

Parameters

other

Direction

Other direction.

Returns

this


subtracted()

subtracted(other): Direction

Returns new Direction object with coordinates received by performing a subtract() operation to this object.

Parameters

other

Direction

Other direction.

Returns

Direction


toJSON()

toJSON(): BaseXYZ

Returns JSON representation of this direction.

Returns

BaseXYZ


toString()

toString(precision): string

Returns string representation of this direction with provided precision (3 by default).

Parameters

precision

number = 3

Precision.

Returns

string


transform()

transform(transformation): this

Transforms coordinates of this direction according to transformation.

Parameters

transformation

Transformation

Transformation.

Returns

this


transformed()

transformed(transformation): Direction

Returns new Direction object with coordinates received by performing a transform() operation to this object.

Parameters

transformation

Transformation

Transformation.

Returns

Direction


fromVector()

static fromVector(vector): Direction

Creates new Direction object from Vector.

Parameters

vector

Vector

3D vector.

Returns

Direction


fromXYZ()

static fromXYZ(xyz): Direction

Creates new Direction object from object implementing BaseXYZ interface.

Parameters

xyz

BaseXYZ

Object implementing BaseXYZ interface.

Returns

Direction


xDir()

static xDir(): Direction

Returns Direction with (1, 0, 0) coordinates.

Returns

Direction


yDir()

static yDir(): Direction

Returns Direction with (0, 1, 0) coordinates.

Returns

Direction


zDir()

static zDir(): Direction

Returns Direction with (0, 0, 1) coordinates.

Returns

Direction