public class

FloatUtils

extends Object
java.lang.Object
   ↳ com.cooliris.media.FloatUtils

Class Overview

A static class for some useful operations on Floats and Vectors

Summary

Public Constructors
FloatUtils()
Public Methods
final static void animate(Vector3f animVal, Vector3f targetVal, float timeElapsed)
This function animates a Tuple3f value to another Tuple3f value
final static float animate(float prevVal, float targetVal, float timeElapsed)
This function animates a float value to another float value
final static float animateWithMaxSpeed(float prevVal, float targetVal, float timeElapsed, float maxSpeed)
final static boolean boundsContainsPoint(float left, float right, float top, float bottom, float posX, float posY)
Function to check whether a point lies inside a rectangle
final static float clamp(float val, float minVal, float maxVal)
Clamp a float to a lower and upper bound
final static int clamp(int val, int minVal, int maxVal)
Clamp an integer to a lower and upper bound
final static float clampMax(float val, float maxVal)
Clamp a float to an upper bound
final static float clampMin(float val, float minVal)
Clamp a float to a lower bound
final static float max(float scaleX, float scaleY)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public FloatUtils ()

Public Methods

public static final void animate (Vector3f animVal, Vector3f targetVal, float timeElapsed)

This function animates a Tuple3f value to another Tuple3f value

Parameters
animVal : The animating Tuple
targetVal : The target value for the Tuple
timeElapsed : Time elapsed since the last time this function was called

public static final float animate (float prevVal, float targetVal, float timeElapsed)

This function animates a float value to another float value

Parameters
prevVal : The previous value (or the animated value)
targetVal : The target value
timeElapsed Time elapsed since the last time this function was called
Returns
  • The new animated value that is closer to the target value and clamped to the target value

public static final float animateWithMaxSpeed (float prevVal, float targetVal, float timeElapsed, float maxSpeed)

public static final boolean boundsContainsPoint (float left, float right, float top, float bottom, float posX, float posY)

Function to check whether a point lies inside a rectangle

Parameters
left : the x coordinate of the left most point
right : the x coordinate of the right most point
top : the y coordinate of the top most point
bottom : the y coordinate of the bottom most point
posX : the input point's x coordinate
posY : the input point's y coordinate
Returns
  • true if point is inside the rectangle else return false

public static final float clamp (float val, float minVal, float maxVal)

Clamp a float to a lower and upper bound

Parameters
val : the input float value
minVal : the minimum value to use to clamp
maxVal : the maximum value to use to clamp
Returns
  • the clamped value

public static final int clamp (int val, int minVal, int maxVal)

Clamp an integer to a lower and upper bound

Parameters
val : the input float value
minVal : the minimum value to use to clamp
maxVal : the maximum value to use to clamp
Returns
  • the clamped value

public static final float clampMax (float val, float maxVal)

Clamp a float to an upper bound

Parameters
val : the input float value
maxVal : the maximum value to use to clamp
Returns
  • the clamped value

public static final float clampMin (float val, float minVal)

Clamp a float to a lower bound

Parameters
val : the input float value
minVal : the minimum value to use to clamp
Returns
  • the clamped value

public static final float max (float scaleX, float scaleY)