Vec2
:A 2D vector.
group
Math
x
: numberThe x coordinate
y
: numberThe y coordinate
fromAngle
(deg: number) => Vec2Create a new Vec2 from an angle in degrees
fromArray
(arr: Array<number>) => Vec2Create a new Vec2 from an array
ZERO
: Vec2An empty vector. (0, 0)
ONE
: Vec2A vector with both components of 1. (1, 1)
LEFT
: Vec2A vector signaling to the left. (-1, 0)
RIGHT
: Vec2A vector signaling to the right. (1, 0)
UP
: Vec2A vector signaling up. (0, -1)
DOWN
: Vec2A vector signaling down. (0, 1)
clone
() => Vec2Clone the vector
add
(args: Vec2Args) => Vec2Returns the addition with another vector.
sub
(args: Vec2Args) => Vec2Returns the subtraction with another vector.
scale
(args: Vec2Args) => Vec2Scale by another vector. or a single number
dist
(args: Vec2Args) => numberGet distance between another vector
sdist
(args: Vec2Args) => numberGet squared distance between another vector
sdist
(v: Vec2, other: Vec2) => numberCalculates the squared distance between the vectors
param
vThe vector
param
otherThe other vector
returns
The distance between the vectors
len
() => numberGet length of the vector
since
v3000.0
slen
() => numberGet squared length of the vector
since
v3000.0
unit
() => Vec2Get the unit vector (length of 1).
normal
() => Vec2Get the perpendicular vector.
reflect
(normal: Vec2) => Vec2Get the reflection of a vector with a normal.
since
v3000.0
project
(on: Vec2) => Vec2Get the projection of a vector onto another vector.
since
v3000.0
reject
(on: Vec2) => Vec2Get the rejection of a vector onto another vector.
since
v3000.0
dot
(p2: Vec2) => numberGet the dot product with another vector.
dot
(v: Vec2, other: Vec2) => numberGet the dot product between 2 vectors.
since
v3000.0
cross
(p2: Vec2) => numberGet the cross product with another vector.
since
v3000.0
cross
(v: Vec2, other: Vec2) => numberGet the cross product between 2 vectors.
since
v3000.0
angle
(args: Vec2Args) => numberGet the angle of the vector in degrees.
angleBetween
(args: Vec2Args) => numberGet the angle between this vector and another vector.
since
v3000.0
lerp
(dest: Vec2, t: number) => Vec2Linear interpolate to a destination vector (for positions).
slerp
(dest: Vec2, t: number) => Vec2Spherical linear interpolate to a destination vector (for rotations).
since
v3000.0
isZero
() => booleanIf the vector (x, y) is zero.
since
v3000.0
toFixed
(n: number) => Vec2To n precision floating point.
transform
(m: Mat4) => Vec2Multiply by a Mat4.
since
v3000.0
eq
(other: Vec2) => booleanSee if one vector is equal to another.
since
v3000.0
bbox
() => RectConverts the vector to a Rect with the vector as the origin.
since
v3000.0.
toArray
() => Array<number>Converts the vector to an array.
since
v3001.0