Creates a new Vector4.
the x value of this vector. Default is 0.
the y value of this vector. Default is 0.
the z value of this vector. Default is 0.
the w value of this vector. Default is 0.
Alias for w.
Read-only flag to check if a given object is of type Vector.
Read-only flag to check if a given object is of type Vector4.
Alias for z.
Adds the scalar value s to this vector's x, y, z and w values
This instance.
The scalar.
Sets this vector to a + b.
This instance.
The x, y, z and w components of this vector are rounded up to the nearest integer value.
This instance.
If this vector's x, y, z or w value is greater than the max vector's x, y, z or w value, it is replaced by the corresponding value.
If this vector's x, y, z or w value is less than the min vector's x, y, z or w value, it is replaced by the corresponding value.
This instance.
Restrict the min and max length of this vector. If this vector's length is greater than the max value, it is replaced by the max value. If this vector's length is less than the min value, it is replaced by the min value.
This instance.
the minimum value the length will be clamped to
the maximum value the length will be clamped to
Restrict the min and max component values. If this vector's x, y, z or w values are greater than the max value, they are replaced by the max value.
If this vector's x, y, z or w values are less than the min value, they are replaced by the min value.
This instance.
The minimum value the components will be clamped to
The maximum value the components will be clamped to
A new Vector4 instance.
Divides this vector by scalar s.
This instance.
The scalar
Calculates the dot product of this vector and v.
The dot product.
The other vector.
Compare the components of this vector are strictly equal to those of v.
True if the components of this vector and v are strictly equal; false otherwise.
The other vector.
The components of this vector are rounded down to the nearest integer value.
This instance.
Sets this vector's x value to be array[ offset + 0 ]
, y value to be
array[ offset + 1 ]
z value to be array[ offset + 2 ]
and w value to be array[ offset + 3 ]
.
This instance.
The source array.
(Optional) offset into the array. Default is 0.
Get the componet referenced by index.
If index equals 0 set x to value.
If index equals 1 set y to value.
If index equals 2 set z to value.
If index equals 3 set w to value.
This instance.
0, 1 or 2.
Computes the Euclidean length (straight-line length) from (0, 0, 0, 0) to (x, y, z, w).
The Euclidean length
Computes the square of the Euclidean length (straight-line length) from (0, 0, 0, 0) to (x, y, z, w). If you are comparing the lengths of vectors, you should compare the length squared instead as it is slightly more efficient to calculate.
The length squared.
Linearly interpolates between this vector and v, where alpha is the percent distance along the line - alpha = 0 will be this vector, and alpha = 1 will be v.
This instance.
Vector4 to interpolate towards.
interpolation factor, typically in the closed interval [0, 1].
Sets this vector to be the vector linearly interpolated between v1 and v2 where alpha is the percent distance along the line connecting the two vectors - alpha = 0 will be v1, and alpha = 1 will be v2.
This instance.
Multiplies this vector by scalar s.
This instance.
The scalar to multiply by.
Inverts this vector - i.e. sets x = -x, y = -y, z = -z and w = -w.
This instance.
Converts this vector to a unit vector - that is, sets it equal to a vector with the same direction as this one, but length 1.
This instance.
Sets each component of this vector to a pseudo-random value between 0 and 1, excluding 1.
This instance.
The components of this vector are rounded to the nearest integer value.
This instance.
The components of this vector are rounded towards zero (up if negative, down if positive) to an integer value.
This instance.
Sets the x, y, z and w components of this vector.
This instance.
Sets the x, y and z components of this vector to the quaternion's axis and w to the angle.
This instance.
The source quaternion
Set the componet referenced by index.
If index equals 0 set x to value.
If index equals 1 set y to value.
If index equals 2 set z to value.
If index equals 3 set w to value.
This instance.
0, 1 or 2.
THe new component value
Sets this vector to a vector with the same direction as this one, but length l.
This instance.
The new length.
Sets the x, y, z and w values of this vector both equal to scalar.
This instance.
Subtracts s from this vector's x, y, z and w components.
This instance.
The scalar
Sets this vector to a - b.
This instance.
Create an array [x, y, z, w], or copies x, y, z and w into the provided array.
The array.
(optional) array to store this vector to. If this is not provided, a new array will be created.
(optional) optional offset into the array.
Class representing a 4D vector. A 4D vector is an ordered quadruplet of numbers (labeled x, y, z, and w), which can be used to represent a number of things, such as:
Iterating through a Vector4 instance will yield its components (x, y, z, w) in the corresponding order.
Example