Vector2¶
Vector2 is a 2D vector with an x and y component.
Properties¶
- X:
number - Y:
number - Down:
Vector2 - Left:
Vector2 - One:
Vector2 - Zero:
Vector2 - Right:
Vector2 - Up:
Vector2 - Magnitude:
number - Normalized:
Vector2 - SqrMagnitude:
number
Methods¶
New() → Vector2¶
Returns a new Vector2 with the given x and y components.
New(d: number) → Vector2¶
Returns a new Vector2 with the given x and y components.
New(x: number, y: number) → Vector2¶
Returns a new Vector2 with the given x and y components.
Angle(from: Vector2, to: Vector2) → number¶
Returns the angle in degrees between from and to.
Cross(lhs: Vector2, rhs: Vector2) → Vector2¶
Returns the cross product of lhs and rhs.
Distance(a: Vector2, b: Vector2) → number¶
Returns the distance between a and b.
Dot(lhs: Vector2, rhs: Vector2) → number¶
Returns the dot product of lhs and rhs.
Lerp(a: Vector2, b: Vector2, t: number) → Vector2¶
Returns a new vector that is the linear interpolation between a and b by t.
Max(lhs: Vector2, rhs: Vector2) → Vector2¶
Returns a vector that is made from the largest components of two vectors.
Min(lhs: Vector2, rhs: Vector2) → Vector2¶
Returns a vector that is made from the smallest components of two vectors.
MoveTowards(current: Vector2, target: Vector2, maxDistanceDelta: number) → Vector2¶
Calculate a position between the points specified by current and target, moving no farther than the distance specified by maxDistanceDelta.
Normalize(value: Vector2) → Vector2¶
Returns a new Vector2 that is the normalized version of the given vector.
Project(vector: Vector2, onNormal: Vector2) → Vector2¶
Returns the projection of a vector onto another vector.
Reflect(inDirection: Vector2, inNormal: Vector2) → Vector2¶
Returns the reflection of a vector off the plane defined by a normal.
Slerp(a: Vector2, b: Vector2, t: number) → Vector2¶
Spherically interpolates between two vectors.