Go to Post Don't let the teams here be so much of an intimidation to you, but instead, an inspiration. They all had to start from the beginning, too. - Amanda Morrison [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 18-02-2010, 21:27
Lord_Jeremy's Avatar
Lord_Jeremy Lord_Jeremy is offline
Lord_Jeremy the Procrastinator
AKA: Jeremy Agostino
FRC #1546 (Chaos Inc.)
Team Role: Electrical
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Baldwin, New York
Posts: 45
Lord_Jeremy is an unknown quantity at this point
Send a message via ICQ to Lord_Jeremy Send a message via AIM to Lord_Jeremy Send a message via MSN to Lord_Jeremy Send a message via Yahoo to Lord_Jeremy
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...
__________________
Compiling...
Compiling...
Reply With Quote
  #2   Spotlight this post!  
Unread 18-02-2010, 21:33
Patrick Chiang Patrick Chiang is offline
Programming
FRC #3070 (Team Pronto)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Seattle
Posts: 162
Patrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to all
Re: Trig Problem, missing arc functions?

Code:
import com.sun.squawk.util.MathUtils;
Javadocs ;P
Reply With Quote
  #3   Spotlight this post!  
Unread 18-02-2010, 22:18
Lord_Jeremy's Avatar
Lord_Jeremy Lord_Jeremy is offline
Lord_Jeremy the Procrastinator
AKA: Jeremy Agostino
FRC #1546 (Chaos Inc.)
Team Role: Electrical
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Baldwin, New York
Posts: 45
Lord_Jeremy is an unknown quantity at this point
Send a message via ICQ to Lord_Jeremy Send a message via AIM to Lord_Jeremy Send a message via MSN to Lord_Jeremy Send a message via Yahoo to Lord_Jeremy
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
__________________
Compiling...
Compiling...
Reply With Quote
  #4   Spotlight this post!  
Unread 18-02-2010, 22:20
Robototes2412's Avatar
Robototes2412 Robototes2412 is offline
1 * 4 != 14
FRC #2412 (Robototes)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Bellevue
Posts: 312
Robototes2412 is on a distinguished road
Re: Trig Problem, missing arc functions?

does squawk have arrays?
Reply With Quote
  #5   Spotlight this post!  
Unread 18-02-2010, 22:28
Lord_Jeremy's Avatar
Lord_Jeremy Lord_Jeremy is offline
Lord_Jeremy the Procrastinator
AKA: Jeremy Agostino
FRC #1546 (Chaos Inc.)
Team Role: Electrical
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Baldwin, New York
Posts: 45
Lord_Jeremy is an unknown quantity at this point
Send a message via ICQ to Lord_Jeremy Send a message via AIM to Lord_Jeremy Send a message via MSN to Lord_Jeremy Send a message via Yahoo to Lord_Jeremy
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() );
		}
	}
}
__________________
Compiling...
Compiling...
Reply With Quote
  #6   Spotlight this post!  
Unread 19-02-2010, 00:10
JewishDan18's Avatar
JewishDan18 JewishDan18 is offline
Registered User
FRC #1700
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2007
Location: Sunnyvale, CA
Posts: 185
JewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to behold
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!
Reply With Quote
  #7   Spotlight this post!  
Unread 19-02-2010, 00:18
Lord_Jeremy's Avatar
Lord_Jeremy Lord_Jeremy is offline
Lord_Jeremy the Procrastinator
AKA: Jeremy Agostino
FRC #1546 (Chaos Inc.)
Team Role: Electrical
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Baldwin, New York
Posts: 45
Lord_Jeremy is an unknown quantity at this point
Send a message via ICQ to Lord_Jeremy Send a message via AIM to Lord_Jeremy Send a message via MSN to Lord_Jeremy Send a message via Yahoo to Lord_Jeremy
Re: Trig Problem, missing arc functions?

Bah, I'm in BC but we're not getting to that for another week IIRC...
__________________
Compiling...
Compiling...
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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