|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.alchemy.core.AlcMath
public class AlcMath
Utility class that handles math functions Random number generation, noise etc... Based on Processing: http://dev.processing.org/source/index.cgi/trunk/processing/core/src/processing/core/PApplet.java?view=markup
Field Summary |
---|
Method Summary | |
---|---|
static float |
constrain(float value,
float min,
float max)
Constrains a value to not exceed a maximum and minimum value. |
static int |
constrain(int value,
int min,
int max)
Constrains a value to not exceed a maximum and minimum value. |
static float |
distance(float x1,
float y1,
float x2,
float y2)
Calculates the distance between two points. |
static float |
map(float value,
float istart,
float istop,
float ostart,
float ostop)
Convenience function to map a variable from one coordinate space to another. |
static double |
mean(int[] p)
Return the mean of an int array |
float |
noise(float x)
Computes the Perlin noise function value at point x. |
float |
noise(float x,
float y)
Computes the Perlin noise function value at the point x, y. |
float |
noise(float x,
float y,
float z)
Computes the Perlin noise function value at x, y, z. |
void |
noiseDetail(int lod)
make perlin noise quality user controlled to allow for different levels of detail. |
void |
noiseDetail(int lod,
float falloff)
|
void |
noiseSeed(long what)
|
float |
random(float howbig)
Return a random number in the range [0, howbig). |
float |
random(float howsmall,
float howbig)
Return a random number in the range [howsmall, howbig). |
void |
randomSeed(long what)
|
static float |
sq(float num)
Squares a number (multiplies a number by itself). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public final float random(float howbig)
The number returned will range from zero up to (but not including) 'howbig'.
howbig
-
public final float random(float howsmall, float howbig)
The number returned will range from 'howsmall' up to (but not including 'howbig'.
If howsmall is >= howbig, howsmall will be returned, meaning that random(5, 5) will return 5 (useful) and random(7, 4) will return 7 (not useful.. better idea?)
public final void randomSeed(long what)
public float noise(float x)
public float noise(float x, float y)
public final float noise(float x, float y, float z)
public final void noiseDetail(int lod)
public final void noiseDetail(int lod, float falloff)
public final void noiseSeed(long what)
public static final double mean(int[] p)
public static final float map(float value, float istart, float istop, float ostart, float ostop)
value
- The incoming value to be convertedistart
- Lower bound of the value's current rangeistop
- Upper bound of the value's current rangeostart
- Lower bound of the value's target rangeostop
- Upper bound of the value's target range
public static final int constrain(int value, int min, int max)
value
- The value to constrainmin
- Minimum limitmax
- Maximum limit
public static final float constrain(float value, float min, float max)
value
- The value to constrainmin
- Minimum limitmax
- Maximum limit
public static final float distance(float x1, float y1, float x2, float y2)
x1
- x-coordinate of the first pointy1
- y-coordinate of the first pointx2
- x-coordinate of the second pointy2
- y-coordinate of the second point
public static final float sq(float num)
num
- The number to square
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |