Class PZMath
java.lang.Object
zombie.core.math.PZMath
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfacestatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatConversion ratios, Degrees to Radians and backstatic final floatstatic final longstatic final longstatic final floatThe double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.static final floatstatic final floatstatic final longstatic long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic floatabs(float val) static floatacosf(float a) static floatalmostIdentity(float x, float m, float n) Almost Identity Imagine you don't want to modify a signal unless it's drops to zero or close to it, in which case you want to replace the value with a small possitive constant.static floatalmostUnitIdentity(float x) Almost Unit Identity This is a near-identiy function that maps the unit interval into itself.static floatangleBetween(float in_ax, float in_ay, float in_bx, float in_by) static floatangleBetween(Vector2 va, Vector2 vb) static floatangleBetweenNormalized(float ax, float bx, float ay, float by) static floatc_lerp(float src, float dest, float alpha) static floatcalculateBearing(Vector3 in_fromPosition, Vector2 in_fromForward, Vector3 in_toPosition) static booleancanParseFloat(String varStr) static floatceil(float val) static doubleclamp(double val, double min, double max) static floatclamp(float val, float min, float max) Result is clamped between min and max.static intclamp(int val, int min, int max) Result is clamped between min and max.static longclamp(long val, long min, long max) static floatclamp_01(float val) static doubleclampDouble_01(double val) static floatclampFloat(float val, float min, float max) static doubleclosestPointOnLineSegment(float x1, float y1, float x2, float y2, float px, float py, double epsilon, org.joml.Vector2f out) static doubleclosestPointsOnLineSegments(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, org.joml.Vector2f p1, org.joml.Vector2f p2) static Vector3closestVector3(float lx0, float ly0, float lz0, float lx1, float ly1, float lz1, float x, float y, float z) static org.lwjgl.util.vector.Matrix4fconvertMatrix(org.joml.Matrix4f src, org.lwjgl.util.vector.Matrix4f dst) static org.joml.Matrix4fconvertMatrix(org.lwjgl.util.vector.Matrix4f src, org.joml.Matrix4f dst) static intcoorddivision(int value, int divisor) static intcoordmodulo(int value, int divisor) static floatcoordmodulof(float value, int divisor) static floatdegToRad(float degrees) static booleanequal(float a, float b) static booleanequal(float a, float b, float delta) static intfastfloor(double val) static intfastfloor(float val) static doublefloor(double val) static floatfloor(float val) static floatfrac(float val) static floatgain(float x, float k) Gain Remapping the unit interval into the unit interval by expanding the sides and compressing the center, and keeping 1/2 mapped to 1/2, that can be done with the gain() function.static floatgetClosestAngle(float in_radsA, float in_radsB) static floatgetClosestAngleDegrees(float in_degsA, float in_degsB) static booleanintersectLineSegments(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, org.joml.Vector2f intersection) static floatisLeft(float x0, float y0, float x1, float y1, float x2, float y2) static floatlerp(float src, float dest, float alpha) static floatstatic org.lwjgl.util.vector.Vector3flerp(org.lwjgl.util.vector.Vector3f out, org.lwjgl.util.vector.Vector3f a, org.lwjgl.util.vector.Vector3f b, float t) static Vector2static Vector3static floatlerpAngle(float src, float dest, float alpha) static floatlerpFunc_EaseInQuad(float x) static floatlerpFunc_EaseOutInQuad(float x) static floatlerpFunc_EaseOutQuad(float x) static floatmax(float a, float b) static floatmax(float a, float b, float c) static floatmax(float a, float b, float c, float d) static floatmax(float a, float b, float c, float d, float e) static intmax(int a, int b) static intmax(int a, int b, int c) static intmax(int a, int b, int c, int d) static intmax(int a, int b, int c, int d, int e) static floatmin(float a, float b) static floatmin(float a, float b, float c) static floatmin(float a, float b, float c, float d) static floatmin(float a, float b, float c, float d, float e) static intmin(int a, int b) static intmin(int a, int b, int c) static intmin(int a, int b, int c, int d) static intmin(int a, int b, int c, int d, int e) static intnextPowerOfTwo(int value) static float[]normalize(float[] weights) static <E> voidnormalize(E[] list, PZMath.FloatGet<E> floatGet, PZMath.FloatSet<E> floatSet) static <E> voidnormalize(List<E> list, PZMath.FloatGet<E> floatGet, PZMath.FloatSet<E> floatSet) static floatpow(float a, float b) static floatradToDeg(float radians) static org.lwjgl.util.vector.Vector3frotateVector(float vx, float vy, float vz, float qx, float qy, float qz, float qw, org.lwjgl.util.vector.Vector3f out_result) static Vector2rotateVector(float vx, float vy, float qx, float qy, float qz, float qw, Vector2 out_result) static org.lwjgl.util.vector.Vector3frotateVector(org.lwjgl.util.vector.Vector3f in_vector, org.lwjgl.util.vector.Quaternion in_quaternion, org.lwjgl.util.vector.Vector3f out_result) static floatroundFloat(float value, int scale) static floatroundFloatPos(float number, int scale) static floatroundFromEdges(float val) static introundToInt(float val) static floatroundToIntPlus05(float val) static floatroundToNearest(float val) static org.lwjgl.util.vector.QuaternionsetFromAxisAngle(float ax, float ay, float az, float angleRadians, org.lwjgl.util.vector.Quaternion out_result) static intsign(float val) static org.lwjgl.util.vector.Quaternionslerp(org.lwjgl.util.vector.Quaternion result, org.lwjgl.util.vector.Quaternion from, org.lwjgl.util.vector.Quaternion to, float alpha) static floatsqrt(float val) static floatstep(float from, float to, float delta) static PZMath.SideOfLinetestSideOfLine(float x1, float y1, float x2, float y2, float px, float py) static doubletryParseDouble(String varStr, double defaultVal) static floattryParseFloat(String varStr, float defaultVal) static inttryParseInt(String varStr, int defaultVal) static floatwrap(float val, float range) static floatwrap(float in_val, float in_min, float in_max)
-
Field Details
-
PI
public static final float PIThe double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.- See Also:
-
PI2
public static final float PI2- See Also:
-
halfPI
public static final float halfPI- See Also:
-
degToRads
public static final float degToRadsConversion ratios, Degrees to Radians and back- See Also:
-
radToDegs
public static final float radToDegs- See Also:
-
microsToNanos
public static final long microsToNanos- See Also:
-
millisToMicros
public static final long millisToMicros- See Also:
-
secondsToMillis
public static final long secondsToMillis- See Also:
-
secondsToNanos
public static long secondsToNanos
-
-
Constructor Details
-
PZMath
public PZMath()
-
-
Method Details
-
almostUnitIdentity
public static float almostUnitIdentity(float x) Almost Unit Identity This is a near-identiy function that maps the unit interval into itself. It is the cousin of smoothstep(), in that it maps 0 to 0, 1 to 1, and has a 0 derivative at the origin, just like smoothstep. However, instead of having a 0 derivative at 1, it has a derivative of 1 at that point. It's equivalent to the Almost Identiy above with n=0 and m=1. Since it's a cubic just like smoothstep() it is very fast to evaluate. https://iquilezles.org/www/articles/functions/functions.htm- Parameters:
x- value in [0..1]- Returns:
- value in [0..1]
-
almostIdentity
public static float almostIdentity(float x, float m, float n) Almost Identity Imagine you don't want to modify a signal unless it's drops to zero or close to it, in which case you want to replace the value with a small possitive constant. Then, rather than clamping the value and introduce a discontinuity, you can smoothly blend the signal into the desired clipped value. So, let m be the threshold (anything above m stays unchanged), and n the value things will take when the signal is zero. Then, the following function does the soft clipping (in a cubic fashion): https://iquilezles.org/www/articles/functions/functions.htm- Parameters:
x- value in [0..1]m-n-- Returns:
- value in [0..1]
-
gain
public static float gain(float x, float k) Gain Remapping the unit interval into the unit interval by expanding the sides and compressing the center, and keeping 1/2 mapped to 1/2, that can be done with the gain() function. This was a common function in RSL tutorials (the Renderman Shading Language). k=1 is the identity curve, kinvalid input: '<'1 produces the classic gain() shape, and k>1 produces "s" shaped curces. The curves are symmetric (and inverse) for k=a and k=1/a. https://iquilezles.org/www/articles/functions/functions.htm -
clamp
public static float clamp(float val, float min, float max) Result is clamped between min and max.- Returns:
- min invalid input: '<'= val invalid input: '<'= max
-
clamp
public static long clamp(long val, long min, long max) -
clamp
public static int clamp(int val, int min, int max) Result is clamped between min and max.- Returns:
- min invalid input: '<'= val invalid input: '<'= max
-
clamp
public static double clamp(double val, double min, double max) -
clampFloat
public static float clampFloat(float val, float min, float max) -
clamp_01
public static float clamp_01(float val) -
clampDouble_01
public static double clampDouble_01(double val) -
setFromAxisAngle
public static org.lwjgl.util.vector.Quaternion setFromAxisAngle(float ax, float ay, float az, float angleRadians, org.lwjgl.util.vector.Quaternion out_result) -
lerp
public static float lerp(float src, float dest, float alpha) -
lerp
-
lerpAngle
public static float lerpAngle(float src, float dest, float alpha) -
lerp
public static org.lwjgl.util.vector.Vector3f lerp(org.lwjgl.util.vector.Vector3f out, org.lwjgl.util.vector.Vector3f a, org.lwjgl.util.vector.Vector3f b, float t) -
lerp
-
lerp
-
c_lerp
public static float c_lerp(float src, float dest, float alpha) -
slerp
public static org.lwjgl.util.vector.Quaternion slerp(org.lwjgl.util.vector.Quaternion result, org.lwjgl.util.vector.Quaternion from, org.lwjgl.util.vector.Quaternion to, float alpha) -
sqrt
public static float sqrt(float val) -
lerpFunc_EaseOutQuad
public static float lerpFunc_EaseOutQuad(float x) -
lerpFunc_EaseInQuad
public static float lerpFunc_EaseInQuad(float x) -
lerpFunc_EaseOutInQuad
public static float lerpFunc_EaseOutInQuad(float x) -
tryParseDouble
-
tryParseFloat
-
canParseFloat
-
tryParseInt
-
pow
public static float pow(float a, float b) -
degToRad
public static float degToRad(float degrees) -
radToDeg
public static float radToDeg(float radians) -
getClosestAngle
public static float getClosestAngle(float in_radsA, float in_radsB) -
getClosestAngleDegrees
public static float getClosestAngleDegrees(float in_degsA, float in_degsB) -
sign
public static int sign(float val) -
fastfloor
public static int fastfloor(double val) -
fastfloor
public static int fastfloor(float val) -
coorddivision
public static int coorddivision(int value, int divisor) -
coordmodulo
public static int coordmodulo(int value, int divisor) -
coordmodulof
public static float coordmodulof(float value, int divisor) -
floor
public static float floor(float val) -
floor
public static double floor(double val) -
ceil
public static float ceil(float val) -
frac
public static float frac(float val) -
wrap
public static float wrap(float val, float range) -
wrap
public static float wrap(float in_val, float in_min, float in_max) -
max
public static float max(float a, float b) -
max
public static float max(float a, float b, float c) -
max
public static float max(float a, float b, float c, float d) -
max
public static float max(float a, float b, float c, float d, float e) -
max
public static int max(int a, int b) -
max
public static int max(int a, int b, int c) -
max
public static int max(int a, int b, int c, int d) -
max
public static int max(int a, int b, int c, int d, int e) -
min
public static float min(float a, float b) -
min
public static float min(float a, float b, float c) -
min
public static float min(float a, float b, float c, float d) -
min
public static float min(float a, float b, float c, float d, float e) -
min
public static int min(int a, int b) -
min
public static int min(int a, int b, int c) -
min
public static int min(int a, int b, int c, int d) -
min
public static int min(int a, int b, int c, int d, int e) -
abs
public static float abs(float val) -
equal
public static boolean equal(float a, float b) -
equal
public static boolean equal(float a, float b, float delta) -
convertMatrix
public static org.lwjgl.util.vector.Matrix4f convertMatrix(org.joml.Matrix4f src, org.lwjgl.util.vector.Matrix4f dst) -
convertMatrix
public static org.joml.Matrix4f convertMatrix(org.lwjgl.util.vector.Matrix4f src, org.joml.Matrix4f dst) -
step
public static float step(float from, float to, float delta) -
angleBetween
-
angleBetween
public static float angleBetween(float in_ax, float in_ay, float in_bx, float in_by) -
angleBetweenNormalized
public static float angleBetweenNormalized(float ax, float bx, float ay, float by) -
acosf
public static float acosf(float a) -
calculateBearing
-
rotateVector
public static org.lwjgl.util.vector.Vector3f rotateVector(org.lwjgl.util.vector.Vector3f in_vector, org.lwjgl.util.vector.Quaternion in_quaternion, org.lwjgl.util.vector.Vector3f out_result) -
rotateVector
public static org.lwjgl.util.vector.Vector3f rotateVector(float vx, float vy, float vz, float qx, float qy, float qz, float qw, org.lwjgl.util.vector.Vector3f out_result) -
rotateVector
-
testSideOfLine
public static PZMath.SideOfLine testSideOfLine(float x1, float y1, float x2, float y2, float px, float py) -
normalize
public static <E> void normalize(List<E> list, PZMath.FloatGet<E> floatGet, PZMath.FloatSet<E> floatSet) -
normalize
public static <E> void normalize(E[] list, PZMath.FloatGet<E> floatGet, PZMath.FloatSet<E> floatSet) -
normalize
public static float[] normalize(float[] weights) -
normalize
-
roundFloatPos
public static float roundFloatPos(float number, int scale) -
roundFloat
public static float roundFloat(float value, int scale) -
nextPowerOfTwo
public static int nextPowerOfTwo(int value) -
roundToNearest
public static float roundToNearest(float val) -
roundToInt
public static int roundToInt(float val) -
roundToIntPlus05
public static float roundToIntPlus05(float val) -
roundFromEdges
public static float roundFromEdges(float val) -
closestVector3
public static Vector3 closestVector3(float lx0, float ly0, float lz0, float lx1, float ly1, float lz1, float x, float y, float z) -
isLeft
public static float isLeft(float x0, float y0, float x1, float y1, float x2, float y2) -
intersectLineSegments
public static boolean intersectLineSegments(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, org.joml.Vector2f intersection) -
closestPointOnLineSegment
public static double closestPointOnLineSegment(float x1, float y1, float x2, float y2, float px, float py, double epsilon, org.joml.Vector2f out) -
closestPointsOnLineSegments
public static double closestPointsOnLineSegments(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, org.joml.Vector2f p1, org.joml.Vector2f p2)
-