Vector2Extension extension
Methods
-
clamp(Vector2 min, Vector2 max)
→ void
-
Clamps this vector so that it is within or equals to the bounds defined by
min
and max
.
-
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 distance ds
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 around center
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.
-
setAll(double value)
→ void
-
Sets both x and y to
value
.
-
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
-
toStringWithMaxPrecision(int maxPrecision)
→ String
-
Stringifies the Vector2 with a maximum precision of
maxPrecision
.
-
translate(double x, double y)
→ void
-
Translates this Vector2 by
x
and y
.
-
translated(double x, double y)
→ Vector2
-
Creates a new Vector2 that is the current Vector2 translated by
x
and y
.