public class VectorUtils
extends Object
Vector2f
s.Modifier and Type | Method and Description |
---|---|
static float |
getAngle(Vector2f from,
Vector2f to)
Returns the angle between two
Vector2f s. |
static float |
getCrossProduct(Vector2f vector1,
Vector2f vector2)
Returns the cross product of two
Vector2f s. |
static Vector2f |
getDirectionalVector(Vector2f source,
Vector2f destination)
Returns a normalized
Vector2f pointing from source to
destination . |
static float |
getFacing(Vector2f vector)
Returns the facing (angle) of a
Vector2f . |
static List<Vector2f> |
rotate(List<Vector2f> toRotate,
float angle)
Rotates a
List of Vector2f s by a specified amount. |
static Vector2f |
rotate(Vector2f toRotate,
float angle,
Vector2f dest)
Rotates a
Vector2f by a specified amount. |
static List<Vector2f> |
rotateAroundPivot(List<Vector2f> toRotate,
Vector2f pivotPoint,
float angle)
Rotates a
List of Vector2f s 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. |
public static float getFacing(Vector2f vector)
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.from
- The source Vector2f
.to
- The Vector2f
to get the angle to.
from
to to
.
public static Vector2f getDirectionalVector(Vector2f source, Vector2f destination)
Vector2f
pointing from source
to
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.vector1
- The first Vector2f
.vector2
- The second Vector2f
.
public static Vector2f rotate(Vector2f toRotate, float angle, Vector2f dest)
Vector2f
by a specified amount.toRotate
- The Vector2f
to rotate.angle
- How much to rotate toRotate
, in degrees.dest
- The destination Vector2f
. Can be
toRotate
.
toRotate
placed in dest
.
public static List<Vector2f> rotate(List<Vector2f> toRotate, float angle)
List
of Vector2f
s by a specified amount. Much
more efficient than rotating each point individually.toRotate
- The List
of Vector2f
s to rotate.angle
- How much to rotate toRotate
, in degrees.
List
of Vector2f
s that have been rotated.
public static Vector2f rotateAroundPivot(Vector2f toRotate, Vector2f pivotPoint, float angle, Vector2f dest)
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.dest
- The destination Vector2f
. Can be
toRotate
.
toRotate
placed in dest
.
public static List<Vector2f> rotateAroundPivot(List<Vector2f> toRotate, Vector2f pivotPoint, float angle)
List
of Vector2f
s by a specified amount around
a pivot point. Much more efficient than rotating each point individually.
toRotate
- The List
of Vector2f
s to rotate.pivotPoint
- The central point to pivot around.angle
- How much to rotate toRotate
, in degrees.
List
of Vector2f
s that have been rotated around
pivotPoint
.