Class PZMath

java.lang.Object
zombie.core.math.PZMath

public final class PZMath extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
     
    static interface 
     
    static enum 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final float
    Conversion ratios, Degrees to Radians and back
    static final float
     
    static final long
     
    static final long
     
    static final float
    The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.
    static final float
     
    static final float
     
    static final long
     
    static long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    abs(float val)
     
    static float
    acosf(float float0)
     
    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.
    static float
    Almost Unit Identity This is a near-identiy function that maps the unit interval into itself.
    static float
    angleBetween(float float2, float float1, float float5, float float4)
     
    static float
    angleBetween(Vector2 vector20, Vector2 vector21)
     
    static float
    angleBetweenNormalized(float float3, float float4, float float1, float float2)
     
    static float
    c_lerp(float src, float dest, float alpha)
     
    static float
    calculateBearing(Vector3 vector30, Vector2 vector2, Vector3 vector31)
     
    static boolean
     
    static float
    ceil(float val)
     
    static double
    clamp(double double0, double double1, double double2)
     
    static float
    clamp(float val, float min, float max)
    Result is clamped between min and max.
    static int
    clamp(int val, int min, int max)
    Result is clamped between min and max.
    static long
    clamp(long val, long min, long max)
     
    static float
    clamp_01(float val)
     
    static double
    clampDouble_01(double double0)
     
    static float
    clampFloat(float val, float min, float max)
     
    static Vector3
    closestVector3(float float0, float float1, float float2, float float3, float float4, float float5, float float6, float float7, float float8)
     
    static org.lwjgl.util.vector.Matrix4f
    convertMatrix(org.joml.Matrix4f matrix4f1, org.lwjgl.util.vector.Matrix4f matrix4f0)
     
    static org.joml.Matrix4f
    convertMatrix(org.lwjgl.util.vector.Matrix4f matrix4f1, org.joml.Matrix4f matrix4f0)
     
    static int
    coorddivision(int int1, int int0)
     
    static int
    coordmodulo(int int0, int int1)
     
    static float
    coordmodulof(float float0, int int0)
     
    static float
    degToRad(float degrees)
     
    static boolean
    equal(float a, float b)
     
    static boolean
    equal(float a, float b, float delta)
     
    static int
    fastfloor(double x)
     
    static int
    fastfloor(float x)
     
    static double
    floor(double double0)
     
    static float
    floor(float val)
     
    static float
    frac(float val)
     
    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.
    static float
    getClosestAngle(float in_radsA, float in_radsB)
     
    static float
    getClosestAngleDegrees(float in_degsA, float in_degsB)
     
    static float
    lerp(float src, float dest, float alpha)
     
    static org.lwjgl.util.vector.Vector3f
    lerp(org.lwjgl.util.vector.Vector3f vector3f0, org.lwjgl.util.vector.Vector3f vector3f1, org.lwjgl.util.vector.Vector3f vector3f2, float float0)
     
    static Vector2
    lerp(Vector2 out, Vector2 a, Vector2 b, float t)
     
    static Vector3
    lerp(Vector3 vector30, Vector3 vector31, Vector3 vector32, float float0)
     
    static float
    lerpAngle(float src, float dest, float alpha)
     
    static float
     
    static float
     
    static float
     
    static float
    max(float a, float b)
     
    static float
    max(float float0, float float1, float float2)
     
    static float
    max(float float0, float float1, float float2, float float3)
     
    static float
    max(float float0, float float1, float float2, float float3, float float4)
     
    static int
    max(int a, int b)
     
    static float
    min(float a, float b)
     
    static float
    min(float float0, float float1, float float2)
     
    static float
    min(float float0, float float1, float float2, float float3)
     
    static float
    min(float float0, float float1, float float2, float float3, float float4)
     
    static int
    min(int a, int b)
     
    static int
    nextPowerOfTwo(int int0)
     
    static float[]
    normalize(float[] float0)
     
    static <E> void
    normalize(E[] object, PZMath.FloatGet<E> floatGet, PZMath.FloatSet<E> floatSet)
     
     
    static <E> void
    normalize(List<E> list, PZMath.FloatGet<E> floatGet, PZMath.FloatSet<E> floatSet)
     
    static float
    pow(float float1, float float0)
     
    static float
    radToDeg(float radians)
     
    static float
    roundFloat(float float1, int int1)
     
    static float
    roundFloatPos(float float1, int int1)
     
    static float
    roundFromEdges(float val)
     
    static int
    roundToInt(float val)
     
    static float
    roundToIntPlus05(float val)
     
    static float
    roundToNearest(float val)
     
    static org.lwjgl.util.vector.Quaternion
    setFromAxisAngle(float float0, float float1, float float2, float float5, org.lwjgl.util.vector.Quaternion quaternion)
     
    static int
    sign(float val)
     
    static org.lwjgl.util.vector.Quaternion
    slerp(org.lwjgl.util.vector.Quaternion quaternion2, org.lwjgl.util.vector.Quaternion quaternion1, org.lwjgl.util.vector.Quaternion quaternion0, float float0)
     
    static float
    sqrt(float val)
     
    static float
    step(float from, float to, float delta)
     
    testSideOfLine(float x1, float y1, float x2, float y2, float px, float py)
     
    static double
    tryParseDouble(String varStr, double defaultVal)
     
    static float
    tryParseFloat(String varStr, float defaultVal)
     
    static int
    tryParseInt(String varStr, int defaultVal)
     
    static float
    wrap(float val, float range)
     
    static float
    wrap(float in_val, float in_min, float in_max)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PI

      public static final float PI
      The 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 degToRads
      Conversion 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 double0, double double1, double double2)
    • 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 double0)
    • setFromAxisAngle

      public static org.lwjgl.util.vector.Quaternion setFromAxisAngle(float float0, float float1, float float2, float float5, org.lwjgl.util.vector.Quaternion quaternion)
    • lerp

      public static float lerp(float src, float dest, float alpha)
    • 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 vector3f0, org.lwjgl.util.vector.Vector3f vector3f1, org.lwjgl.util.vector.Vector3f vector3f2, float float0)
    • lerp

      public static Vector3 lerp(Vector3 vector30, Vector3 vector31, Vector3 vector32, float float0)
    • lerp

      public static Vector2 lerp(Vector2 out, Vector2 a, Vector2 b, float t)
    • 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 quaternion2, org.lwjgl.util.vector.Quaternion quaternion1, org.lwjgl.util.vector.Quaternion quaternion0, float float0)
    • 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

      public static double tryParseDouble(String varStr, double defaultVal)
    • tryParseFloat

      public static float tryParseFloat(String varStr, float defaultVal)
    • canParseFloat

      public static boolean canParseFloat(String varStr)
    • tryParseInt

      public static int tryParseInt(String varStr, int defaultVal)
    • pow

      public static float pow(float float1, float float0)
    • 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 x)
    • fastfloor

      public static int fastfloor(float x)
    • coorddivision

      public static int coorddivision(int int1, int int0)
    • coordmodulo

      public static int coordmodulo(int int0, int int1)
    • coordmodulof

      public static float coordmodulof(float float0, int int0)
    • floor

      public static float floor(float val)
    • floor

      public static double floor(double double0)
    • 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 float0, float float1, float float2)
    • max

      public static float max(float float0, float float1, float float2, float float3)
    • max

      public static float max(float float0, float float1, float float2, float float3, float float4)
    • max

      public static int max(int a, int b)
    • min

      public static float min(float a, float b)
    • min

      public static float min(float float0, float float1, float float2)
    • min

      public static float min(float float0, float float1, float float2, float float3)
    • min

      public static float min(float float0, float float1, float float2, float float3, float float4)
    • min

      public static int min(int a, int b)
    • 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 matrix4f1, org.lwjgl.util.vector.Matrix4f matrix4f0)
    • convertMatrix

      public static org.joml.Matrix4f convertMatrix(org.lwjgl.util.vector.Matrix4f matrix4f1, org.joml.Matrix4f matrix4f0)
    • step

      public static float step(float from, float to, float delta)
    • angleBetween

      public static float angleBetween(Vector2 vector20, Vector2 vector21)
    • angleBetween

      public static float angleBetween(float float2, float float1, float float5, float float4)
    • angleBetweenNormalized

      public static float angleBetweenNormalized(float float3, float float4, float float1, float float2)
    • acosf

      public static float acosf(float float0)
    • calculateBearing

      public static float calculateBearing(Vector3 vector30, Vector2 vector2, Vector3 vector31)
    • 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[] object, PZMath.FloatGet<E> floatGet, PZMath.FloatSet<E> floatSet)
    • normalize

      public static float[] normalize(float[] float0)
    • normalize

      public static ArrayList<Double> normalize(ArrayList<Double> arrayList)
    • roundFloatPos

      public static float roundFloatPos(float float1, int int1)
    • roundFloat

      public static float roundFloat(float float1, int int1)
    • nextPowerOfTwo

      public static int nextPowerOfTwo(int int0)
    • 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 float0, float float1, float float2, float float3, float float4, float float5, float float6, float float7, float float8)