|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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...
|
|
#2
|
|||
|
|||
|
Re: Trig Problem, missing arc functions?
Code:
import com.sun.squawk.util.MathUtils; |
|
#3
|
||||
|
||||
|
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
|
|
#4
|
||||
|
||||
|
Re: Trig Problem, missing arc functions?
does squawk have arrays?
|
|
#5
|
||||
|
||||
|
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() );
}
}
}
|
|
#6
|
||||
|
||||
|
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!
|
|
#7
|
||||
|
||||
|
Re: Trig Problem, missing arc functions?
Bah, I'm in BC but we're not getting to that for another week IIRC...
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Trig functions in C18 3.10 | dmlawrence | Programming | 9 | 08-02-2008 09:33 |
| Possiblity of using a few trig functions | baop858 | Programming | 4 | 18-01-2008 23:55 |
| Trig. Functions in EasyC | miketwalker | FIRST Tech Challenge | 5 | 07-12-2006 23:27 |
| speed of math.h trig functions? | Jared Russell | Programming | 4 | 07-02-2006 07:13 |
| Return of the Inverse Trig Functions | Leo M | Programming | 3 | 24-01-2002 08:12 |