org.sunflow.math
Class MathUtils

java.lang.Object
  extended by org.sunflow.math.MathUtils

public final class MathUtils
extends java.lang.Object


Method Summary
static double clamp(double x, double min, double max)
           
static float clamp(float x, float min, float max)
           
static int clamp(int x, int min, int max)
           
static float fastPow(float a, float b)
          Computes a fast approximation to Math.pow(a, b).
static float frac(float x)
           
static double max(double a, double b, double c)
           
static float max(float a, float b, float c)
           
static float max(float a, float b, float c, float d)
           
static int max(int a, int b, int c)
           
static double min(double a, double b, double c)
           
static float min(float a, float b, float c)
           
static float min(float a, float b, float c, float d)
           
static int min(int a, int b, int c)
           
static float smoothStep(float a, float b, float x)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

clamp

public static final int clamp(int x,
                              int min,
                              int max)

clamp

public static final float clamp(float x,
                                float min,
                                float max)

clamp

public static final double clamp(double x,
                                 double min,
                                 double max)

min

public static final int min(int a,
                            int b,
                            int c)

min

public static final float min(float a,
                              float b,
                              float c)

min

public static final double min(double a,
                               double b,
                               double c)

min

public static final float min(float a,
                              float b,
                              float c,
                              float d)

max

public static final int max(int a,
                            int b,
                            int c)

max

public static final float max(float a,
                              float b,
                              float c)

max

public static final double max(double a,
                               double b,
                               double c)

max

public static final float max(float a,
                              float b,
                              float c,
                              float d)

smoothStep

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

frac

public static final float frac(float x)

fastPow

public static final float fastPow(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