Degrees relativ to X axis.
Length.
Squared length.
Get greater of x
or y
.
Get lesser of x
or y
.
Radians relativ to X axis.
Set both x
and y
.
Add components.
Optional
y: numberSelf
Ceil all components.
Self
Clamp all components.
Min
Max
Self
Clamp x and y separately.
Min X
Min Y
Max X
Max Y
Self
Copy components into a typed array.
Typed array
Element offset
Cross product.
Optional
y: numberCross product
Get angle between this and (x
, y
) from origin.
Optional
y: numberAngle in degrees
Get angle of the vector between this and (x
, y
).
Optional
y: numberAngle in degrees
Divide by components.
Optional
y: numberMake this vector the result of (x
, y
) / this vector.
Optional
y: numberSelf
Dot product.
Optional
y: numberDot product.
Check equality of components.
Tolerance
true
if equal within tolerance
Check equality of vectors.
Optional
epsilon: numberTolerance
true
if equal within tolerance
Floor all components.
Self
Make all components absolute.
Self
Make this vector the direction vector between this and (x
, y
).
Optional
y: numberSelf
Multiply components.
Optional
y: numberSelf
Normalize.
Self
Project this vector onto the vector defined by x
and y
.
X
Optional
y: numberY
Self
Get angle between this and (x
, y
) from origin.
Optional
y: numberAngle in radians
Get angle of the vector between this and (x
, y
).
Optional
y: numberAngle in radians
Rotate this vector around a point.
Amount to rotate in degrees
Optional
cx: numberCenter x
Optional
cy: numberCenter y
Self
Rotate this vector around a point.
Amount to rotate in radians
Center
Self
Rotate this vector around a point.
Amount to rotate in radians
Optional
cx: numberCenter x
Optional
cy: numberCenter y
Self
Rotate this vector around a point.
Amount to rotate in radians
Center
Self
Round all components.
Self
Set components.
X value
Optional
y: numberY value, uses x
if omitted
Self
Subtract components.
Optional
y: numberSelf
Make this vector the result of (x
, y
) - this vector.
Optional
y: numberSelf
Returns a string representation of an object.
Static
fromStatic
oneStatic
zero
Two-dimensional vector (point).
Methods (like Vec2.multiply, Vec2.add) generally mutate the instance. Create new instances with Vec2.clone.