Methods
add(that) → {Vec3}
Adds the vector with the provided vector argument, returning a new Vec3
object representing the sum.
Parameters:
Name | Type | Description |
---|---|---|
that |
Vec3 | Vec4 | Array | The vector to add. |
Returns:
The sum of the two vectors.
- Type
- Vec3
cross(that) → {number}
Calculates and returns the cross product of the vector and the provided
vector argument.
Parameters:
Name | Type | Description |
---|---|---|
that |
Vec3 | Vec4 | Array | The other vector argument. |
Returns:
The 2D cross product.
- Type
- number
divScalar(that) → {Vec3}
Divides the vector with the provided scalar argument, returning a new Vec3
object representing the scaled vector.
Parameters:
Name | Type | Description |
---|---|---|
that |
number | The scalar to divide the vector by. |
Returns:
The scaled vector.
- Type
- Vec3
dot(that) → {number}
Calculates and returns the dot product of the vector and the provided
vector argument.
Parameters:
Name | Type | Description |
---|---|---|
that |
Vec3 | Vec4 | Array | The other vector argument. |
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 |
Vec3 | Vec4 | Array | The vector to test equality with. |
epsilon |
number | The epsilon value. Optional. |
Returns:
Whether or not the vector components match.
- Type
- boolean
length(length) → {number|Vec3}
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
Vec3 scaled to the provided length.
Parameters:
Name | Type | Description |
---|---|---|
length |
number | The length to scale the vector to. Optional. |
Returns:
Either the length, or new scaled vector.
- Type
- number | Vec3
lengthSquared() → {number}
Returns the squared length of the vector.
Returns:
The squared length of the vector.
- Type
- number
multScalar(that) → {Vec3}
Multiplies the vector with the provided scalar argument, returning a new Vec3
object representing the scaled vector.
Parameters:
Name | Type | Description |
---|---|---|
that |
number | The scalar to multiply the vector by. |
Returns:
The scaled vector.
- Type
- Vec3
negate() → {Vec3}
Returns a new Vec3 with each component negated.
Returns:
The negated vector.
- Type
- Vec3
normalize() → {Vec3}
Returns a new Vec3 of unit length.
Returns:
The vector of unit length.
- Type
- Vec3
projectOntoPlane(normal) → {number}
Given a plane normal, returns the projection of the vector onto the plane.
Parameters:
Name | Type | Description |
---|---|---|
normal |
Vec3 | Vec4 | Array | The plane normal. |
Returns:
The unsigned angle in radians.
- Type
- number
sub(that) → {Vec3}
Subtracts the provided vector argument from the vector, returning a new
Vec3 object representing the difference.
Parameters:
Name | Type | Description |
---|---|---|
that |
Vec3 | Vec4 | Array | The vector to subtract. |
Returns:
The difference of the two vectors.
- Type
- Vec3
toArray() → {Array}
Returns an array representation of the vector.
Returns:
The vector as an array.
- Type
- Array
toString() → {String}
Returns a string representation of the vector.
Returns:
The string representation of the vector.
- Type
- String
unsignedAngle(that, normal) → {number}
Returns the unsigned angle between this angle and the argument, projected
onto a plane, in radians.
Parameters:
Name | Type | Description |
---|---|---|
that |
Vec3 | Vec4 | Array | The vector to measure the angle from. |
normal |
Vec3 | Vec4 | Array | The reference vector to measure the direction of the angle. If not provided will use a.cross( b ). (Optional) |
Returns:
The unsigned angle in radians.
- Type
- number
(static) random() → {Vec3}
Returns a random Vec3 of unit length.
Returns:
A random vector of unit length.
- Type
- Vec3