|
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)
Returns the angle between two Vector2f s. |
static Vector2f |
getDirectionalVector(CombatEntityAPI source,
CombatEntityAPI destination)
Returns a normalized Vector2f pointing from source
to destination . |
static Vector2f |
getDirectionalVector(CombatEntityAPI source,
Vector2f destination)
Returns a normalized Vector2f pointing from source
to destination . |
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 radius. |
static float |
getDistance(CombatEntityAPI entity,
Vector2f vector)
Returns the distance between a CombatEntityAPI and a Vector2f (includes collision radius). |
static float |
getDistance(SectorEntityToken token1,
SectorEntityToken token2)
Returns the distance between two SectorEntityToken s. |
static float |
getDistance(SectorEntityToken token,
Vector2f vector)
Returns the distance between a SectorEntityToken and a Vector2f . |
static float |
getDistance(Vector2f vector1,
Vector2f vector2)
Returns the distance between two Vector2f s. |
static float |
getDistanceSquared(CombatEntityAPI obj1,
CombatEntityAPI obj2)
Deprecated. Use getDistance(com.fs.starfarer.api.combat.CombatEntityAPI,
com.fs.starfarer.api.combat.CombatEntityAPI) instead. With the addition
of collision radius checking, there's no way to avoid calculating the
square root. |
static float |
getDistanceSquared(CombatEntityAPI entity,
Vector2f vector)
Deprecated. Use getDistance(com.fs.starfarer.api.combat.CombatEntityAPI,
org.lwjgl.util.vector.Vector2f) instead. With the addition of collision
radius checking, there's no way to avoid calculating the square root. |
static float |
getDistanceSquared(SectorEntityToken token1,
SectorEntityToken token2)
Returns the distance squared between two SectorEntityToken s. |
static float |
getDistanceSquared(SectorEntityToken token,
Vector2f vector)
Returns the distance squared between a SectorEntityToken and
a Vector2f . |
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)
Returns the facing of a Vector2f . |
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 |
getRandomPointOnCircumference(Vector2f center,
float radius)
Returns a random point along the circumference of a circle. |
static boolean |
isPointWithinBounds(Vector2f point,
CombatEntityAPI entity)
Deprecated. Use CollisionUtils.isPointWithinBounds(org.lwjgl.util.vector.Vector2f,
com.fs.starfarer.api.combat.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.
getDistance(org.lwjgl.util.vector.Vector2f, org.lwjgl.util.vector.Vector2f)
public static float getDistance(SectorEntityToken token, Vector2f vector)
SectorEntityToken
and a Vector2f
.
getDistance(org.lwjgl.util.vector.Vector2f, org.lwjgl.util.vector.Vector2f)
public static float getDistance(CombatEntityAPI obj1, CombatEntityAPI obj2)
CombatEntityAPI
s, including collision radius.
getDistance(org.lwjgl.util.vector.Vector2f, org.lwjgl.util.vector.Vector2f)
public static float getDistance(CombatEntityAPI entity, Vector2f vector)
CombatEntityAPI
and a Vector2f
(includes collision radius).
getDistance(org.lwjgl.util.vector.Vector2f, org.lwjgl.util.vector.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.
getDistanceSquared(org.lwjgl.util.vector.Vector2f,
org.lwjgl.util.vector.Vector2f)
public static float getDistanceSquared(SectorEntityToken token, Vector2f vector)
SectorEntityToken
and
a Vector2f
.
getDistanceSquared(org.lwjgl.util.vector.Vector2f,
org.lwjgl.util.vector.Vector2f)
@Deprecated public static float getDistanceSquared(CombatEntityAPI obj1, CombatEntityAPI obj2)
getDistance(com.fs.starfarer.api.combat.CombatEntityAPI,
com.fs.starfarer.api.combat.CombatEntityAPI)
instead. With the addition
of collision radius checking, there's no way to avoid calculating the
square root.
CombatEntityAPI
s
(includes collision radii).
getDistanceSquared(org.lwjgl.util.vector.Vector2f,
org.lwjgl.util.vector.Vector2f)
@Deprecated public static float getDistanceSquared(CombatEntityAPI entity, Vector2f vector)
getDistance(com.fs.starfarer.api.combat.CombatEntityAPI,
org.lwjgl.util.vector.Vector2f)
instead. With the addition of collision
radius checking, there's no way to avoid calculating the square root.
CombatEntityAPI
and a
Vector2f
(includes collision radius).
getDistanceSquared(org.lwjgl.util.vector.Vector2f,
org.lwjgl.util.vector.Vector2f)
public static float getDistanceSquared(Vector2f vector1, Vector2f vector2)
Vector2f
s (avoids a costly sqrt()).
When comparing distances, use this function instead of
getDistance(org.lwjgl.util.vector.Vector2f,
org.lwjgl.util.vector.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 Vector2f getDirectionalVector(CombatEntityAPI source, Vector2f destination)
Vector2f
pointing from source
to destination
.
getDirectionalVector(org.lwjgl.util.vector.Vector2f,
org.lwjgl.util.vector.Vector2f)
public static Vector2f getDirectionalVector(CombatEntityAPI source, CombatEntityAPI destination)
Vector2f
pointing from source
to destination
.
getDirectionalVector(org.lwjgl.util.vector.Vector2f,
org.lwjgl.util.vector.Vector2f)
public static float clampAngle(float angle)
angle
- The angle to be clamped.
public static float getFacing(Vector2f vector)
Vector2f
.
vector
- The vector to get the facing of.
vector
.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 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(org.lwjgl.util.vector.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 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 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 boolean isPointWithinBounds(Vector2f point, CombatEntityAPI entity)
CollisionUtils.isPointWithinBounds(org.lwjgl.util.vector.Vector2f,
com.fs.starfarer.api.combat.CombatEntityAPI)
instead.
|
LazyLib | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |