Vec4

Vec4

A four component vector.

Constructor

new Vec4()

Instantiates a Vec4 object.
Source:

Methods

add(that) → {Vec4}

Adds the vector with the provided vector argument, returning a new Vec4 object representing the sum.
Parameters:
Name Type Description
that Vec4 | Array The vector to add.
Source:
Returns:
The sum of the two vectors.
Type
Vec4

divScalar(that) → {Vec4}

Divides the vector with the provided scalar argument, returning a new Vec4 object representing the scaled vector.
Parameters:
Name Type Description
that number The scalar to divide the vector by.
Source:
Returns:
The scaled vector.
Type
Vec4

dot(that) → {number}

Calculates and returns the dot product of the vector and the provided vector argument.
Parameters:
Name Type Description
that Vec4 | Array The other vector argument.
Source:
Returns:
The dot product.
Type
number

equals(that, epsilon) → {boolean}

Returns true if the vector components match those of a provided vector. An optional epsilon value may be provided.
Parameters:
Name Type Description
that Vec4 | Array The vector to test equality with.
epsilon number The epsilon value. Optional.
Source:
Returns:
Whether or not the vector components match.
Type
boolean

length(length) → {number|Vec4}

If no argument is provided, this function returns the scalar length of the vector. If an argument is provided, this method will return a new Vec4 scaled to the provided length.
Parameters:
Name Type Description
length number The length to scale the vector to. Optional.
Source:
Returns:
Either the length, or new scaled vector.
Type
number | Vec4

lengthSquared() → {number}

Returns the squared length of the vector.
Source:
Returns:
The squared length of the vector.
Type
number

multScalar(that) → {Vec4}

Multiplies the vector with the provided scalar argument, returning a new Vec4 object representing the scaled vector.
Parameters:
Name Type Description
that number The scalar to multiply the vector by.
Source:
Returns:
The scaled vector.
Type
Vec4

negate() → {Vec4}

Returns a new Vec4 with each component negated.
Source:
Returns:
The negated vector.
Type
Vec4

normalize() → {Vec4}

Returns a new Vec4 of unit length.
Source:
Returns:
The vector of unit length.
Type
Vec4

sub(that) → {Vec4}

Subtracts the provided vector argument from the vector, returning a new Vec4 object representing the difference.
Parameters:
Name Type Description
that Vec4 | Array The vector to subtract.
Source:
Returns:
The difference of the two vectors.
Type
Vec4

toArray() → {Array}

Returns an array representation of the vector.
Source:
Returns:
The vector as an array.
Type
Array

toString() → {String}

Returns a string representation of the vector.
Source:
Returns:
The string representation of the vector.
Type
String

(static) random() → {Vec4}

Returns a random Vec4 of unit length.
Source:
Returns:
A random vector of unit length.
Type
Vec4