Module: vec4

Summary

Methods

Detailed Description

Methods

add(a, b, out) → {Vec4}

Adds two vec4's
Parameters:
Name Type Description
a Vec4 the first operand
b Vec4 the second operand
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

clone(a) → {Vec4}

Creates a new vec4 initialized with values from an existing vector
Parameters:
Name Type Description
a Vec4 vector to clone
Returns:
a new 4D vector
Type
Vec4
Source:

copy(a, out) → {Vec4}

Copy the values from one vec4 to another
Parameters:
Name Type Description
a Vec4 the source vector
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

create() → {Vec4}

Creates a new, empty vec4
Returns:
a new 4D vector
Type
Vec4
Source:

dist()

Alias for vec4.distance
Source:

distance(a, b) → {Number}

Calculates the euclidian distance between two vec4's
Parameters:
Name Type Description
a Vec4 the first operand
b Vec4 the second operand
Returns:
distance between a and b
Type
Number
Source:

div()

Alias for vec4.divide
Source:

divide(a, b, out) → {Vec4}

Divides two vec4's
Parameters:
Name Type Description
a Vec4 the first operand
b Vec4 the second operand
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

dot(a, b) → {Number}

Calculates the dot product of two vec4's
Parameters:
Name Type Description
a Vec4 the first operand
b Vec4 the second operand
Returns:
dot product of a and b
Type
Number
Source:

forEach(a, stride, offset, count, fn, argopt) → {Array}

Perform some operation over an array of vec4s.
Parameters:
Name Type Attributes Description
a Array the array of vectors to iterate over
stride Number Number of elements between the start of each vec4. If 0 assumes tightly packed
offset Number Number of elements to skip at the beginning of the array
count Number Number of vec4s to iterate over. If 0 iterates over entire array
fn function Function to call for each vector in the array
arg Object <optional>
additional argument to pass to fn
Returns:
a
Type
Array
Source:

fromValues(x, y, z, w) → {Vec4}

Creates a new vec4 initialized with the given values
Parameters:
Name Type Description
x Number X component
y Number Y component
z Number Z component
w Number W component
Returns:
a new 4D vector
Type
Vec4
Source:

inverse(a, out) → {Vec4}

Returns the inverse of the components of a vec4
Parameters:
Name Type Description
a Vec4 vector to invert
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

len()

Alias for vec4.length
Source:

length(a) → {Number}

Calculates the length of a vec4
Parameters:
Name Type Description
a Vec4 vector to calculate length of
Returns:
length of a
Type
Number
Source:

lerp(a, b, t, out) → {Vec4}

Performs a linear interpolation between two vec4's
Parameters:
Name Type Description
a Vec4 the first operand
b Vec4 the second operand
t Number interpolation amount between the two inputs
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

max(a, b, out) → {Vec4}

Returns the maximum of two vec4's
Parameters:
Name Type Description
a Vec4 the first operand
b Vec4 the second operand
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

min(a, b, out) → {Vec4}

Returns the minimum of two vec4's
Parameters:
Name Type Description
a Vec4 the first operand
b Vec4 the second operand
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

mul()

Alias for vec4.multiply
Source:

multiply(a, b, out) → {Vec4}

Multiplies two vec4's
Parameters:
Name Type Description
a Vec4 the first operand
b Vec4 the second operand
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

negate(a, out) → {Vec4}

Negates the components of a vec4
Parameters:
Name Type Description
a Vec4 vector to negate
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

normalize(a, out) → {Vec4}

Normalize a vec4
Parameters:
Name Type Description
a Vec4 vector to normalize
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

random(scaleopt, out) → {Vec4}

Generates a random vector with the given scale
Parameters:
Name Type Attributes Description
scale Number <optional>
Length of the resulting vector. If ommitted, a unit vector will be returned
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

scale(a, b, out) → {Vec4}

Scales a vec4 by a scalar number
Parameters:
Name Type Description
a Vec4 the vector to scale
b Number amount to scale the vector by
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

scaleAndAdd(a, b, scale, out) → {Vec4}

Adds two vec4's after scaling the second operand by a scalar value
Parameters:
Name Type Description
a Vec4 the first operand
b Vec4 the second operand
scale Number the amount to scale b by before adding
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

set(x, y, z, w, out) → {Vec4}

Set the components of a vec4 to the given values
Parameters:
Name Type Description
x Number X component
y Number Y component
z Number Z component
w Number W component
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

sqrDist()

Alias for vec4.squaredDistance
Source:

sqrLen()

Alias for vec4.squaredLength
Source:

squaredDistance(a, b) → {Number}

Calculates the squared euclidian distance between two vec4's
Parameters:
Name Type Description
a Vec4 the first operand
b Vec4 the second operand
Returns:
squared distance between a and b
Type
Number
Source:

squaredLength(a) → {Number}

Calculates the squared length of a vec4
Parameters:
Name Type Description
a Vec4 vector to calculate squared length of
Returns:
squared length of a
Type
Number
Source:

str(vec) → {String}

Returns a string representation of a vector
Parameters:
Name Type Description
vec Vec4 vector to represent as a string
Returns:
string representation of the vector
Type
String
Source:

sub()

Alias for vec4.subtract
Source:

subtract(a, b, out) → {Vec4}

Subtracts vector b from vector a
Parameters:
Name Type Description
a Vec4 the first operand
b Vec4 the second operand
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

transformMat4(a, m, out) → {Vec4}

Transforms the vec4 with a mat4.
Parameters:
Name Type Description
a Vec4 the vector to transform
m Mat4 matrix to transform with
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source:

transformQuat(a, q, out) → {Vec4}

Transforms the vec4 with a quat
Parameters:
Name Type Description
a Vec4 the vector to transform
q Quat quaternion to transform with
out Vec4 the receiving vector
Returns:
out
Type
Vec4
Source: