modeling/maths/vec3

Represents a three dimensional vector.

Source:
See:
  • vec3 for data structure information.

Methods

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

Source:

Calculates the absolute coordinates of the give vector.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector of reference

Returns:

out

Type
vec3

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

Source:

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

Parameters:
Name Type Description
out vec3

receiving vector

a vec3

first operand

b vec3

second operand

Returns:

out

Type
vec3

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

Source:

Calculate the angle between two vectors.

Parameters:
Name Type Description
a vec3

first operand

b vec3

second operand

Returns:

angle (radians)

Type
Number

(static) clone(vector) → {vec3}

Source:

Create a clone of the given vector.

Parameters:
Name Type Description
vector vec3

vector to clone

Returns:

a new vector

Type
vec3

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

Source:

Create a copy of the given vector.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector to copy

Returns:

out

Type
vec3

(static) create() → {vec3}

Source:

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

Returns:

a new vector

Type
vec3

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

Source:

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

Returns:

out

Type
vec3

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

Source:

Calculates the Euclidian distance between the given vectors.

Parameters:
Name Type Description
a vec3

first operand

b vec3

second operand

Returns:

distance

Type
Number

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

Source:

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

Parameters:
Name Type Description
out vec3

receiving vector

a vec3

dividend vector

b vec3

divisor vector

Returns:

out

Type
vec3

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

Source:

Calculates the dot product of two vectors.

Parameters:
Name Type Description
a vec3

first operand

b vec3

second operand

Returns:

dot product

Type
Number

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

Source:

Compare the given vectors for equality.

Parameters:
Name Type Description
a vec3

first operand

b vec3

second operand

Returns:

true if a and b are equal

Type
Boolean

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

Source:

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
Returns:

out

Type
vec3

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

Source:

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

Returns:

a new vector

Type
vec3

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

Source:

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

Returns:

out

Type
vec3

(static) length(vector) → {Number}

Source:

Calculates the length of a vector.

Parameters:
Name Type Description
vector vec3

vector to calculate length of

Returns:

length

Type
Number

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

Source:

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

Returns:

out

Type
vec3

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

Source:

Returns the maximum coordinates of the given vectors.

Parameters:
Name Type Description
out vec3

receiving vector

a vec3

first operand

b vec3

second operand

Returns:

out

Type
vec3

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

Source:

Returns the minimum coordinates of the given vectors.

Parameters:
Name Type Description
out vec3

receiving vector

a vec3

first operand

b vec3

second operand

Returns:

out

Type
vec3

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

Source:

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

Returns:

out

Type
vec3

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

Source:

Negates the coordinates of the given vector.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector to negate

Returns:

out

Type
vec3

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

Source:

Normalize the given vector.

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector to normalize

Returns:

out

Type
vec3

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

Source:

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

Parameters:
Name Type Description
out vec3

receiving vector

vector vec3

vector of reference

Returns:

out

Type
vec3

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

Source:

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

Returns:

out

Type
vec3

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

Source:

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

Returns:

out

Type
vec3

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

Source:

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

Returns:

out

Type
vec3

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

Source:

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

Returns:

out

Type
vec3

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

Source:

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

Returns:

out

Type
vec3

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

Source:

Calculates the squared distance between two vectors.

Parameters:
Name Type Description
a vec3

first operand

b vec3

second operand

Returns:

squared distance

Type
Number

(static) squaredLength(vector) → {Number}

Source:

Calculates the squared length of the given vector.

Parameters:
Name Type Description
vector vec3

vector to calculate squared length of

Returns:

squared length

Type
Number

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

Source:

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

Parameters:
Name Type Description
out vec3

receiving vector

a vec3

minuend vector

b vec3

subtrahend vector

Returns:

out

Type
vec3

(static) toString(vec) → {String}

Source:

Convert the given vector to a representative string.

Parameters:
Name Type Description
vec vec3

vector of reference

Returns:

string representation

Type
String

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

Source:

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

Returns:

out

Type
vec3