Class Vector3
Represents a vector in homogeneous 3D space.
Defined in: benchgl.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Vector3(x, y, z)
Creates a new Vector3.
|
Method Attributes | Method Name and Description |
---|---|
$add(vector)
Adds another Vector3 to this Vector3.
|
|
$negate()
Negates this Vector3.
|
|
$scale(f)
Scales this Vector3 by a factor.
|
|
$sub(vector)
Subtracts another Vector3 to this Vector3.
|
|
$unit()
Normalizes this Vector3.
|
|
add(vector)
Adds another Vector3 to this Vector3.
|
|
angleWith(vector)
Calculates the angle between this and another Vector3.
|
|
copy()
Copies this Vector3 in a new one.
|
|
cross(vector)
Computes the cross product between this and another Vector3.
|
|
distTo(vector)
Calculates the distance between this and another Vector3.
|
|
distToSqr(vector)
Calculates the squared distance between this and another Vector3.
|
|
dot(vector)
Computes the dot product between this and another Vector3.
|
|
negate()
Negates this Vector3.
|
|
norm()
Gets the norm of this Vector3.
|
|
normSqr()
Gets the squared norm of this Vector3.
|
|
scale(f)
Scales this Vector3 by a factor.
|
|
set(x, y, z)
Sets this Vector3 coordinates.
|
|
sub(vector)
Subtracts another Vector3 to this Vector3.
|
|
toArray()
Gets the array version of this Vector3.
|
|
unit()
Normalizes this Vector3.
|
Class Detail
Vector3(x, y, z)
Creates a new Vector3.
- Parameters:
- {Number} x Optional, Default: 0
- The x coordinate.
- {Number} y Optional, Default: 0
- The y coordinate.
- {Number} z Optional, Default: 0
- The z coordinate.
Method Detail
{Vector3}
$add(vector)
Adds another Vector3 to this Vector3. Affects this Vector3.
- Parameters:
- {Vector3} vector
- The Vector3 to add.
- Returns:
- {Vector3} This Vector3 now stores the sum.
{Vector3}
$negate()
Negates this Vector3. Affects this Vector3.
- Returns:
- {Vector3} The negated version of this Vector3.
{Vector3}
$scale(f)
Scales this Vector3 by a factor. Affects this Vector3
- Parameters:
- {Number} f
- The factor to scale this Vector3 with.
- Returns:
- {Vector3} This Vector3 now is scaled.
{Vector3}
$sub(vector)
Subtracts another Vector3 to this Vector3. Affects this Vector3.
- Parameters:
- {Vector3} vector
- The Vector3 to add.
- Returns:
- {Vector3} This Vector3 now stores the subtraction.
{Vector3}
$unit()
Normalizes this Vector3. Affects this Vector3.
- Returns:
- {Vector3} The normalized version of this Vector3.
{Vector3}
add(vector)
Adds another Vector3 to this Vector3. Does not affect this Vector3.
- Parameters:
- {Vector3} vector
- The Vector3 to add.
- Returns:
- {Vector3} A new vector representing the addition.
{Number}
angleWith(vector)
Calculates the angle between this and another Vector3.
- Parameters:
- {Vector3} vector
- The other Vector3 to calculate the angle with.
- Returns:
- {Number} The angle between the two Vector3.
{Vector3}
copy()
Copies this Vector3 in a new one.
- Returns:
- {Vector3} A copy of this Vector3.
{Vector3}
cross(vector)
Computes the cross product between this and another Vector3.
Does not affect this Vector3.
- Parameters:
- {Vector3} vector
- The other Vector3 to compute the dot product with.
- Returns:
- {Vector3} A new vector representing the croos product.
{Number}
distTo(vector)
Calculates the distance between this and another Vector3.
- Parameters:
- {Vector3} vector
- The other Vector3 to calculate the distance with.
- Returns:
- {Number} The distance between the two Vector3.
{Number}
distToSqr(vector)
Calculates the squared distance between this and another Vector3.
- Parameters:
- {Vector3} vector
- The other Vector3 to calculate the distance with.
- Returns:
- {Number} The squared distance between the two Vector3.
{Number}
dot(vector)
Computes the dot product between this and another Vector3.
- Parameters:
- {Vector3} vector
- The other Vector3 to compute the dot product with.
- Returns:
- {Number} The dot product.
{Vector3}
negate()
Negates this Vector3. Does not affect this Vector3.
- Returns:
- {Vector3} A new vector representing the negation of this Vector3.
{Number}
norm()
Gets the norm of this Vector3.
- Returns:
- {Number} The norm of this Vector3.
{Number}
normSqr()
Gets the squared norm of this Vector3.
- Returns:
- {Number} The squared norm of this Vector3.
{Vector3}
scale(f)
Scales this Vector3 by a factor. Does not affect this Vector3.
- Parameters:
- {Number} f
- The factor to scale this Vector3 with.
- Returns:
- {Vector3} A new vector representing the scaled version of this Vector3.
set(x, y, z)
Sets this Vector3 coordinates.
- Parameters:
- {Number} x
- The x coordinate to set.
- {Number} y
- The y coordinate to set.
- {Number} z
- The z coordinate to set.
{Vector3}
sub(vector)
Subtracts another Vector3 to this Vector3. Does not affect this Vector3.
- Parameters:
- {Vector3} vector
- The Vector3 to add.
- Returns:
- {Vector3} A new vector representing the subtraction.
{Array}
toArray()
Gets the array version of this Vector3.
- Returns:
- {Array} An array representation of this Vector3.
{Vector3}
unit()
Normalizes this Vector3. Does not affect this Vector3.
- Returns:
- {Vector3} A new vector representing the normalized version of this Vector3.