Vector4
A vector with four components.
Constructor Summary
Public Constructor | ||
public |
constructor(x: Number, y: Number, z: Number, w: Number) Constructs a new vector. |
Member Summary
Public Members | ||
public |
The W component. |
|
public |
The X component. |
|
public |
The Y component. |
|
public |
The Z component. |
Method Summary
Public Methods | ||
public |
Adds a vector to this one. |
|
public |
Adds a scalar to this vector. |
|
public |
addScaledVector(v: Vector4, s: Number): Vector4 Adds a scaled vector to this one. |
|
public |
addVectors(a: Vector4, b: Vector4): Vector4 Sets this vector to the sum of two given vectors. |
|
public |
applyMatrix4(m: Matrix4): Vector4 Applies a matrix to this vector. |
|
public |
Ceils this vector. |
|
public |
Clamps this vector. |
|
public |
Clones this vector. |
|
public |
Copies the values of another vector. |
|
public |
distanceTo(v: Vector4): Number Calculates the distance to a given vector. |
|
public |
Calculates the squared distance to a given vector. |
|
public |
Divides this vector by another vector. |
|
public |
divideScalar(s: Number): Vector4 Divides this vector by a given scalar. |
|
public |
Calculates the dot product with another vector. |
|
public |
Checks if this vector equals the given one. |
|
public |
Floors this vector. |
|
public |
Copies values from an array. |
|
public |
Calculates the length of this vector. |
|
public |
Calculates the squared length of this vector. |
|
public |
Lerps towards the given vector. |
|
public |
lerpVectors(v1: Vector4, v2: Vector4, alpha: Number): Vector4 Sets this vector to the lerp result of the given vectors. |
|
public |
Calculates the Manhattan distance to a given vector. |
|
public |
Calculates the Manhattan length of this vector. |
|
public |
Adopts the max value for each component of this vector and the given one. |
|
public |
Adopts the min value for each component of this vector and the given one. |
|
public |
Multiplies this vector with another vector. |
|
public |
multiplyScalar(s: Number): Vector4 Multiplies this vector with a given scalar. |
|
public |
multiplyVectors(a: Vector4, b: Vector4): Vector4 Sets this vector to the product of two given vectors. |
|
public |
Negates this vector. |
|
public |
Normalizes this vector. |
|
public |
Randomizes the values of this vector |
|
public |
Rounds this vector. |
|
public |
Sets the values of this vector |
|
public |
Stores the axis angle from the given quaternion in this vector. |
|
public |
Stores the axis angle from the given rotation matrix in this vector. |
|
public |
Sets the length of this vector. |
|
public |
Subtracts a vector from this vector. |
|
public |
Subtracts a scalar from this vector. |
|
public |
subVectors(a: Vector4, b: Vector4): Vector4 Sets this vector to the difference between two given vectors. |
|
public |
Stores this vector in an array. |
Public Constructors
Public Members
Public Methods
public add(v: Vector4): Vector4 source
Adds a vector to this one.
Params:
Name | Type | Attribute | Description |
v | Vector4 | The vector to add. |
public addScalar(s: Number): Vector4 source
Adds a scalar to this vector.
Params:
Name | Type | Attribute | Description |
s | Number | The scalar to add. |
public addVectors(a: Vector4, b: Vector4): Vector4 source
Sets this vector to the sum of two given vectors.
public applyMatrix4(m: Matrix4): Vector4 source
Applies a matrix to this vector.
Params:
Name | Type | Attribute | Description |
m | Matrix4 | A matrix. |
public copy(v: Vector4): Vector4 source
Copies the values of another vector.
Params:
Name | Type | Attribute | Description |
v | Vector4 | A vector. |
public distanceTo(v: Vector4): Number source
Calculates the distance to a given vector.
Params:
Name | Type | Attribute | Description |
v | Vector4 | A vector. |
public distanceToSquared(v: Vector4): Number source
Calculates the squared distance to a given vector.
Params:
Name | Type | Attribute | Description |
v | Vector4 | A vector. |
public divide(v: Vector4): Vector4 source
Divides this vector by another vector.
Params:
Name | Type | Attribute | Description |
v | Vector4 | A vector. |
public divideScalar(s: Number): Vector4 source
Divides this vector by a given scalar.
Params:
Name | Type | Attribute | Description |
s | Number | A scalar. |
public dot(v: Vector4): Number source
Calculates the dot product with another vector.
Params:
Name | Type | Attribute | Description |
v | Vector4 | A vector. |
public equals(v: Vector4): Boolean source
Checks if this vector equals the given one.
Params:
Name | Type | Attribute | Description |
v | Vector4 | A vector. |
public lerpVectors(v1: Vector4, v2: Vector4, alpha: Number): Vector4 source
Sets this vector to the lerp result of the given vectors.
public manhattanDistanceTo(v: Vector4): Number source
Calculates the Manhattan distance to a given vector.
Params:
Name | Type | Attribute | Description |
v | Vector4 | A vector. |
public max(v: Vector4): Vector4 source
Adopts the max value for each component of this vector and the given one.
Params:
Name | Type | Attribute | Description |
v | Vector4 | A vector. |
public min(v: Vector4): Vector4 source
Adopts the min value for each component of this vector and the given one.
Params:
Name | Type | Attribute | Description |
v | Vector4 | A vector. |
public multiply(v: Vector4): Vector4 source
Multiplies this vector with another vector.
Params:
Name | Type | Attribute | Description |
v | Vector4 | A vector. |
public multiplyScalar(s: Number): Vector4 source
Multiplies this vector with a given scalar.
Params:
Name | Type | Attribute | Description |
s | Number | A scalar. |
public multiplyVectors(a: Vector4, b: Vector4): Vector4 source
Sets this vector to the product of two given vectors.
public set(x: Number, y: Number, z: Number, w: Number): Vector4 source
Sets the values of this vector
public setAxisAngleFromQuaternion(q: Quaternion): Vector4 source
Stores the axis angle from the given quaternion in this vector.
For more details see: http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
Params:
Name | Type | Attribute | Description |
q | Quaternion | A quaternion. Assumed to be normalized |
public setAxisAngleFromRotationMatrix(m: Matrix4): Vector4 source
Stores the axis angle from the given rotation matrix in this vector.
For more details see: http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm
Params:
Name | Type | Attribute | Description |
m | Matrix4 | A matrix. The upper 3x3 must be a pure rotation matrix (i.e. unscaled). |
public setLength(length: Number): Vector4 source
Sets the length of this vector.
Params:
Name | Type | Attribute | Description |
length | Number | The new length. |
public sub(v: Vector4): Vector4 source
Subtracts a vector from this vector.
Params:
Name | Type | Attribute | Description |
v | Vector4 | The vector to subtract. |
public subScalar(s: Number): Vector4 source
Subtracts a scalar from this vector.
Params:
Name | Type | Attribute | Description |
s | Number | The scalar to subtract. |