Modifier and Type | Method and Description |
---|---|
static Vector2f |
clampLength(Vector2f toClamp,
float maxLength)
Reduces a vector's length if it is higher than the passed in argument.
|
static Vector2f |
clampLength(Vector2f toClamp,
float minLength,
float maxLength)
Ensures a vector's length is within the given parameters and stores the result in a destination vector.
|
static Vector2f |
clampLength(Vector2f toClamp,
float minLength,
float maxLength,
Vector2f dest)
Ensures a vector's length is within the given parameters and stores the result in a destination vector.
|
static Vector2f |
clampLength(Vector2f toClamp,
float maxLength,
Vector2f dest)
Reduces a vector's length if it is higher than the passed in argument and stores the result in a destination
vector.
|
static float |
getAngle(Vector2f from,
Vector2f to)
Returns the angle between two
Vector2f s in degrees. |
static float |
getAngleStrict(Vector2f from,
Vector2f to)
Returns the angle between two
Vector2f s in degrees. |
static float |
getCrossProduct(Vector2f vector1,
Vector2f vector2)
Returns the cross product of two
Vector2f s. |
static Vector2f |
getDirectionalVector(Vector2f source,
Vector2f destination)
|
static float |
getFacing(Vector2f vector)
Returns the facing (angle) of a
Vector2f in degrees. |
static float |
getFacingStrict(Vector2f vector)
Returns the facing (angle) of a
Vector2f in degrees. |
static boolean |
isZeroVector(Vector2f vector)
Tests whether a vector is a zero vector (coordinates of {0, 0}).
|
static Vector2f |
resize(Vector2f vector,
float length)
Scales a vector to the requested length.
|
static Vector2f |
resize(Vector2f vector,
float length,
Vector2f dest)
Scales a vector to the requested length and stores the result in a destination vector.
|
static List<Vector2f> |
rotate(List<Vector2f> toRotate,
float angle)
|
static Vector2f |
rotate(Vector2f toRotate,
float angle)
Rotates a
Vector2f by a specified amount. |
static Vector2f |
rotate(Vector2f toRotate,
float angle,
Vector2f dest)
Rotates a
Vector2f by a specified amount and stores the result in a destination vector. |
static List<Vector2f> |
rotateAroundPivot(List<Vector2f> toRotate,
Vector2f pivotPoint,
float angle)
|
static Vector2f |
rotateAroundPivot(Vector2f toRotate,
Vector2f pivotPoint,
float angle)
Rotates a
Vector2f by a specified amount around a pivot point. |
static Vector2f |
rotateAroundPivot(Vector2f toRotate,
Vector2f pivotPoint,
float angle,
Vector2f dest)
Rotates a
Vector2f by a specified amount around a pivot point and stores the result in a destination
vector. |
public static float getFacing(Vector2f vector)
Vector2f
in degrees. Accurate to within ~0.29 degrees. If you need
more accuracy, use getFacingStrict(Vector2f)
.vector
- The vector to get the facing of.vector
in degrees, or 0 if the
vector has no length.getFacingStrict(Vector2f)
public static float getFacingStrict(Vector2f vector)
Vector2f
in degrees. This method uses the slower but more accurate
behavior of pre-2.3 getFacing(Vector2f)
.vector
- The vector to get the facing of.vector
in degrees, or 0 if the vector has no length.public static float getAngle(Vector2f from, Vector2f to)
Vector2f
s in degrees. Accurate to within ~0.29 degrees. If you need
more accuracy, use getAngleStrict(Vector2f, Vector2f)
.from
- The source Vector2f
.to
- The Vector2f
to get the angle to.from
to to
, in degrees.getAngleStrict(Vector2f, Vector2f)
public static float getAngleStrict(Vector2f from, Vector2f to)
Vector2f
s in degrees. This method uses the slower but more accurate
behavior of pre-2.3 getAngle(Vector2f, Vector2f)
.public static Vector2f getDirectionalVector(Vector2f source, Vector2f destination)
source
- The origin of the vector.destination
- The location to point at.Vector2f
pointing at destination
.public static float getCrossProduct(Vector2f vector1, Vector2f vector2)
Vector2f
s.public static boolean isZeroVector(Vector2f vector)
vector
- The vector to test.true
if both of vector
's coordinates are 0, false
otherwise.public static Vector2f resize(Vector2f vector, float length, Vector2f dest)
vector
- The vector to be resized. Will not be modified; instead the result will be placed in dest
.length
- The new total length of the destination vector.dest
- The destination Vector2f
. Can be vector
.dest
, scaled based on vector
, returned for easier chaining of methods.public static Vector2f resize(Vector2f vector, float length)
vector
- The vector to be modified.length
- The new total length of vector
.vector
, returned for easier chaining of methods.resize(Vector2f, float, Vector2f)
public static Vector2f clampLength(Vector2f toClamp, float maxLength, Vector2f dest)
toClamp
- The vector whose length should be clamped. Will not be modified; instead the result will be
placed in dest
.maxLength
- The maximum length of the destination vector. If its current length is higher, it will be
reduced to this amount.dest
- The destination Vector2f
. Can be toClamp
.dest
, clamped based on toClamp
, returned for easier chaining of methods.public static Vector2f clampLength(Vector2f toClamp, float maxLength)
toClamp
- The vector whose length should be clamped.maxLength
- The maximum length of toClamp
. If its current length is higher, it will be reduced to
this amount.toClamp
, returned for easier chaining of methods.clampLength(Vector2f, float, Vector2f)
public static Vector2f clampLength(Vector2f toClamp, float minLength, float maxLength, Vector2f dest)
toClamp
- The vector whose length should be clamped. Will not be modified; instead the result will be
placed in dest
.minLength
- The minimum length of the destination vector. If its current length is lower, it will be
increased to this amount.maxLength
- The maximum length of the destination vector. If its current length is higher, it will be
reduced to this amount.dest
- The destination Vector2f
. Can be toClamp
.dest
, clamped based on toClamp
, returned for easier chaining of methods.public static Vector2f clampLength(Vector2f toClamp, float minLength, float maxLength)
toClamp
- The vector whose length should be clamped. Will not be modified; instead the result will be
placed in dest
.minLength
- The minimum length of toClamp
. If its current length is lower, it will be increased to
this amount.maxLength
- The maximum length of toClamp
. If its current length is higher, it will be reduced to
this amount.toClamp
, returned for easier chaining of methods.clampLength(Vector2f, float, float, Vector2f)
public static Vector2f rotate(Vector2f toRotate, float angle, Vector2f dest)
Vector2f
by a specified amount and stores the result in a destination vector.toRotate
- The Vector2f
to rotate. Will not be modified; instead the result will be placed in dest
.angle
- How much to rotate the destination vector, in degrees.dest
- The destination Vector2f
. Can be toRotate
.dest
, rotated based on toRotate
, returned for easier chaining of methods.public static Vector2f rotate(Vector2f toRotate, float angle)
Vector2f
by a specified amount.toRotate
- The Vector2f
to rotate.angle
- How much to rotate toRotate
, in degrees.toRotate
, returned for easier chaining of methods.rotate(Vector2f, float, Vector2f)
public static Vector2f rotateAroundPivot(Vector2f toRotate, Vector2f pivotPoint, float angle, Vector2f dest)
Vector2f
by a specified amount around a pivot point and stores the result in a destination
vector.toRotate
- The Vector2f
to rotate. Will not be modified; instead the result will be placed in
dest
.pivotPoint
- The central point to pivot around.angle
- How much to rotate the destination vector, in degrees.dest
- The destination Vector2f
. Can be toRotate
.dest
, rotated based on toRotate
around pivotPoint
, returned for easier chaining
of methods.public static Vector2f rotateAroundPivot(Vector2f toRotate, Vector2f pivotPoint, float angle)
Vector2f
by a specified amount around a pivot point.toRotate
- The Vector2f
to rotate.pivotPoint
- The central point to pivot around.angle
- How much to rotate toRotate
, in degrees.toRotate
, returned for easier chaining of methods.rotateAroundPivot(Vector2f, Vector2f, float, Vector2f)