Vector2Extension extension
- on
Methods
-
clampLength(
double min, double max) → void - Clamps the length of this vector.
-
invert(
) → void - Inverts the vector.
-
inverted(
) → Vector2 - Returns the inverse of this vector.
-
isIdentity(
) → bool - Whether the Vector2 is the identity vector or not
-
isZero(
) → bool - Whether the Vector2 is the zero vector or not
-
lerp(
Vector2 to, double t) → void - Linearly interpolate towards another Vector2
-
moveToTarget(
Vector2 target, double ds) → void -
Smoothly moves this Vector2 in the direction
target
by a displacement given by a distanceds
in that direction. -
projection(
Vector2 other, {Vector2? out}) → Vector2 -
Project this onto
other
. -
rotate(
double angle, {Vector2? center}) → void -
Rotates the Vector2 with
angle
in radians rotates aroundcenter
if it is defined In a screen coordinate system (where the y-axis is flipped) it rotates in a clockwise fashion In a normal coordinate system it rotates in a counter-clockwise fashion -
scaleTo(
double newLength) → void - Changes the length of the vector to the length provided, without changing direction.
-
screenAngle(
) → double - Signed angle in a coordinate system where the Y-axis is flipped.
-
taxicabDistanceTo(
Vector2 other) → double -
Distance to
other
vector, using the taxicab (L1) geometry. -
toOffset(
) → Offset - Creates an Offset from the Vector2
-
toPoint(
) → Point< num> - Creates a Point from the Vector2
-
toPositionedRect(
Vector2 size) → Rect - Creates a Rect starting from (x, y) and having the size of the argument Vector2
-
toRect(
) → Rect - Creates a Rect starting in origin and going the Vector2
-
toSize(
) → Size - Creates a Size from the Vector2
Operators
-
operator %(
Vector2 mod) → Vector2 - Modulo/Remainder
-
operator &(
Vector2 size) → Rect - A rectangle constructor operator.
Static Methods
-
fromDegrees(
double d) → Vector2 - Creates a heading Vector2 with the given angle in degrees.
-
fromInts(
int x, int y) → Vector2 - Create a Vector2 with ints as input
-
fromRadians(
double r) → Vector2 - Creates a heading Vector2 with the given angle in radians.
-
identity(
) → Vector2 - Creates a new identity Vector2 (1.0, 1.0).