new Vector4(x, y, z, w)
Class that represent a 4 dimensional vector.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | X coordinate. |
y |
number | Y coordinate. |
z |
number | Z coordinate. |
w |
number | W coordinate. |
Methods
add(v) → {ALMath.Vector4}
Function to add vector v.
Parameters:
Name | Type | Description |
---|---|---|
v |
ALMath.Vector4 | vector to add. |
Returns:
- A new vector which is the sum between this and v.
- Type
- ALMath.Vector4
addScalar(n) → {ALMath.Vector4}
Function to add scalar n.
Parameters:
Name | Type | Description |
---|---|---|
n |
number | Scalar to add. |
Returns:
- A new vector which is the sum between each component of this and scalar n.
- Type
- ALMath.Vector4
ceil() → {ALMath.Vector4}
Function to ceil vector.
Returns:
- A new vector ceiled.
- Type
- ALMath.Vector4
clamp(min, max) → {ALMath.Vector4}
Function to clamp between min and max.
Parameters:
Name | Type | Description |
---|---|---|
min |
number | Min value. |
max |
number | Max value. |
Returns:
- A new vector clamped between min and max.
- Type
- ALMath.Vector4
clone() → {ALMath.Vector4}
Function to clone vectors.
Returns:
- A copy of this.
- Type
- ALMath.Vector4
distanceTo(v) → {number}
Function to compute distance between vectors.
Parameters:
Name | Type | Description |
---|---|---|
v |
ALMath.Vector4 | Vector to compute the distance. |
Returns:
- Distance between this and v.
- Type
- number
divide(v) → {ALMath.Vector4}
Function to divide by vector v.
Parameters:
Name | Type | Description |
---|---|---|
v |
ALMath.Vector4 | Vector to divide. |
Throws:
Division by zero.
Returns:
- A new vector which is the divison between this and v.
- Type
- ALMath.Vector4
divideByScalar(n) → {ALMath.Vector4}
Function to divide by scalar n.
Parameters:
Name | Type | Description |
---|---|---|
n |
number | Scalar to divide. |
Throws:
Division by zero.
Returns:
- A new vector which is the division between each component of this and scalar n.
- Type
- ALMath.Vector4
dot(v) → {number}
Function to compute dot product.
Parameters:
Name | Type | Description |
---|---|---|
v |
ALMath.Vector4 | Vector to do the dot product. |
Returns:
- Dot product between this and v.
- Type
- number
equals(v) → {boolean}
Function to compare vectors.
Parameters:
Name | Type | Description |
---|---|---|
v |
ALMath.Vector4 | Vector to compare. |
Returns:
- true if this and v are equals, false otherwise.
- Type
- boolean
floor() → {ALMath.Vector4}
Function to floor vector.
Returns:
- A new vector floored.
- Type
- ALMath.Vector4
getForGL() → {Float32Array}
Function to get the vector in format that WebGL understands.
Returns:
- A Float32Array with x, y, z and w.
- Type
- Float32Array
length() → {number}
Function to compute length of the vector.
Returns:
- Vector length.
- Type
- number
multiply(v) → {ALMath.Vector4}
Function to multipy by vector v.
Parameters:
Name | Type | Description |
---|---|---|
v |
ALMath.Vector4 | Vector to multiply. |
Returns:
- A new vector which is the multiplication between this and v.
- Type
- ALMath.Vector4
multiplyByScalar(n) → {ALMath.Vector4}
Function to multiply by scalar n.
Parameters:
Name | Type | Description |
---|---|---|
n |
number | Scalar to multiply. |
Returns:
- A new vector which is the multiplication between each component of this and scalar n.
- Type
- ALMath.Vector4
negate() → {ALMath.Vector4}
Function to negate vector.
Returns:
- A new vector with each component negate.
- Type
- ALMath.Vector4
normalize() → {number}
Function to normalize vector.
Returns:
- A new vector normalized.
- Type
- number
round() → {ALMath.Vector4}
Function to round between min and max.
Returns:
- A new vector rounded.
- Type
- ALMath.Vector4
set(x, y, z, w) → {ALMath.Vector3}
Function to set the vector components.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | X component. |
y |
number | Y component. |
z |
number | Z component. |
w |
number | W component. |
Returns:
- this.
- Type
- ALMath.Vector3
sub(v) → {ALMath.Vector4}
Function to substract vector v.
Parameters:
Name | Type | Description |
---|---|---|
v |
ALMath.Vector4 | Vector to substract. |
Returns:
- A new vector which is the substract between this and v.
- Type
- ALMath.Vector4
subScalar(n) → {ALMath.Vector4}
Function to substract scalar n.
Parameters:
Name | Type | Description |
---|---|---|
n |
number | Scalar to substract. |
Returns:
- A new vector which is the substract between each component of this and scalar n.
- Type
- ALMath.Vector4