Documentation of 'mikera.util.mathz.FloatMaths' Java class
FloatMaths
mikera.util.mathz

Class FloatMaths



  • public final class FloatMaths
    extends java.lang.Object
    Static class for specialised maths functions that return floats
    • Constructor Summary

      Constructors 
      Constructor and Description
      FloatMaths() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static float abs(float a)
      float abs function
      static float alternateSqrt(float x)
      Interesting way to approximate a square root....
      static float approxSqrt(float x)
      Fast approximate square root
      static float bound(float v, float min, float max)
      Bound a value within a given range
      static float cos(double a)
      Float-returning version of Math.cos
      static float cos(float a)
      Float-returning version of Math.cos
      static float fastInverseSqrt(float x)
      Fast inverse square root on floats - amusing hack used in Quake
      static float fastPower(float a, float b)
      Computes a fast approximation to Math.pow(a, b).
      static float lerp(float t, float a, float b)
      Linear interpolation between a and b
      static float mod(float n, float d)
      Mod function implemented for float values
      static float round(float f, int dp)
      Float round to a specified number of decimal places
      static float sin(double a)
      Float-returning version of Math.sin
      static float sin(float a)
      Float-returning version of Math.sin
      static float smoothFactor(float x)
      Smooth factor function for linear interpolation, with dy/dx=0 at x=0 and x=1
      static float smoothStep(float a, float b, float x) 
      static float sqrt(float a)
      float square root
      static float square(float x)
      Square function
      static float tanh(float x)
      float version of Math.tanh
      static float tanhDerivative(float x) 
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FloatMaths

        public FloatMaths()
    • Method Detail

      • round

        public static float round(float f,
                                  int dp)
        Float round to a specified number of decimal places
      • fastPower

        public static final float fastPower(float a,
                                            float b)
        Computes a fast approximation to Math.pow(a, b). Adapted from http://www.dctsystems.co.uk/Software/power.html.
        Parameters:
        a - a positive number
        b - a number
        Returns:
        a^b
      • lerp

        public static final float lerp(float t,
                                       float a,
                                       float b)
        Linear interpolation between a and b
      • smoothFactor

        public static final float smoothFactor(float x)
        Smooth factor function for linear interpolation, with dy/dx=0 at x=0 and x=1
      • mod

        public static float mod(float n,
                                float d)
        Mod function implemented for float values
      • smoothStep

        public static final float smoothStep(float a,
                                             float b,
                                             float x)
      • bound

        public static final float bound(float v,
                                        float min,
                                        float max)
        Bound a value within a given range
      • abs

        public static float abs(float a)
        float abs function
      • square

        public static float square(float x)
        Square function
      • sqrt

        public static float sqrt(float a)
        float square root
      • alternateSqrt

        public static float alternateSqrt(float x)
        Interesting way to approximate a square root.... however seems to be slower than standard Math.sqrt() approach
        Parameters:
        x -
        Returns:
      • approxSqrt

        public static float approxSqrt(float x)
        Fast approximate square root
      • fastInverseSqrt

        public static float fastInverseSqrt(float x)
        Fast inverse square root on floats - amusing hack used in Quake
      • sin

        public static float sin(double a)
        Float-returning version of Math.sin
      • cos

        public static float cos(double a)
        Float-returning version of Math.cos
      • sin

        public static float sin(float a)
        Float-returning version of Math.sin
      • tanh

        public static float tanh(float x)
        float version of Math.tanh
      • tanhDerivative

        public static float tanhDerivative(float x)
      • cos

        public static float cos(float a)
        Float-returning version of Math.cos

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.