Vector4
Class representing a 4D vector. A 4D vector is an ordered quadruplet of numbers (labeled x, y, z, and w).
Constructors
constructor
-
Parameters
- _x: number
- _y: number
- _z: number
- _w: number
Returns Vector4
Properties
x0
the x value of this vector.
y0
the y value of this vector.
z0
the z value of this vector.
w0
the w value of this vector.
is Vector4
Check the type whether it belongs to Vector4. This value should not be changed by user.
Methods
set
set Scalar
set X
set Y
set Z
set W
set Component
get Component
clone
clone Readonly
-
Returns ReadonlyVector4
copy
add
add Scalar
add Vectors
add Scaled Vector
sub
sub Scalar
sub Vectors
multiply Scalar
apply Matrix4
divide Scalar
-
Divides this vector by scalar s. Sets vector to
( 0, 0, 0, 0 )ifs = 0.Parameters
- scalar: number
Returns Vector4
min
max
clamp
-
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.Parameters
Returns Vector4
clamp Scalar
-
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.Parameters
- minVal: number
- maxVal: number
Returns Vector4
clamp Length
-
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.Parameters
- min: number
- max: number
Returns Vector4
floor
-
The components of this vector are rounded down to the nearest integer value.
Returns Vector4
ceil
round
-
The components of this vector are rounded to the nearest integer value.
Returns Vector4
round To Zero
-
The components of this vector are rounded towards zero (up if negative, down if positive) to an integer value.
Returns Vector4
negate
-
Inverts this vector - i.e. sets x = -x, y = -y, z = -z and w = -w.
Returns Vector4
dot
length Sq
-
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.
Returns number
length
-
Computes the Euclidean length (straight-line length) from (0, 0, 0, 0) to (x, y, z, w).
Returns number
manhattan Length
-
Computes the Manhattan length of this vector.
Returns number
normalize
-
Converts this vector to a unit vector
- that is, sets it equal to a vector with the same direction as this one, but length| length 1.
Returns Vector4
set Length
-
Sets this vector to a vector with given length the same direction as this one.
Parameters
- length: number
Returns Vector4
lerp
lerp Vectors
equals
set Axis Angle From Quaternion
set Axis Angle From Rotation Matrix
from Array0
get Number Count
-
There are 4 elements in this vector.
Returns number
to Array
-
Returns an array [x, y, z, w], or copies x, y, z and w into the provided array.
Parameters
- array: number[]
(optional) array to store this vector to. If this is not provided, a new array will be created.
- offset: number
(optional) optional offset into the array.
Returns number[]
- array: number[]
Class representing a 4D vector. A 4D vector is an ordered quadruplet of numbers (labeled x, y, z, and w).