Vector2
Vector2 is used to represent 2D vectors and points. It is used internally by the editor to pass 2D positions and directions. Additionally, it includes functions for performing common vector operations.
构造方法
Vector2.new ( x : number? , y : number? ) |
成员变量
Vector2.x : number |
| The X component of the vector. |
Vector2.y : number |
| The Y component of the vector. |
Vector2.minChannel : number |
| (Read Only) Gets the minimum component of the current vector. |
Vector2.negative : Vector2 |
| (Read-only) The negation of the vector. |
Vector2.maxChannel : number |
| (Read Only) Gets the maximum component of the current vector. |
Vector2.magnitude : number |
| (Read Only) Returns the length of this vector. |
Vector2.sqrMagnitude : number |
| (Read Only) Returns the squared magnitude of the current vector object. |
Vector2.inverse : Vector2 |
| (Read-only) The inverse of the vector. |
Vector2.normalized : Vector2 |
| (Read Only) Returns the normalized value of the vector. |
Vector2.abs : Vector2 |
| (Read-only) The absolute value vector of the current vector object. |
Vector2.almostZero : boolean |
| (Read Only) Determines if the current vector object is close to the zero vector. |
静态变量
Vector2.zero : Vector2 |
| (Read Only) Constructs a Vector2 object with each component set to 0. |
Vector2.one : Vector2 |
| (Read Only) Constructs a Vector2 object with each component set to 1. |
Vector2.infinity : Vector2 |
| (Read Only) Returns a Vector2 object representing positive infinity. In this object, both the x and y components are set to Infinity. |
成员方法
Vector2.SetValues ( x : number , y : number ) : void |
| Sets the x and y components of an existing vector. |
Vector2.Scale ( scale : Vector2 ) : void |
| Scales the vector. |
Vector2.Negative ( ) : void |
| Get the opposite of the current vector. |
Vector2.Inverse ( ) : void |
| Get the inverse of the current vector. |
Vector2.toString ( ) : string |
| Get the formatted string of the current vector. |
Vector2.Normalize ( ) : void |
| Normalize the current vector. |
Vector2.CopyFrom ( from : Vector2 ) : void |
| Copies each component of the parameter vector to the specified component of the current vector. |
Vector2.Get ( index : number ) : number |
| Returns the component value at the specified index position in the current vector object. |
Vector2.Set ( index : number , value : number ) : void |
| Set the value of the component at the specified index in the current Vector object. |
Vector2.Add ( rhs : number|Vector2 ) : Vector2 |
| Adds the current vector object with another vector or a number, and returns the resulting vector. |
Vector2.Sub ( rhs : number|Vector2 ) : Vector2 |
| Subtracts the current vector object by another vector or a number, and returns the resulting vector. |
Vector2.Mul ( rhs : number|Vector2 ) : Vector2 |
| Multiplies the current vector object by another vector or a scalar value and returns the resulting vector. |
Vector2.Div ( rhs : number|Vector2 ) : Vector2 |
| Divides the current vector by another vector or a scalar value and returns the resulting vector. |
Vector2.AddAssign ( rhs : number|Vector2 ) : void |
| Adds the current vector object with another vector or a scalar value, and assigns the result to the current vector object. |
Vector2.SubAssign ( rhs : number|Vector2 ) : void |
| Subtracts another vector or a scalar from the current vector object and assigns the result to the current vector object. |
Vector2.MulAssign ( rhs : number|Vector2 ) : void |
| Multiplies the current vector object by another vector or a scalar value and assigns the result to the current vector object. |
Vector2.DivAssign ( rhs : number|Vector2 ) : void |
| Divides the components of the current vector object by the corresponding components or value of another vector, and assigns the result to the current vector object. |
Vector2.EqualsTo ( other : Vector2 ) : boolean |
| Determines whether the current Vector2 is equal to the target Vector2. |
静态方法
Vector2.Clone ( val : Vector2 ) : Vector2 |
Constructs a new vector using the vector val. |
Vector2.Dot ( lhs : Vector2 , rhs : Vector2 ) : number |
| Calculates the dot product of two vectors. |
Vector2.Lerp ( lhs : Vector2 , rhs : Vector2 , t : number ) : Vector2 |
| Linearly interpolates between two vectors, lhs and rhs, based on a given interpolation parameter t, and returns the interpolated result. |
Vector2.LerpUnclamped ( lhs : Vector2 , rhs : Vector2 , t : number ) : Vector2 |
| Performs a linear interpolation between two vectors and returns the interpolated result. |
Vector2.Min ( lhs : Vector2 , rhs : Vector2 ) : Vector2 |
| Calculates the minimum value of each component of two Vector2 objects. |
Vector2.Distance ( lhs : Vector2 , rhs : Vector2 ) : number |
| Calculates the straight-line distance between two vectors. |
Vector2.Max ( lhs : Vector2 , rhs : Vector2 ) : Vector2 |
| Calculates the maximum value of each component of two Vector2 objects. |
Vector2.EqualsTo ( lhs : Vector2 , rhs : Vector2 ) : boolean |
| Determines whether two Vector2 objects are equal. |
