com.b3dgs.lionengine.utility
Class Maths

java.lang.Object
  extended by com.b3dgs.lionengine.utility.Maths

public final class Maths
extends java.lang.Object

Static functions arround maths manipulation.


Method Summary
static float curveValue(float value, float dest, float speed)
          Apply progressive modifications to a value.
static float fixBetween(float value, float min, float max)
          Fix a value between an interleave.
static int fixBetween(int value, int min, int max)
          Fix a value between an interleave.
static int getDistance(int x1, int y1, int x2, int y2)
          Get integer distance of two points.
static Point2D intersection(java.awt.geom.Line2D l1, java.awt.geom.Line2D l2)
          Get the intersection point of two lines.
static long nano()
          Get the current time in nano second.
static int random(int min, int max)
          Get a random value contained in specified interleave.
static long time()
          Get the current time in millisecond.
static float wrapFloat(float value, float min, float max)
          Wrap value (keep value bewteen min and max).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

fixBetween

public static int fixBetween(int value,
                             int min,
                             int max)
Fix a value between an interleave.

Parameters:
value - value to fix.
min - minimum value.
max - maximum value.
Returns:
fixed value.

fixBetween

public static float fixBetween(float value,
                               float min,
                               float max)
Fix a value between an interleave.

Parameters:
value - value to fix.
min - minimum value.
max - maximum value.
Returns:
fixed value.

curveValue

public static float curveValue(float value,
                               float dest,
                               float speed)
Apply progressive modifications to a value.

Parameters:
value - value.
dest - value to reach.
speed - effect speed.
Returns:
modified value.

intersection

public static Point2D intersection(java.awt.geom.Line2D l1,
                                   java.awt.geom.Line2D l2)
Get the intersection point of two lines.

Parameters:
l1 - first line.
l2 - second line.
Returns:
intersection point.

getDistance

public static int getDistance(int x1,
                              int y1,
                              int x2,
                              int y2)
Get integer distance of two points.

Parameters:
x1 - point 1 x.
y1 - point 1 y.
x2 - point 2 x.
y2 - point 2 y.
Returns:
distance between point 1 and 2.

wrapFloat

public static float wrapFloat(float value,
                              float min,
                              float max)
Wrap value (keep value bewteen min and max).

Parameters:
value - input value.
min - minimum value (included).
max - maximum value (excluded).
Returns:
wrapped value.

random

public static int random(int min,
                         int max)
Get a random value contained in specified interleave.

Parameters:
min - minimum value (included).
max - maximum value (included).
Returns:
random value.

time

public static long time()
Get the current time in millisecond.

Returns:
current time in millisecond.

nano

public static long nano()
Get the current time in nano second.

Returns:
current time in nano second.