NASA World Wind

gov.nasa.worldwind.util
Class WWMath

java.lang.Object
  extended by gov.nasa.worldwind.util.WWMath

public class WWMath
extends Object

A collection of useful math methods, all static.


Constructor Summary
WWMath()
           
 
Method Summary
static double clamp(double v, double min, double max)
          Clamps a value to a given range.
static double convertHoursToMillis(double hours)
          Converts time in hours to time in milliseconds.
static double convertMetersToFeet(double meters)
          converts meters to feet.
static double convertMetersToMiles(double meters)
          converts meters to miles.
static double convertMillisToHours(double mills)
          Converts time in milliseconds to time in hours.
static double convertMillisToMinutes(double millis)
          Converts time in milliseconds to time in minutes.
static double convertMillisToSeconds(double millis)
          Converts time in milliseconds to time in seconds.
static double convertMinutesToMillis(double minutes)
          Converts time in minutes to time in milliseconds.
static double convertSecondsToMillis(double seconds)
          Converts time in seconds to time in milliseconds.
static boolean isPowerOfTwo(int value)
          Convenience method for testing whether a value is a power of two.
static double logBase2(double value)
          Convenience method to compute the log base 2 of a value.
static int powerOfTwoCeiling(int reference)
          Returns the value that is the nearest power of 2 greater than or equal to the given value.
static int powerOfTwoFloor(int reference)
          Returns the value that is the nearest power of 2 less than or equal to the given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WWMath

public WWMath()
Method Detail

clamp

public static double clamp(double v,
                           double min,
                           double max)
Clamps a value to a given range.

Parameters:
v - the value to clamp.
min - the floor.
max - the ceiling
Returns:
the nearest value such that min <= v <= max.

convertHoursToMillis

public static double convertHoursToMillis(double hours)
Converts time in hours to time in milliseconds.

Parameters:
hours - time in hours.
Returns:
time in milliseconds.

convertMetersToFeet

public static double convertMetersToFeet(double meters)
converts meters to feet.

Parameters:
meters - the value in meters.
Returns:
the value converted to feet.

convertMetersToMiles

public static double convertMetersToMiles(double meters)
converts meters to miles.

Parameters:
meters - the value in meters.
Returns:
the value converted to miles.

convertMillisToHours

public static double convertMillisToHours(double mills)
Converts time in milliseconds to time in hours.

Parameters:
mills - time in milliseconds.
Returns:
time in hours.

convertMillisToMinutes

public static double convertMillisToMinutes(double millis)
Converts time in milliseconds to time in minutes.

Parameters:
millis - time in milliseconds.
Returns:
time in minutes.

convertMillisToSeconds

public static double convertMillisToSeconds(double millis)
Converts time in milliseconds to time in seconds.

Parameters:
millis - time in milliseconds.
Returns:
time in seconds.

convertMinutesToMillis

public static double convertMinutesToMillis(double minutes)
Converts time in minutes to time in milliseconds.

Parameters:
minutes - time in minutes.
Returns:
time in milliseconds.

convertSecondsToMillis

public static double convertSecondsToMillis(double seconds)
Converts time in seconds to time in milliseconds.

Parameters:
seconds - time in seconds.
Returns:
time in milliseconds.

isPowerOfTwo

public static boolean isPowerOfTwo(int value)
Convenience method for testing whether a value is a power of two.

Parameters:
value - the value to test for power of 2
Returns:
true if power of 2, else false

logBase2

public static double logBase2(double value)
Convenience method to compute the log base 2 of a value.

Parameters:
value - the value to take the log of.
Returns:
the log base 2 of the specified value.

powerOfTwoCeiling

public static int powerOfTwoCeiling(int reference)
Returns the value that is the nearest power of 2 greater than or equal to the given value.

Parameters:
reference - the reference value. The power of 2 returned is greater than or equal to this value.
Returns:
the value that is the nearest power of 2 greater than or equal to the reference value

powerOfTwoFloor

public static int powerOfTwoFloor(int reference)
Returns the value that is the nearest power of 2 less than or equal to the given value.

Parameters:
reference - the reference value. The power of 2 returned is less than or equal to this value.
Returns:
the value that is the nearest power of 2 less than or equal to the reference value

NASA World Wind

Hosted by docs.bugaco.com