Class
: A 2D vector.
: number The x coordinate
: number The y coordinate
static (deg: number)
=> Vec2 Create a new Vec2 from an angle in degrees
static (arr: Array<number>)
=> Vec2 Create a new Vec2 from an array
static : Vec2 An empty vector. (0, 0)
static : Vec2 A vector with both components of 1. (1, 1)
static : Vec2 A vector signaling to the left. (-1, 0)
static : Vec2 A vector signaling to the right. (1, 0)
static : Vec2 A vector signaling up. (0, -1)
static : Vec2 A vector signaling down. (0, 1)
()
=> Vec2 Clone the vector
(args: Vec2Args)
=> Vec2 Returns the addition with another vector.
(args: Vec2Args)
=> Vec2 Returns the subtraction with another vector.
(args: Vec2Args)
=> Vec2 Scale by another vector. or a single number
(args: Vec2Args)
=> number Get distance between another vector
(args: Vec2Args)
=> number Get squared distance between another vector
static (v: Vec2, other: Vec2)
=> number Calculates the squared distance between the vectors
param vThe vector
param otherThe other vector
returns The distance between the vectors
()
=> number Get length of the vector
()
=> number Get squared length of the vector
()
=> Vec2 Get the unit vector (length of 1).
()
=> Vec2 Get the perpendicular vector.
(normal: Vec2)
=> Vec2 Get the reflection of a vector with a normal.
(on: Vec2)
=> Vec2 Get the projection of a vector onto another vector.
(on: Vec2)
=> Vec2 Get the rejection of a vector onto another vector.
(p2: Vec2)
=> number Get the dot product with another vector.
static (v: Vec2, other: Vec2)
=> number Get the dot product between 2 vectors.
(p2: Vec2)
=> number Get the cross product with another vector.
static (v: Vec2, other: Vec2)
=> number Get the cross product between 2 vectors.
(args: Vec2Args)
=> number Get the angle of the vector in degrees.
(args: Vec2Args)
=> number Get the angle between this vector and another vector.
(dest: Vec2, t: number)
=> Vec2 Linear interpolate to a destination vector (for positions).
(dest: Vec2, t: number)
=> Vec2 Spherical linear interpolate to a destination vector (for rotations).
()
=> boolean If the vector (x, y) is zero.
(n: number)
=> Vec2 To n precision floating point.
(m: Mat4)
=> Vec2 Multiply by a Mat4.
(other: Vec2)
=> boolean See if one vector is equal to another.
()
=> Rect Converts the vector to a Rect with the vector as the origin.
()
=> Array<number> Converts the vector to an array.