Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Trig Problem, missing arc functions? (http://www.chiefdelphi.com/forums/showthread.php?t=83048)

Lord_Jeremy 18-02-2010 21:27

Trig Problem, missing arc functions?
 
Hey. So I'm in the midst of rewriting my autonomous routines. I'm implementing a navigation system. One of the functions I'm writing needs to find the angle of a right triangle, given the base and height. So I wrote double dAngle = Math.atan( y / x ); Netbeans highlighted this as an error... So then I deleted .atan and reinserted . and let the autocomplete come up. To my surprise, I see no atan or arctan or arcanything in the list of available methods. What the heck? Do we seriously not have inverse trig functions in our incredibly minimalist version of Java? Not having ArrayList was bad enough, but at least I could use Vectors with a million object casts everywhere. I don't even know how I can do what I'm doing without inverse trig. Google searching yields two options: Use a third party library or write my own lookup table-using methods. Have any other teams run into this issue? What are your solutions? Bah, and I was upset I had to write my own nsign...

Patrick Chiang 18-02-2010 21:33

Re: Trig Problem, missing arc functions?
 
Code:

import com.sun.squawk.util.MathUtils;
Javadocs ;P

Lord_Jeremy 18-02-2010 22:18

Re: Trig Problem, missing arc functions?
 
Lol I must've missed something because I didn't even know we had squawk... I thought we were just running barebones J2ME

Robototes2412 18-02-2010 22:20

Re: Trig Problem, missing arc functions?
 
does squawk have arrays?

Lord_Jeremy 18-02-2010 22:28

Re: Trig Problem, missing arc functions?
 
It couldn't possibly have ArrayLists like you might be used to because this version of java doesn't support template classes. That means you can't do Class<Type>. You can use a Vector just like an ArrayList if you cast the return of elementAt(int) as the class you're expecting.

For example, the following code sets an array of doubles and then prints each value increased by 10.

Code:

import java.util.Vector;

public class Test
{
        public static void main(String[] args)
        {
                Vector vec = new Vector();
               
                vec.addElement( new Double( 1.0 ) );
                vec.addElement( new Double( -5.0 ) );
                vec.addElement( new Double( 2.2 ) );

                for( int i = 0; i < vec.size(); i++ )
                {
                        System.out.println( 10 + ( (Double)vec.elementAt(i) ).doubleValue() );
                }
        }
}


JewishDan18 19-02-2010 00:10

Re: Trig Problem, missing arc functions?
 
Our team (for some reason) encountered erros when trying to include the MathUtils, so we wrote our own atan2 using taylor series. Knew that calc would be useful somewhere!

Lord_Jeremy 19-02-2010 00:18

Re: Trig Problem, missing arc functions?
 
Bah, I'm in BC but we're not getting to that for another week IIRC...


All times are GMT -5. The time now is 09:38.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi