Module: modeling/maths/vec3

Represents a three dimensional vector.

Source:
See:
  • vec3 for data structure information.

Methods

(static) abs(out, vector) → {vec3}

Calculates the absolute coordinates of the give vector.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector of reference

Source:
Returns:

out

Type
vec3

(static) add(out, a, b) → {vec3}

Adds the coordinates of two vectors (A+B).

Parameters:
Name Type Description
out vec3

receiving vector

a vec3

first operand

b vec3

second operand

Source:
Returns:

out

Type
vec3

(static) angle(a, b) → {Number}

Calculate the angle between two vectors.

Parameters:
Name Type Description
a vec3

first operand

b vec3

second operand

Source:
Returns:

angle (radians)

Type
Number

(static) clone(vector) → {vec3}

Create a clone of the given vector.

Parameters:
Name Type Description
vector vec3

vector to clone

Source:
Returns:

a new vector

Type
vec3

(static) copy(out, vector) → {vec3}

Create a copy of the given vector.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector to copy

Source:
Returns:

out

Type
vec3

(static) create() → {vec3}

Creates a new vector initialized to [0,0,0].

Source:
Returns:

a new vector

Type
vec3

(static) cross(out, a, b) → {vec3}

Computes the cross product of the given vectors (AxB).

Parameters:
Name Type Description
out vec3

receiving vector

a vec3

first operand

b vec3

second operand

Source:
Returns:

out

Type
vec3

(static) distance(a, b) → {Number}

Calculates the Euclidian distance between the given vectors.

Parameters:
Name Type Description
a vec3

first operand

b vec3

second operand

Source:
Returns:

distance

Type
Number

(static) divide(out, a, b) → {vec3}

Divides the coordinates of two vectors (A/B).

Parameters:
Name Type Description
out vec3

receiving vector

a vec3

dividend vector

b vec3

divisor vector

Source:
Returns:

out

Type
vec3

(static) dot(a, b) → {Number}

Calculates the dot product of two vectors.

Parameters:
Name Type Description
a vec3

first operand

b vec3

second operand

Source:
Returns:

dot product

Type
Number

(static) equals(a, b) → {Boolean}

Compare the given vectors for equality.

Parameters:
Name Type Description
a vec3

first operand

b vec3

second operand

Source:
Returns:

true if a and b are equal

Type
Boolean

(static) fromScalar(out, scalar) → {vec3}

Creates a vector from a single scalar value. All components of the resulting vector have the given value.

Parameters:
Name Type Description
out vec3

receiving vector

scalar Number
Source:
Returns:

out

Type
vec3

(static) fromValues(x, y, z) → {vec3}

Creates a new vector initialized with the given values.

Parameters:
Name Type Description
x Number

X component

y Number

Y component

z Number

Z component

Source:
Returns:

a new vector

Type
vec3

(static) fromVec2(out, vector, zopt) → {vec3}

Create a new vector by extending a 2D vector with a Z value.

Parameters:
Name Type Attributes Default Description
out vec3

receiving vector

vector Array

2D vector of values

z Number <optional>
0

Z value

Source:
Returns:

out

Type
vec3

(static) length(vector) → {Number}

Calculates the length of a vector.

Parameters:
Name Type Description
vector vec3

vector to calculate length of

Source:
Returns:

length

Type
Number

(static) lerp(out, a, b, t) → {vec3}

Performs a linear interpolation between two vectors.

Parameters:
Name Type Description
out vec3

receiving vector

a vec3

first operand

b vec3

second operand

t Number

interpolant (0.0 to 1.0) applied between the two inputs

Source:
Returns:

out

Type
vec3

(static) max(out, a, b) → {vec3}

Returns the maximum coordinates of the given vectors.

Parameters:
Name Type Description
out vec3

receiving vector

a vec3

first operand

b vec3

second operand

Source:
Returns:

out

Type
vec3

(static) min(out, a, b) → {vec3}

Returns the minimum coordinates of the given vectors.

Parameters:
Name Type Description
out vec3

receiving vector

a vec3

first operand

b vec3

second operand

Source:
Returns:

out

Type
vec3

(static) multiply(out, a, b) → {vec3}

Multiply the coordinates of the given vectors (A*B).

Parameters:
Name Type Description
out vec3

receiving vector

a vec3

first operand

b vec3

second operand

Source:
Returns:

out

Type
vec3

(static) negate(out, vector) → {vec3}

Negates the coordinates of the given vector.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector to negate

Source:
Returns:

out

Type
vec3

(static) normalize(out, vector) → {vec3}

Normalize the given vector.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector to normalize

Source:
Returns:

out

Type
vec3

(static) orthogonal(out, vector) → {vec3}

Create a new vector that is orthogonal to the given vector.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector of reference

Source:
Returns:

out

Type
vec3

(static) rotateX(out, vector, origin, radians) → {vec3}

Rotate the given vector around the given origin, X axis only.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector to rotate

origin vec3

origin of the rotation

radians Number

angle of rotation

Source:
Returns:

out

Type
vec3

(static) rotateY(out, vector, origin, radians) → {vec3}

Rotate the given vector around the given origin, Y axis only.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector to rotate

origin vec3

origin of the rotation

radians Number

angle of rotation

Source:
Returns:

out

Type
vec3

(static) rotateZ(out, vector, origin, radians) → {vec3}

Rotate the given vector around the given origin, Z axis only.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector to rotate

origin vec3

origin of the rotation

radians Number

angle of rotation in radians

Source:
Returns:

out

Type
vec3

(static) scale(out, vector, amount) → {vec3}

Scales the coordinates of the given vector by a scalar number.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector to scale

amount Number

amount to scale the vector by

Source:
Returns:

out

Type
vec3

(static) snap(out, vector, epsilon) → {vec3}

Snaps the coordinates of the given vector to the given epsilon.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector to snap

epsilon Number

epsilon of precision, less than 0

Source:
Returns:

out

Type
vec3

(static) squaredDistance(a, b) → {Number}

Calculates the squared distance between two vectors.

Parameters:
Name Type Description
a vec3

first operand

b vec3

second operand

Source:
Returns:

squared distance

Type
Number

(static) squaredLength(vector) → {Number}

Calculates the squared length of the given vector.

Parameters:
Name Type Description
vector vec3

vector to calculate squared length of

Source:
Returns:

squared length

Type
Number

(static) subtract(out, a, b) → {vec3}

Subtracts the coordinates of two vectors (A-B).

Parameters:
Name Type Description
out vec3

receiving vector

a vec3

minuend vector

b vec3

subtrahend vector

Source:
Returns:

out

Type
vec3

(static) toString(vec) → {String}

Convert the given vector to a representative string.

Parameters:
Name Type Description
vec vec3

vector of reference

Source:
Returns:

string representation

Type
String

(static) transform(out, vector, matrix) → {vec3}

Transforms the given vector using the given matrix.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector to transform

matrix mat4

transform matrix

Source:
Returns:

out

Type
vec3