B.Math.Vector4()Represents a 4D vector. To create the object use B.Math.makeVector4(). CONSTANTS:{B.Math.Vector4} ZERO = {x: 0.0, y: 0.0, z: 0.0, w: 0.0} Zero vector. PROPERTIES:{number} x X component. {number} y Y component. {number} z Z component. {number} w W component. METHODS:clone() Clones this vector to a new vector. RETURNS:this copy(v) Copies a given vector into this vector. set(x, y, z, w) Sets this vector from separated components. get(index) Gets an element by its index. PARAMETERS:{number} index RETURNS:{number} THROWS:{Error} if the index is out of range fromArray(array, offset) Sets this vector from a part of array. PARAMETERS:{Array.<number>} array {number} [offset] = 0 RETURNS:{number} new offset toArray(array, offset) Sets this vector to a part of array. PARAMETERS:{Array.<number>} array {number} [offset] = 0 RETURNS:{number} new offset length() Calculates the length of this vector. RETURNS:{number} length lengthSq() Calculates the squared length of this vector. RETURNS:{number} squared length normalize() Normalizes this vector. RETURNS:this negate() Inverts this vector. RETURNS:this clamp(minVal, maxVal) Clamps components of this vector. add(v) Adds a vector or a scalar to this vector. addVectors(a, b) Adds two given vectors and sets the result to this. sub(v) Subtracts a vector or a scalar from this vector. subVectors(a, b) Subtracts two given vectors and sets the result to this. mul(v) Multiplies this vector by a given vector or a scalar. mulVectors(a, b) Multiplies two given vectors and sets the result to this. div(v) Divides this vector by a given vector or a scalar. divVectors(a, b) Divides two given vectors and sets the result to this. transform(matrix) Transforms this vector by a 4x4 matrix. dot(v) Calculates the dot product of this vector and another vector. equal(v) Checks for strict equality of this vector and another vector. |
CONSTANTS:PROPERTIES:METHODS: |