artofillusion.math
Class FastMath

java.lang.Object
  extended by artofillusion.math.FastMath

public class FastMath
extends java.lang.Object

This class provides faster replacements for some of the methods of java.lang.Math. Read the comments for each method before using it, since in some cases they return different results from java.lang.Math.


Constructor Summary
FastMath()
           
 
Method Summary
static double atan(double d)
          This method calculates a fast approximation to the arctan function.
static int ceil(double d)
          This method produces identical results to Math.ceil() for all normal input values (one which fall inside the allowed range of the int type).
static int floor(double d)
          This method produces identical results to Math.floor() for all normal input values (one which fall inside the allowed range of the int type).
static double pow(double base, int exponent)
          This method produces results which are nearly identical to Math.pow(), although the last few digits may be different due to numerical error.
static int round(double d)
          This method produces identical results to Math.round() for all normal input values (one which fall inside the allowed range of the int type).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastMath

public FastMath()
Method Detail

floor

public static int floor(double d)
This method produces identical results to Math.floor() for all normal input values (one which fall inside the allowed range of the int type).


ceil

public static int ceil(double d)
This method produces identical results to Math.ceil() for all normal input values (one which fall inside the allowed range of the int type).


round

public static int round(double d)
This method produces identical results to Math.round() for all normal input values (one which fall inside the allowed range of the int type).


pow

public static double pow(double base,
                         int exponent)
This method produces results which are nearly identical to Math.pow(), although the last few digits may be different due to numerical error. Unlike Math.pow(), this method requires the exponent to be an integer.


atan

public static double atan(double d)
This method calculates a fast approximation to the arctan function. It differs from the true value by no more than 0.005 for any input value.

I found this formula on an internet discussion board post by Ranko Bojanic. The reference cited in that post was

Approximation Theory (C. Hastings, Jr., Note 143, Math. Tables Aids. Comp 6, 68 (1953))



Copyright © 1999-2011 by Peter Eastman.