/*Siddhartha Kasivajhula * Georgia Institute of Technology * c/o Predrag Cvitanovic * Advisor: Rytis Paskauskas * Fall 2005 */ //! @brief Provides some useful custom math functions /// functions are: a "modulo" function for int, and one for double. A log2 function for determining precision /// necessary while zooming. A function dif() to check if two numbers differ by less than a given value. Used /// in class Animation to "flash" when within sight of the strobe index public class AFMMath { public static double mod(double arg1, double arg2) { double intQuotient = (int) (arg1 / arg2); return (arg1 - arg2 * intQuotient); } public static int mod(int arg1, int arg2) { int quotient = arg1 / arg2; return (arg1 - arg2 * quotient); } public static boolean dif(double arg1, double arg2, double dif) { if (Math.abs(arg1 - arg2) < dif) return true; else return false; } public static double log2(double num) { return Math.log(num)/Math.log(2); } public static void main(String[] args) { //double a = 5.37; //double b = 38.70442149222625; double a = 15.3; double b = 15.34; boolean c = dif(a, b, 0.05); System.out.println(c); //System.out.println(19.719902750289553-19.15868863865226); } }