Class Vector4
Hierarchy
- Vector4
Index
Constructors
Properties
Accessors
Methods
- add
- add
In Place - add
To Ref - as
Array - clone
- copy
From - copy
From Floats - divide
- divide
In Place - divide
To Ref - dot
- equals
- equals
To Floats - equals
With Epsilon - floor
- fract
- from
Array - get
Class Name - get
Hash Code - length
- length
Squared - maximize
In Place - minimize
In Place - multiply
- multiply
By Floats - multiply
In Place - multiply
To Ref - negate
- negate
In Place - negate
To Ref - normalize
- normalize
From Length - normalize
To New - normalize
To Ref - scale
- scale
And Add To Ref - scale
In Place - scale
To Ref - set
- set
All - subtract
- subtract
From Floats - subtract
From Floats To Ref - subtract
In Place - subtract
To Ref - to
Array - to
String - to
Vector3 - Center
- Center
To Ref - Distance
- Distance
Squared - Dot
- From
Array - From
Array To Ref - From
Float Array To Ref - From
Floats To Ref - From
Vector3 - Maximize
- Minimize
- Normalize
- Normalize
To Ref - One
- Random
- Transform
Coordinates - Transform
Coordinates From Floats To Ref - Transform
Coordinates To Ref - Transform
Normal - Transform
Normal From Floats To Ref - Transform
Normal To Ref - Zero
Constructors
constructor
Creates a Vector4 object from the given floats.
Parameters
Optional x: number
x value of the vector
Optional y: number
y value of the vector
Optional z: number
z value of the vector
Optional w: number
w value of the vector
Returns Vector4
Properties
wSearch playground for w
w value of the vector
xSearch playground for x
x value of the vector
ySearch playground for y
y value of the vector
zSearch playground for z
z value of the vector
Accessors
Static Zero Read Only
Gets a zero Vector4 that must not be updated
Returns DeepImmutableObject<Vector4>
Methods
addSearch playground for add
Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
Parameters
otherVector: DeepImmutableObject<Vector4>
the vector to add
Returns Vector4
the resulting vector
add In PlaceSearch playground for addInPlace
Adds the given vector to the current Vector4.
Parameters
otherVector: DeepImmutableObject<Vector4>
the vector to add
Returns Vector4
the updated Vector4.
add To RefSearch playground for addToRef
Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
Type Parameters
T extends Vector4<T>
Parameters
otherVector: DeepImmutableObject<Vector4>
the vector to add
result: T
the vector to store the result
Returns T
result input
as ArraySearch playground for asArray
Returns a new array populated with 4 elements : the Vector4 coordinates.
Returns number[]
the resulting array
cloneSearch playground for clone
Returns a new Vector4 copied from the current one.
Returns Vector4
the new cloned vector
copy FromSearch playground for copyFrom
Updates the current Vector4 with the given one coordinates.
Parameters
source: DeepImmutableObject<Vector4>
the source vector to copy from
Returns Vector4
the updated Vector4.
copy From FloatsSearch playground for copyFromFloats
Updates the current Vector4 coordinates with the given floats.
Parameters
x: number
float to copy from
y: number
float to copy from
z: number
float to copy from
w: number
float to copy from
Returns Vector4
the updated Vector4.
divideSearch playground for divide
Returns a new Vector4 set with the division result of the current Vector4 by the given one.
Parameters
otherVector: DeepImmutableObject<Vector4>
vector to devide with
Returns Vector4
resulting new vector
divide In PlaceSearch playground for divideInPlace
Divides the current Vector3 coordinates by the given ones.
Parameters
otherVector: DeepImmutableObject<Vector4>
vector to devide with
Returns Vector4
the updated Vector3.
divide To RefSearch playground for divideToRef
Updates the given vector "result" with the division result of the current Vector4 by the given one.
Type Parameters
T extends Vector4<T>
Parameters
otherVector: DeepImmutableObject<Vector4>
vector to devide with
result: T
vector to store the result
Returns T
result input
dotSearch playground for dot
Returns the dot product (float) between the current vectors and "otherVector"
Parameters
otherVector: DeepImmutableObject<Vector4>
defines the right operand
Returns number
the dot product
equalsSearch playground for equals
Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
Parameters
otherVector: DeepImmutableObject<Vector4>
the vector to compare against
Returns boolean
true if they are equal
equals To FloatsSearch playground for equalsToFloats
Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
Parameters
x: number
x value to compare against
y: number
y value to compare against
z: number
z value to compare against
w: number
w value to compare against
Returns boolean
true if equal
equals With EpsilonSearch playground for equalsWithEpsilon
Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
Parameters
otherVector: DeepImmutableObject<Vector4>
vector to compare against
Optional epsilon: number
(Default: very small number)
Returns boolean
true if they are equal
floorSearch playground for floor
Gets a new Vector4 from current Vector4 floored values
Returns Vector4
a new Vector4
fractSearch playground for fract
Gets a new Vector4 from current Vector4 fractional values
Returns Vector4
a new Vector4
from ArraySearch playground for fromArray
Update the current vector from an array
Parameters
array: FloatArray
defines the destination array
Optional index: number
defines the offset in the destination array
Returns Vector4
the current Vector3
get Class NameSearch playground for getClassName
Returns the string "Vector4".
Returns string
"Vector4"
get Hash CodeSearch playground for getHashCode
Returns the Vector4 hash code.
Returns number
a unique hash code
lengthSearch playground for length
Returns the Vector4 length (float).
Returns number
the length
length SquaredSearch playground for lengthSquared
Returns the Vector4 squared length (float).
Returns number
the length squared
maximize In PlaceSearch playground for maximizeInPlace
Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
Parameters
other: DeepImmutableObject<Vector4>
defines the second operand
Returns Vector4
the current updated Vector4
minimize In PlaceSearch playground for minimizeInPlace
Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
Parameters
other: DeepImmutableObject<Vector4>
defines the second operand
Returns Vector4
the current updated Vector4
multiplySearch playground for multiply
Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
Parameters
otherVector: DeepImmutableObject<Vector4>
vector to multiple with
Returns Vector4
resulting new vector
multiply By FloatsSearch playground for multiplyByFloats
Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
Parameters
x: number
x value multiply with
y: number
y value multiply with
z: number
z value multiply with
w: number
w value multiply with
Returns Vector4
resulting new vector
multiply In PlaceSearch playground for multiplyInPlace
multiply To RefSearch playground for multiplyToRef
Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
Type Parameters
T extends Vector4<T>
Parameters
otherVector: DeepImmutableObject<Vector4>
vector to multiple with
result: T
vector to store the result
Returns T
result input
negateSearch playground for negate
Returns a new Vector4 set with the current Vector4 negated coordinates.
Returns Vector4
a new vector with the negated values
negate In PlaceSearch playground for negateInPlace
Negate this vector in place
Returns Vector4
this
negate To RefSearch playground for negateToRef
Negate the current Vector4 and stores the result in the given vector "result" coordinates
Type Parameters
T extends Vector4<T>
Parameters
result: T
defines the Vector3 object where to store the result
Returns T
the result
normalizeSearch playground for normalize
Normalizes in place the Vector4.
Returns Vector4
the updated Vector4.
normalize From LengthSearch playground for normalizeFromLength
Normalize the current Vector4 with the given input length. Please note that this is an in place operation.
Parameters
len: number
the length of the vector
Returns Vector4
the current updated Vector4
normalize To NewSearch playground for normalizeToNew
Normalize the current Vector4 to a new vector
Returns Vector4
the new Vector4
normalize To RefSearch playground for normalizeToRef
Normalize the current Vector4 to the reference
Type Parameters
T extends Vector4<T>
Parameters
reference: T
define the Vector4 to update
Returns T
the updated Vector4
scaleSearch playground for scale
Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
Parameters
scale: number
the number to scale with
Returns Vector4
a new vector with the result
scale And Add To RefSearch playground for scaleAndAddToRef
Scale the current Vector4 values by a factor and add the result to a given Vector4
Type Parameters
T extends Vector4<T>
Parameters
scale: number
defines the scale factor
result: T
defines the Vector4 object where to store the result
Returns T
result input
scale In PlaceSearch playground for scaleInPlace
Multiplies the current Vector4 coordinates by scale (float).
Parameters
scale: number
the number to scale with
Returns Vector4
the updated Vector4.
scale To RefSearch playground for scaleToRef
Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
Type Parameters
T extends Vector4<T>
Parameters
scale: number
the number to scale with
result: T
a vector to store the result in
Returns T
result input
setSearch playground for set
Updates the current Vector4 coordinates with the given floats.
Parameters
x: number
float to set from
y: number
float to set from
z: number
float to set from
w: number
float to set from
Returns Vector4
the updated Vector4.
set AllSearch playground for setAll
Copies the given float to the current Vector3 coordinates
Parameters
v: number
defines the x, y, z and w coordinates of the operand
Returns Vector4
the current updated Vector3
subtractSearch playground for subtract
Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
Parameters
otherVector: DeepImmutableObject<Vector4>
the vector to add
Returns Vector4
the new vector with the result
subtract From FloatsSearch playground for subtractFromFloats
Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
Parameters
x: number
value to subtract
y: number
value to subtract
z: number
value to subtract
w: number
value to subtract
Returns Vector4
new vector containing the result
subtract From Floats To RefSearch playground for subtractFromFloatsToRef
Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
Type Parameters
T extends Vector4<T>
Parameters
x: number
value to subtract
y: number
value to subtract
z: number
value to subtract
w: number
value to subtract
result: T
the vector to store the result in
Returns T
result input
subtract In PlaceSearch playground for subtractInPlace
Subtract in place the given vector from the current Vector4.
Parameters
otherVector: DeepImmutableObject<Vector4>
the vector to subtract
Returns Vector4
the updated Vector4.
subtract To RefSearch playground for subtractToRef
Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
Type Parameters
T extends Vector4<T>
Parameters
otherVector: DeepImmutableObject<Vector4>
the vector to subtract
result: T
the vector to store the result
Returns T
result input
to ArraySearch playground for toArray
Populates the given array from the given index with the Vector4 coordinates.
Parameters
array: FloatArray
array to populate
Optional index: number
index of the array to start at (default: 0)
Returns Vector4
the Vector4.
to StringSearch playground for toString
Returns the string with the Vector4 coordinates.
Returns string
a string containing all the vector values
to Vector3Search playground for toVector3
Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
Returns Vector3
this converted to a new vector3
Static CenterSearch playground for Center
Returns a new Vector4 located at the center between the vectors "value1" and "value2".
Parameters
value1: DeepImmutableObject<Vector4>
value to calulate the center between
value2: DeepImmutableObject<Vector4>
value to calulate the center between
Returns Vector4
the center between the two vectors
Static Center To RefSearch playground for CenterToRef
Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
Type Parameters
T extends Vector4<T>
Parameters
value1: DeepImmutableObject<Vector4>
defines first vector
value2: DeepImmutableObject<Vector4>
defines second vector
ref: T
defines third vector
Returns T
ref
Static DistanceSearch playground for Distance
Returns the distance (float) between the vectors "value1" and "value2".
Parameters
value1: DeepImmutableObject<Vector4>
value to calulate the distance between
value2: DeepImmutableObject<Vector4>
value to calulate the distance between
Returns number
the distance between the two vectors
Static Distance SquaredSearch playground for DistanceSquared
Returns the squared distance (float) between the vectors "value1" and "value2".
Parameters
value1: DeepImmutableObject<Vector4>
value to calulate the distance between
value2: DeepImmutableObject<Vector4>
value to calulate the distance between
Returns number
the distance between the two vectors squared
Static DotSearch playground for Dot
Returns the dot product (float) between the vectors "left" and "right"
Parameters
left: DeepImmutableObject<Vector4>
defines the left operand
right: DeepImmutableObject<Vector4>
defines the right operand
Returns number
the dot product
Static From ArraySearch playground for FromArray
Returns a new Vector4 set from the starting index of the given array.
Parameters
array: DeepImmutableObject<ArrayLike<number>>
the array to pull values from
Optional offset: number
the offset into the array to start at
Returns Vector4
the new vector
Static From Array To RefSearch playground for FromArrayToRef
Updates the given vector "result" from the starting index of the given array.
Type Parameters
T extends Vector4<T>
Parameters
array: DeepImmutableObject<ArrayLike<number>>
the array to pull values from
offset: number
the offset into the array to start at
result: T
the vector to store the result in
Returns T
result input
Static From Float Array To RefSearch playground for FromFloatArrayToRef
Updates the given vector "result" from the starting index of the given Float32Array.
Type Parameters
T extends Vector4<T>
Parameters
array: DeepImmutableObject<Float32Array>
the array to pull values from
offset: number
the offset into the array to start at
result: T
the vector to store the result in
Returns T
result input
Static From Floats To RefSearch playground for FromFloatsToRef
Updates the given vector "result" coordinates from the given floats.
Type Parameters
T extends Vector4<T>
Parameters
x: number
float to set from
y: number
float to set from
z: number
float to set from
w: number
float to set from
result: T
the vector to the floats in
Returns T
result input
Static From Vector3Search playground for FromVector3
Static MaximizeSearch playground for Maximize
Returns a vector with the maximum values from the left and right vectors
Type Parameters
T extends Vector4<T>
Parameters
left: DeepImmutable<T>
left vector to maximize
right: DeepImmutableObject<Vector4>
right vector to maximize
Returns T
a new vector with the maximum of the left and right vector values
Static MinimizeSearch playground for Minimize
Returns a vector with the minimum values from the left and right vectors
Type Parameters
T extends Vector4<T>
Parameters
left: DeepImmutable<T>
left vector to minimize
right: DeepImmutableObject<Vector4>
right vector to minimize
Returns T
a new vector with the minimum of the left and right vector values
Static NormalizeSearch playground for Normalize
Returns a new normalized Vector4 from the given one.
Parameters
vector: DeepImmutableObject<Vector4>
the vector to normalize
Returns Vector4
the vector
Static Normalize To RefSearch playground for NormalizeToRef
Updates the given vector "result" from the normalization of the given one.
Type Parameters
T extends Vector4<T>
Parameters
vector: DeepImmutableObject<Vector4>
the vector to normalize
result: T
the vector to store the result in
Returns T
result input
Static OneSearch playground for One
Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
Returns Vector4
the new vector
Static RandomSearch playground for Random
Returns a new Vector4 with random values between min and max
Parameters
Optional min: number
the minimum random value
Optional max: number
the maximum random value
Returns Vector4
a Vector4 with random values between min and max
Static Transform CoordinatesSearch playground for TransformCoordinates
Returns a new Vector4 set with the result of the transformation by the given matrix of the given vector. This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account) The difference with Vector3.TransformCoordinates is that the w component is not used to divide the other coordinates but is returned in the w coordinate instead
Parameters
vector: DeepImmutableObject<Vector3>
defines the Vector3 to transform
transformation: DeepImmutableObject<Matrix>
defines the transformation matrix
Returns Vector4
the transformed Vector4
Static Transform Coordinates From Floats To RefSearch playground for TransformCoordinatesFromFloatsToRef
Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z) This method computes tranformed coordinates only, not transformed direction vectors The difference with Vector3.TransformCoordinatesFromFloatsToRef is that the w component is not used to divide the other coordinates but is returned in the w coordinate instead
Type Parameters
T extends Vector4<T>
Parameters
x: number
define the x coordinate of the source vector
y: number
define the y coordinate of the source vector
z: number
define the z coordinate of the source vector
transformation: DeepImmutableObject<Matrix>
defines the transformation matrix
result: T
defines the Vector4 where to store the result
Returns T
result input
Static Transform Coordinates To RefSearch playground for TransformCoordinatesToRef
Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account) The difference with Vector3.TransformCoordinatesToRef is that the w component is not used to divide the other coordinates but is returned in the w coordinate instead
Type Parameters
T extends Vector4<T>
Parameters
vector: DeepImmutableObject<Vector3>
defines the Vector3 to transform
transformation: DeepImmutableObject<Matrix>
defines the transformation matrix
result: T
defines the Vector4 where to store the result
Returns T
result input
Static Transform NormalSearch playground for TransformNormal
Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector. This methods computes transformed normalized direction vectors only.
Type Parameters
T extends Vector4<T>
Parameters
vector: DeepImmutable<T>
the vector to transform
transformation: DeepImmutableObject<Matrix>
the transformation matrix to apply
Returns T
the new vector
Static Transform Normal From Floats To RefSearch playground for TransformNormalFromFloatsToRef
Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w). This methods computes transformed normalized direction vectors only.
Type Parameters
T extends Vector4<T>
Parameters
x: number
value to transform
y: number
value to transform
z: number
value to transform
w: number
value to transform
transformation: DeepImmutableObject<Matrix>
the transformation matrix to apply
result: T
the vector to store the results in
Returns T
result input
Static Transform Normal To RefSearch playground for TransformNormalToRef
Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector. This methods computes transformed normalized direction vectors only.
Type Parameters
T extends Vector4<T>
Parameters
vector: DeepImmutableObject<Vector4>
the vector to transform
transformation: DeepImmutableObject<Matrix>
the transformation matrix to apply
result: T
the vector to store the result in
Returns T
result input
Static ZeroSearch playground for Zero
Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
Returns Vector4
the new vector
Vector4 class created for EulerAngle class conversion to Quaternion