|
LazyLib | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectMathUtils
public class MathUtils
Contains methods for working with vectors, angles, distances, and circles.
Method Summary | |
---|---|
static float |
clampAngle(float angle)
Clamps an angle within 360 degrees (ex: 400 degrees becomes 40 degrees). |
static boolean |
equals(float a,
float b)
Tests for near-equality of floating point numbers. |
static float |
getAngle(Vector2f from,
Vector2f to)
Deprecated. Use VectorUtils.getAngle(Vector2f, Vector2f) instead. |
static Vector2f |
getDirectionalVector(CombatEntityAPI source,
CombatEntityAPI destination)
Deprecated. Use getDirectionalVector(Vector2f, Vector2f) instead. |
static Vector2f |
getDirectionalVector(CombatEntityAPI source,
Vector2f destination)
Deprecated. Use getDirectionalVector(Vector2f, Vector2f) instead. |
static Vector2f |
getDirectionalVector(Vector2f source,
Vector2f destination)
Returns a normalized Vector2f pointing from source to
destination . |
static float |
getDistance(CombatEntityAPI obj1,
CombatEntityAPI obj2)
Returns the distance between two CombatEntityAPI s, including
collision radii. |
static float |
getDistance(CombatEntityAPI entity,
Vector2f vector)
Returns the distance between a CombatEntityAPI and a
Vector2f , including collision radius. |
static float |
getDistance(SectorEntityToken token1,
SectorEntityToken token2)
Returns the distance between two SectorEntityToken s,
including interaction radii. |
static float |
getDistance(SectorEntityToken token,
Vector2f vector)
Returns the distance between a SectorEntityToken and a
Vector2f , including interaction radius. |
static float |
getDistance(Vector2f vector1,
Vector2f vector2)
Returns the distance between two Vector2f s. |
static float |
getDistanceSquared(CombatEntityAPI obj1,
CombatEntityAPI obj2)
Returns the distance squared between two CombatEntityAPI s,
including collision radii. |
static float |
getDistanceSquared(CombatEntityAPI entity,
Vector2f vector)
Returns the distance squared between a CombatEntityAPI and a
Vector2f (includes collision radius). |
static float |
getDistanceSquared(SectorEntityToken token1,
SectorEntityToken token2)
Returns the distance squared between two SectorEntityToken s,
including interaction radii. |
static float |
getDistanceSquared(SectorEntityToken token,
Vector2f vector)
Returns the distance squared between a SectorEntityToken and
a Vector2f , including interaction radius. |
static float |
getDistanceSquared(Vector2f vector1,
Vector2f vector2)
Returns the distance squared between two Vector2f s (avoids a
costly sqrt()). |
static List<Vector2f> |
getEquidistantPointsInsideCircle(Vector2f center,
float radius,
float spaceBetweenPoints)
Returns a List of evenly spaced Vector2f s inside a
circle. |
static float |
getFacing(Vector2f vector)
Deprecated. Use VectorUtils.getFacing(Vector2f) instead. |
static Vector2f |
getPointOnCircumference(Vector2f center,
float radius,
float angle)
Returns a point along the circumference of a circle at the given angle. |
static List<Vector2f> |
getPointsAlongCircumference(Vector2f center,
float radius,
int numPoints,
float angleOffset)
Returns an evenly distributed List of points along a circle's
circumference. |
static Random |
getRandom()
Returns the random number generator used by LazyLib's methods. |
static float |
getRandomNumberInRange(float min,
float max)
Returns a random number within a given range. |
static Vector2f |
getRandomPointInCircle(Vector2f center,
float radius)
Returns a random point inside of a circle with uniform distribution. |
static Vector2f |
getRandomPointInCone(Vector2f center,
float radius,
float minAngle,
float maxAngle)
Returns a random point inside of a circular sector (2d cone) with uniform distribution. |
static Vector2f |
getRandomPointOnCircumference(Vector2f center,
float radius)
Returns a random point along the circumference of a circle. |
static Vector2f |
getRandomPointOnLine(Vector2f lineStart,
Vector2f lineEnd)
Returns a random point along the line between two Vector2f s. |
static float |
getShortestRotation(float currAngle,
float destAngle)
Returns the direction and length of the quickest rotation between two angles. |
static boolean |
isPointOnLine(Vector2f point,
Vector2f lineStart,
Vector2f lineEnd)
Check if a point is along the line between two Vector2f s. |
static boolean |
isPointWithinBounds(Vector2f point,
CombatEntityAPI entity)
Deprecated. Use CollisionUtils.isPointWithinBounds(Vector2f, CombatEntityAPI) instead. |
static boolean |
isPointWithinCircle(Vector2f point,
Vector2f center,
float radius)
Returns whether a point is within the bounds of a circle or not. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static float getDistance(SectorEntityToken token1, SectorEntityToken token2)
SectorEntityToken
s,
including interaction radii.
getDistance(Vector2f, Vector2f)
public static float getDistance(SectorEntityToken token, Vector2f vector)
SectorEntityToken
and a
Vector2f
, including interaction radius.
getDistance(Vector2f, Vector2f)
public static float getDistance(CombatEntityAPI obj1, CombatEntityAPI obj2)
CombatEntityAPI
s, including
collision radii.
getDistance(Vector2f, Vector2f)
public static float getDistance(CombatEntityAPI entity, Vector2f vector)
CombatEntityAPI
and a
Vector2f
, including collision radius.
getDistance(Vector2f, Vector2f)
public static float getDistance(Vector2f vector1, Vector2f vector2)
Vector2f
s.
For comparing distances, it is vastly more efficient to use
getDistanceSquared(org.lwjgl.util.vector.Vector2f,
org.lwjgl.util.vector.Vector2f)
.
public static float getDistanceSquared(SectorEntityToken token1, SectorEntityToken token2)
SectorEntityToken
s,
including interaction radii.
With the addition of collision radius checking, there's no way to avoid
calculating the square root.
getDistance(SectorEntityToken, SectorEntityToken)
will be just as efficient.
getDistanceSquared(Vector2f, Vector2f)
public static float getDistanceSquared(SectorEntityToken token, Vector2f vector)
SectorEntityToken
and
a Vector2f
, including interaction radius.
With the addition of collision radius checking, there's no way to avoid
calculating the square root.
getDistance(SectorEntityToken, Vector2f)
will be just
as efficient.
getDistanceSquared(Vector2f, Vector2f)
public static float getDistanceSquared(CombatEntityAPI obj1, CombatEntityAPI obj2)
CombatEntityAPI
s,
including collision radii.
With the addition of collision radius checking, there's no way to avoid
calculating the square root.
getDistance(CombatEntityAPI, CombatEntityAPI)
will be
just as efficient.
getDistanceSquared(Vector2f, Vector2f)
public static float getDistanceSquared(CombatEntityAPI entity, Vector2f vector)
CombatEntityAPI
and a
Vector2f
(includes collision radius).
With the addition of collision radius checking, there's no way to avoid
calculating the square root.
getDistance(CombatEntityAPI, Vector2f)
will be just
as efficient.
getDistanceSquared(Vector2f, Vector2f)
public static float getDistanceSquared(Vector2f vector1, Vector2f vector2)
Vector2f
s (avoids a
costly sqrt()).
When comparing distances, use this function instead of
getDistance(Vector2f, Vector2f)
.
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 clampAngle(float angle)
angle
- The angle to be clamped.
public static float getShortestRotation(float currAngle, float destAngle)
currAngle
- The current facing.destAngle
- The facing to rotate towards.
public static Vector2f getPointOnCircumference(Vector2f center, float radius, float angle)
center
- The center point of the circle (can be null for a 0, 0
origin).radius
- The radius of the circle.angle
- The angle, in degrees, to get the point at.
Vector2f
at [@code angle} degrees along the
circumference of the given circle.
public static Vector2f getRandomPointOnCircumference(Vector2f center, float radius)
center
- The center point of the circle (can be null for a 0, 0
origin).radius
- The radius of the circle.
getPointOnCircumference(Vector2f, float, float)
public static Vector2f getRandomPointInCircle(Vector2f center, float radius)
center
- The center point of the circle (can be null for a 0, 0
origin).radius
- The radius of the circle.
public static Vector2f getRandomPointInCone(Vector2f center, float radius, float minAngle, float maxAngle)
center
- The center point of the cone (can be null for a 0, 0
origin).radius
- The radius of the cone.minAngle
- The minimum angular bounds.maxAngle
- The maximum angular bounds.
public static Vector2f getRandomPointOnLine(Vector2f lineStart, Vector2f lineEnd)
Vector2f
s.
lineStart
- The starting point of the line.lineEnd
- The end point of the line.
Vector2f
along the line between
lineStart
and lineEnd
.
public static List<Vector2f> getPointsAlongCircumference(Vector2f center, float radius, int numPoints, float angleOffset)
List
of points along a circle's
circumference.
center
- The center point of the circle (can be null for a 0, 0
origin).radius
- The radius of the circle.numPoints
- How many points to generate.angleOffset
- The offset angle of the initial point.
List
of Vector2f
s that are evenly distributed
along the circle's circumference.
public static boolean isPointWithinCircle(Vector2f point, Vector2f center, float radius)
point
- The Vector2f
to check.center
- The center point of the circle (can be null for a 0, 0
origin).radius
- The radius of the circle.
true
if point
is within the circle,
false
otherwise.
public static boolean isPointOnLine(Vector2f point, Vector2f lineStart, Vector2f lineEnd)
Vector2f
s.
point
- The point to check.lineStart
- The starting point of the line.lineEnd
- The end point of the line.
true
if the point is along the line, false
otherwise.
public static List<Vector2f> getEquidistantPointsInsideCircle(Vector2f center, float radius, float spaceBetweenPoints)
List
of evenly spaced Vector2f
s inside a
circle.
WARNING: be VERY conservative using this method - a radius of 250 and a
spacing
of 5 will result in 10,000 circle checks and 7,825 Vector2f
s
created!
center
- The center point of the circle (can be null for
a 0, 0 origin).radius
- The radius of the circle.spaceBetweenPoints
- How much space should be between each point.
List
of evenly spaced Vector2f
s inside a
circle.
public static float getRandomNumberInRange(float min, float max)
min
- The minimum value to select.max
- The maximum value to select.
Float
between min
and max
.
public static boolean equals(float a, float b)
a
- The first float to compare.b
- The second float to compare.
true
if a
and b
are within 99.99999%
of each other, false
otherwise.public static Random getRandom()
Random
instance used by LazyLib.
@Deprecated public static float getFacing(Vector2f vector)
VectorUtils.getFacing(Vector2f)
instead.
public static float getAngle(Vector2f from, Vector2f to)
VectorUtils.getAngle(Vector2f, Vector2f)
instead.
@Deprecated public static Vector2f getDirectionalVector(CombatEntityAPI source, Vector2f destination)
getDirectionalVector(Vector2f, Vector2f)
instead.
@Deprecated public static Vector2f getDirectionalVector(CombatEntityAPI source, CombatEntityAPI destination)
getDirectionalVector(Vector2f, Vector2f)
instead.
@Deprecated public static boolean isPointWithinBounds(Vector2f point, CombatEntityAPI entity)
CollisionUtils.isPointWithinBounds(Vector2f, CombatEntityAPI)
instead.
|
LazyLib | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |