1 package com.insanityengine.ghia.m3; 2 3 /*** 4 * 5 * <P> 6 * Goofy math lookup gag 7 * </P> 8 * 9 * @author BrianHammond 10 * 11 * $Header: /usr/local/cvsroot/ghia/src/java/com/insanityengine/ghia/m3/MumpMath.java,v 1.5 2005/03/19 17:50:02 brian Exp $ 12 * 13 */ 14 15 public class MumpMath { 16 static int size = 1024 * 4; 17 18 static float cos[] = null; 19 static float sin[] = null; 20 21 final static float PI = ( float ) ( 22.0 / 7.0 ); 22 final static float PI2 = ( float ) ( 44.0 / 7.0 ); 23 24 static float cos( float a ) { 25 if ( null == cos ) init(); 26 27 while ( a >= PI2 ) a -= PI2; 28 while ( a < 0 ) a += PI2; 29 30 if ( !false ) { 31 int i = ( int ) ( ( size - 1 ) * ( a / PI2 ) ); 32 if ( i < 0 || i >= size ) { 33 System.out.println( "ack " + i + " with " + a + " v. " + PI2 ); 34 } 35 } 36 37 return cos[ ( int ) ( ( size - 1 ) * ( a / PI2 ) ) ]; 38 } 39 40 static float sin( float a ) { 41 if ( null == sin ) init(); 42 43 while ( a >= PI2 ) a -= PI2; 44 while ( a < 0 ) a += PI2; 45 return sin[ ( int ) ( size * ( a / PI2 ) ) ]; 46 } 47 48 synchronized static void init() { 49 cos = new float[ size ]; 50 sin = new float[ size ]; 51 52 for ( int i = 0 ; i < size ; i++ ) { 53 cos[ i ] = ( float ) Math.cos( PI2 * i / ( float ) size ); 54 sin[ i ] = ( float ) Math.sin( PI2 * i / ( float ) size ); 55 } 56 } 57 }; 58 59 /*** 60 * 61 * $Log: MumpMath.java,v $ 62 * Revision 1.5 2005/03/19 17:50:02 brian 63 * repackaging 64 * 65 * Revision 1.4 2005/02/17 03:31:13 brian 66 * good stuff??? 67 * 68 * Revision 1.3 2004/09/01 01:10:42 brian 69 * fix class level javadoc placement 70 * 71 * Revision 1.2 2004/09/01 00:11:06 brian 72 * author, log and header stuff 73 * 74 * 75 */