Skip to content

Vector4

The Vector4 class is used to represent a four-dimensional vector.

构造方法

Vector4.new ( x : number? , y : number? , z : number? , w : number? )

成员变量

Vector4.x : number
The X component of the vector.
Vector4.y : number
The Y component of the vector.
Vector4.z : number
The Z component of the vector.
Vector4.w : number
The W component of the vector.
Vector4.minChannel : number
(Read Only) Gets the minimum component of the current vector.
Vector4.negative : Vector4
(Read-only) The opposite of the vector.
Vector4.maxChannel : number
(Read Only) The maximum component of the current vector.
Vector4.magnitude : number
(Read Only) Returns the length of this vector.
Vector4.sqrMagnitude : number
(Read Only) Returns the squared length of the current vector object.
Vector4.inverse : Vector4
(Read-only) The reciprocal of the vector.
Vector4.normalized : Vector4
(Read Only) Returns the normalized value of the vector.
Vector4.abs : Vector4
(Read Only) Returns the absolute value vector of the current vector object.
Vector4.almostZero : boolean
(Read Only) Determines if the current vector object is close to the zero vector.

静态变量

Vector4.zero : Vector4
(Read Only) Returns a Vector4 object with each component set to 0.
Vector4.one : Vector4
(Read Only) Returns a Vector4 object with each component set to 1.
Vector4.infinity : Vector4
(Read Only) Returns a Vector4 object representing positive infinity. In this object, each component is set to Infinity.

成员方法

Vector4.SetValues ( x : number , y : number , z : number , w : number ) : void
Sets the values of an existing vector for each component.
Vector4.Scale ( scale : Vector4 ) : void
Scales the vector by a given factor.
Vector4.Negative ( ) : void
Get the opposite of the current vector.
Vector4.Inverse ( ) : void
Get the reciprocal of the current vector.
Vector4.toString ( ) : string
Get the formatted string of the current vector.
Vector4.Normalize ( ) : void
Normalize the current vector.
Vector4.CopyFrom ( from : Vector4 ) : void
Copies each component of the parameter vector to the specified component of the current vector.
Vector4.Get ( index : number ) : number
Returns the component value at the specified index position in the current Vector object.
Vector4.Set ( index : number , value : number ) : void
Set the value of the component at the specified index in the current Vector4 object.
Vector4.Add ( rhs : number|Vector4 ) : Vector4
Adds the current vector object with another vector or a scalar value and returns the resulting vector.
Vector4.Sub ( rhs : number|Vector4 ) : Vector4
Subtracts another vector or a scalar from the current vector object and returns the resulting vector.
Vector4.Mul ( rhs : number|Vector4 ) : Vector4
Multiplies the current vector object by another vector or a scalar value and returns the resulting vector.
Vector4.Div ( rhs : number|Vector4 ) : Vector4
Divides the current vector by another vector or a scalar value and returns the resulting vector.
Vector4.AddAssign ( rhs : number|Vector4 ) : void
Adds the current vector object with another vector or a scalar value, and assigns the result to the current vector object.
Vector4.SubAssign ( rhs : number|Vector4 ) : void
Subtracts another vector or a scalar from the current vector object and assigns the result to the current vector object.
Vector4.MulAssign ( rhs : number|Vector4 ) : void
Multiplies the current vector object by another vector or a scalar value and assigns the result to the current vector object.
Vector4.DivAssign ( rhs : number|Vector4 ) : void
Divides the components of the current vector object by the corresponding components of another vector or a scalar value, and assigns the result to the current vector object.
Vector4.EqualsTo ( other : Vector4 ) : boolean
Determines whether the current Vector4 is equal to the target Vector4.

静态方法

Vector4.Clone ( val : Vector4 ) : Vector4
Constructs a new vector using the vector val.
Vector4.Dot ( lhs : Vector4 , rhs : Vector4 ) : number
Calculates the dot product of two vectors.
Vector4.Lerp ( lhs : Vector4 , rhs : Vector4 , t : number ) : Vector4
Linearly interpolates between two vectors, lhs and rhs, based on a given interpolation parameter t, and returns the interpolated result.
Vector4.LerpUnclamped ( lhs : Vector4 , rhs : Vector4 , t : number ) : Vector4
Performs a linear interpolation between two vectors and returns the interpolated result.
Vector4.Min ( lhs : Vector4 , rhs : Vector4 ) : Vector4
Calculates the minimum value of each component of two Vector4 objects.
Vector4.Distance ( lhs : Vector4 , rhs : Vector4 ) : number
Calculates the straight-line distance between two vectors.
Vector4.Max ( lhs : Vector4 , rhs : Vector4 ) : Vector4
Calculates the maximum value for each component of two Vector4 objects.
Vector4.EqualsTo ( lhs : Vector4 , rhs : Vector4 ) : boolean
Determines whether two Vector4 objects are equal.