nodebox.graphics
Class MathUtils

java.lang.Object
  extended by nodebox.graphics.MathUtils

public final class MathUtils
extends Object


Method Summary
static double clamp(double v)
          Clamps the value so the result is between 0.0 and 1.0.
static double clamp(double v, double min, double max)
          Clamps the value so the result is between the given minimum and maximum value.
static float clamp(float v)
          Clamps the value so the result is between 0.0 and 1.0.
static float clamp(float v, float min, float max)
          Clamps the value so the result is between the given minimum and maximum value.
static Random randomFromSeed(long seed)
           
static double snap(double v, double distance, double strength)
          Round a value to the nearest "step".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

clamp

public static float clamp(float v)
Clamps the value so the result is between 0.0 and 1.0.

This means that if the value is smaller than 0.0, this method will return 0.0. If the value is larger than 1.0, this method will return 1.0. Values within the range are returned unchanged.

Parameters:
v - the value to clamp
Returns:
a value between 0.0 and 1.0.

clamp

public static double clamp(double v)
Clamps the value so the result is between 0.0 and 1.0.

This means that if the value is smaller than 0.0, this method will return 0.0. If the value is larger than 1.0, this method will return 1.0. Values within the range are returned unchanged.

Parameters:
v - the value to clamp
Returns:
a value between 0.0 and 1.0.

clamp

public static float clamp(float v,
                          float min,
                          float max)
Clamps the value so the result is between the given minimum and maximum value.

This means that if the value is smaller than min, this method will return min. If the value is larger than max, this method will return max. Values within the range are returned unchanged.

Parameters:
v - the value to clamp
min - the minimum value
max - the maximum value
Returns:
a value between min and max.

clamp

public static double clamp(double v,
                           double min,
                           double max)
Clamps the value so the result is between the given minimum and maximum value.

This means that if the value is smaller than min, this method will return min. If the value is larger than max, this method will return max. Values within the range are returned unchanged.

Parameters:
v - the value to clamp
min - the minimum value
max - the maximum value
Returns:
a value between min and max.

snap

public static double snap(double v,
                          double distance,
                          double strength)
Round a value to the nearest "step".

Parameters:
v - The value to snap.
distance - The distance between steps.
strength - The strength of rounding. If 1 the values will always be on a step. If zero, the value is unchanged.
Returns:
The snapped value.

randomFromSeed

public static Random randomFromSeed(long seed)


Copyright © 2013. All Rights Reserved.