Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   No atan() method in FRC version of java (http://www.chiefdelphi.com/forums/showthread.php?t=87052)

buildmaster5000 04-10-2010 20:52

No atan() method in FRC version of java
 
I am trying to program a swerve drive, and I need to use atan(), but netbeans always says it doesn't exist in my class. Yes I know there is getDirection() on the joystick, but I need to manipulate numbers after taking them from the joystick.

Thanks in advance

Alex

Jared Russell 04-10-2010 21:07

Re: No atan() method in FRC version of java
 
Alex:

Take a look in the com.sun.squawk.util.MathUtils package. There are implementations of many of the J2SE math functions, including atan() and atan2(), in there.

JewishDan18 05-10-2010 01:34

Re: No atan() method in FRC version of java
 
Team 20 had the same problem. We ended up writing a Talyor approximation and reflecting it about the axis to produce our own atan2 function.

buildmaster5000 05-10-2010 07:59

Re: No atan() method in FRC version of java
 
Quote:

Originally Posted by Jared341 (Post 976122)
Alex:

Take a look in the com.sun.squawk.util.MathUtils package. There are implementations of many of the J2SE math functions, including atan() and atan2(), in there.

What is the import line I need to use? I tried 'import com.sun.squawk.util.MathUtils;' and that did not work. I have yet to learn what Taylor series are in detail, so that would be a project for down the road.

buildmaster5000 06-10-2010 18:40

Re: No atan() method in FRC version of java
 
Ok well I figured it out. I needed to call MathUtils.atan(). I wasn't using MathUtils befroe. Thanks for the input though everybody.

biojae 06-10-2010 19:38

Re: No atan() method in FRC version of java
 
What are you using the atan() function for?
If you are going to have negative numbers for the input, it may be better to use atan2(x,y).

Ether 06-10-2010 20:23

Re: No atan() method in FRC version of java
 
Quote:

Originally Posted by biojae (Post 976316)
it may be better to use atan2(x,y).

Did you mean to say atan2(y,x)? Or does Java really reverse the order like Excel does. Say it ain't so.




biojae 06-10-2010 20:29

Re: No atan() method in FRC version of java
 
Quote:

Originally Posted by Ether (Post 976320)
Did you mean to say atan2(y,x)? Or does Java really reverse the order like Excel does. Say it ain't so.

Sorry, that was a typo.
Here is the actual function header:
Code:

double atan2(double y, double x) ;

buildmaster5000 09-10-2010 14:59

Re: No atan() method in FRC version of java
 
Quote:

Originally Posted by biojae (Post 976316)
What are you using the atan() function for?
If you are going to have negative numbers for the input, it may be better to use atan2(x,y).

I am using it to calcluate the desired angle of a wheel in a swerve configuration. I calculate the x and y components of the vector representing each wheel. Getting the magnitude (speed) is easy, but without atan, the angle was going to be a challenge.

Ether 11-10-2010 14:15

Re: No atan() method in FRC version of java
 
Quote:

Originally Posted by JewishDan18 (Post 976155)
Team 20 had the same problem. We ended up writing a Talyor approximation and reflecting it about the axis to produce our own atan2 function.

Taylor expansion is not the best tool to use for this purpose.

See the discussion about ATAN2 nonlinear model fitting here:

http://www.chiefdelphi.com/media/papers/2390




EricVanWyk 11-10-2010 15:19

Re: No atan() method in FRC version of java
 
Quote:

Originally Posted by Ether (Post 976837)
Taylor expansion is not the best tool to use for this purpose.

See the discussion about ATAN2 nonlinear model fitting here:

http://www.chiefdelphi.com/media/papers/2390



I spent the summer porting a fixed point math library to Arm's Thumb2 assembly, and learned a lot when I hit the arc-trig functions. At the high school level, suffice it to say that these functions are very-not-polynomials and therefore hate Taylor series expansions. At the college level, suffice it to say that if I ever teach numerical approximations the final exam will be to approximate arcsine.


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

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