public final class FXGLMath extends Object
| Modifier and Type | Field and Description |
|---|---|
static float |
degRad |
static float |
degreesToRadians
multiply by this to convert from degrees to radians
|
static float |
E |
static float |
EPSILON
A "close to zero" float epsilon value for use.
|
static float |
FLOAT_ROUNDING_ERROR |
static float |
nanoToSec |
static float |
PI |
static float |
PI2 |
static float |
radDeg |
static float |
radiansToDegrees
multiply by this to convert from radians to degrees
|
| Modifier and Type | Method and Description |
|---|---|
static float |
abs(float value) |
static double |
atan2(double y,
double x)
Average error of 0.00231 radians (0.1323 degrees),
largest error of 0.00488 radians (0.2796 degrees).
|
static float |
atan2(float y,
float x)
Average error of 0.00231 radians (0.1323 degrees),
largest error of 0.00488 radians (0.2796 degrees).
|
static javafx.geometry.Point2D |
bezier(javafx.geometry.Point2D p1,
javafx.geometry.Point2D p2,
javafx.geometry.Point2D p3,
double t) |
static javafx.geometry.Point2D |
bezier(javafx.geometry.Point2D p1,
javafx.geometry.Point2D p2,
javafx.geometry.Point2D p3,
javafx.geometry.Point2D p4,
double t) |
static int |
ceil(float value) |
static int |
ceilPositive(float value) |
static double |
clamp(double value,
double min,
double max) |
static float |
clamp(float value,
float min,
float max) |
static int |
clamp(int value,
int min,
int max) |
static long |
clamp(long value,
long min,
long max) |
static short |
clamp(short value,
short min,
short max) |
static BezierSpline |
closedBezierSpline(Vec2[] points) |
static float |
cos(float radians) |
static float |
cosDeg(float degrees) |
static int |
floor(float value) |
static int |
floorPositive(float value)
Note: this method simply casts the float to int.
|
static Random |
getRandom() |
static double |
interpolate(double fromValue,
double toValue,
double progress,
javafx.animation.Interpolator interpolator) |
static javafx.geometry.Point2D |
interpolate(javafx.geometry.Point2D fromValue,
javafx.geometry.Point2D toValue,
double progress,
javafx.animation.Interpolator interpolator) |
static boolean |
isEqual(float a,
float b) |
static boolean |
isEqual(float a,
float b,
float tolerance) |
static boolean |
isPowerOfTwo(int value) |
static boolean |
isZero(float value) |
static boolean |
isZero(float value,
float tolerance) |
static double |
lerp(double fromValue,
double toValue,
double progress) |
static javafx.geometry.Point2D |
lerp(double fromX,
double fromY,
double toX,
double toY,
double progress) |
static float |
lerpAngle(float fromRadians,
float toRadians,
float progress)
Linearly interpolates between two angles in radians.
|
static float |
lerpAngleDeg(float fromDegrees,
float toDegrees,
float progress)
Linearly interpolates between two angles in degrees.
|
static float |
log(float base,
float value) |
static float |
log2(float value) |
static double |
map(double value,
double currentRangeStart,
double currentRangeStop,
double targetRangeStart,
double targetRangeStop)
Map value of a given range to a target range.
|
static int |
nextPowerOfTwo(int value) |
static float |
noise1D(double t) |
static float |
random() |
static float |
random(float range) |
static float |
random(float start,
float end) |
static int |
random(int range) |
static int |
random(int start,
int end) |
static <T> T |
random(List<T> list) |
static long |
random(long range) |
static long |
random(long start,
long end) |
static <T> T |
random(T[] array) |
static boolean |
randomBoolean() |
static boolean |
randomBoolean(float chance) |
static javafx.scene.paint.Color |
randomColor() |
static javafx.geometry.Point2D |
randomPoint2D() |
static int |
randomSign() |
static float |
randomTriangular()
This is an optimized version of
randomTriangular(-1, 1, 0). |
static float |
randomTriangular(float max)
This is an optimized version of
randomTriangular(-max, max, 0). |
static float |
randomTriangular(float min,
float max)
This method is equivalent of
randomTriangular(min, max, (min + max) * .5f). |
static float |
randomTriangular(float min,
float max,
float mode) |
static Vec2 |
randomVec2() |
static int |
round(float value) |
static int |
roundPositive(float value) |
static float |
sin(float radians) |
static float |
sinDeg(float degrees) |
static float |
sqrt(float x) |
public static final float nanoToSec
public static final float EPSILON
public static final float FLOAT_ROUNDING_ERROR
public static final float PI
public static final float PI2
public static final float E
public static final float radiansToDegrees
public static final float radDeg
public static final float degreesToRadians
public static final float degRad
public static float sin(float radians)
radians - angle in radianspublic static float cos(float radians)
radians - angle in radianspublic static float sinDeg(float degrees)
degrees - angle in degreespublic static float cosDeg(float degrees)
degrees - angle in degreespublic static float atan2(float y,
float x)
y - y componentx - x componentpublic static double atan2(double y,
double x)
y - y componentx - x componentpublic static Random getRandom()
public static int random(int range)
range - the end inclusive valuepublic static int random(int start,
int end)
start - start valueend - end valuepublic static long random(long range)
range - the end inclusive valuepublic static long random(long start,
long end)
start - start valueend - end valuepublic static boolean randomBoolean()
public static boolean randomBoolean(float chance)
chance - chance to checkpublic static float random()
public static float random(float range)
range - end exclusive valuepublic static float random(float start,
float end)
start - start inclusive valueend - end exclusive valuepublic static int randomSign()
public static float randomTriangular()
randomTriangular(-1, 1, 0).public static float randomTriangular(float max)
randomTriangular(-max, max, 0).max - the upper limit-max (exclusive) and max (exclusive),
where values around zero are more likelypublic static float randomTriangular(float min,
float max)
randomTriangular(min, max, (min + max) * .5f).min - the lower limitmax - the upper limitmin (inclusive) and max (exclusive),
where the mode argument defaults to the midpoint between the bounds, giving a symmetric distributionpublic static float randomTriangular(float min,
float max,
float mode)
min - the lower limitmax - the upper limitmode - the point around which the values are more likelymin (inclusive) and max (exclusive),
where values around mode are more likelypublic static Vec2 randomVec2()
public static javafx.geometry.Point2D randomPoint2D()
public static javafx.scene.paint.Color randomColor()
public static <T> T random(T[] array)
public static <T> T random(List<T> list)
public static float sqrt(float x)
public static int nextPowerOfTwo(int value)
value - the valuepublic static boolean isPowerOfTwo(int value)
value - the value to checkpublic static short clamp(short value,
short min,
short max)
public static int clamp(int value,
int min,
int max)
public static long clamp(long value,
long min,
long max)
public static float clamp(float value,
float min,
float max)
public static double clamp(double value,
double min,
double max)
public static double map(double value,
double currentRangeStart,
double currentRangeStop,
double targetRangeStart,
double targetRangeStop)
value - the value to mappublic static double lerp(double fromValue,
double toValue,
double progress)
fromValue - start valuetoValue - end valueprogress - the interpolation progress [0..1]public static javafx.geometry.Point2D lerp(double fromX,
double fromY,
double toX,
double toY,
double progress)
public static double interpolate(double fromValue,
double toValue,
double progress,
javafx.animation.Interpolator interpolator)
public static javafx.geometry.Point2D interpolate(javafx.geometry.Point2D fromValue,
javafx.geometry.Point2D toValue,
double progress,
javafx.animation.Interpolator interpolator)
public static float lerpAngle(float fromRadians,
float toRadians,
float progress)
fromRadians - start angle in radianstoRadians - target angle in radiansprogress - interpolation value in the range [0, 1]public static float lerpAngleDeg(float fromDegrees,
float toDegrees,
float progress)
fromDegrees - start angle in degreestoDegrees - target angle in degreesprogress - interpolation value in the range [0, 1]public static float abs(float value)
public static int floor(float value)
value - from -(2^14) to (Float.MAX_VALUE - 2^14)public static int floorPositive(float value)
value - a positive valuepublic static int ceil(float value)
value - from -(2^14) to (Float.MAX_VALUE - 2^14)public static int ceilPositive(float value)
value - a positive floatpublic static int round(float value)
value - from -(2^14) to (Float.MAX_VALUE - 2^14)public static int roundPositive(float value)
value - a positive floatpublic static boolean isZero(float value)
value - the value to checkpublic static boolean isZero(float value,
float tolerance)
value - the value to checktolerance - represent an upper bound below which the value is considered zeropublic static boolean isEqual(float a,
float b)
a - the first valueb - the second valuepublic static boolean isEqual(float a,
float b,
float tolerance)
a - the first valueb - the second valuetolerance - represent an upper bound below which the two values are considered equalpublic static float log(float base,
float value)
base - the basevalue - the valuepublic static float log2(float value)
value - the valuepublic static javafx.geometry.Point2D bezier(javafx.geometry.Point2D p1,
javafx.geometry.Point2D p2,
javafx.geometry.Point2D p3,
double t)
public static javafx.geometry.Point2D bezier(javafx.geometry.Point2D p1,
javafx.geometry.Point2D p2,
javafx.geometry.Point2D p3,
javafx.geometry.Point2D p4,
double t)
public static BezierSpline closedBezierSpline(Vec2[] points)
points - the spline passes through these pointspublic static float noise1D(double t)
t - current time * frequency (lower frequency -> smoother output)Copyright © 2017. All rights reserved.