Go to Post Clearly and clearly, the go-to place is Chief Delphi. It connects all the dots. - JaneYoung [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 Rating: Thread Rating: 2 votes, 4.00 average. Display Modes
  #1   Spotlight this post!  
Unread 01-17-2010, 03:29 PM
ionine_ ionine_ is offline
Registered User
FRC #0334
 
Join Date: Jan 2010
Location: Brooklyn, NY
Posts: 10
ionine_ is on a distinguished road
Math.atan2 ?

Hello. This year my team is planning to use Mecanum wheels, and we are programming in Java. Since we plan to use RobotDrive.holonomicDrive, we need to convert joystick (Xbox controller, and some of the axes are inverted so WPILibJ's Joystick.getMagnitude, etc. are out of the question) and our algorithm for this involves Math.atan2. However, the JRE on the cRIO doesn't seem to have such a feature. Is there any way to forgo using Math.atan2 or is there some other replacement for converting Cartesian coordinates to polar coordinates?

Thank you,
Ilya Ostrovskiy, #334.
Reply With Quote
  #2   Spotlight this post!  
Unread 01-17-2010, 04:01 PM
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
Re: Math.atan2 ?

Look in the package com.sun.squawk.util.MathUtils for extra math functions.

static double acos(double a)
Returns the arc cosine of an angle, in the range of 0 through pi.
static double asin(double a)
Returns the arc sine of an angle, in the range of -pi/2 through pi/2.
static double atan(double a)
Returns the arc tangent of an angle, in the range of -pi/2 through pi/2.
static double atan2(double y, double x)
Converts rectangular coordinates (x, y) to polar (r, theta).
static double exp(double a)
Returns Euler's number e raised to the power of a double value.
static double expm1(double a)
Returns ex -1.
static double IEEEremainder(double x, double p)
Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard.
static double log(double a)
Returns the natural logarithm (base e) of a double value.
static double log1p(double a)
Returns the natural logarithm of the sum of the argument and 1.
static double pow(double x, double y)
Returns the value of the first argument raised to the power of the second argument.
static double rint(double a)
Returns the double value that is closest in value to the argument and is equal to a mathematical integer.
static long round(double a)
Returns the closest long to the argument.
static int round(float a)
Returns the closest int to the argument.
static double scalbn(double x, int n)
performs x*2^n by exponent manipulation

(By language specification rules we aren't allowed to add non Java ME methods to the java.* package).
Reply With Quote
  #3   Spotlight this post!  
Unread 01-17-2010, 04:03 PM
ionine_ ionine_ is offline
Registered User
FRC #0334
 
Join Date: Jan 2010
Location: Brooklyn, NY
Posts: 10
ionine_ is on a distinguished road
Re: Math.atan2 ?

Thank you very, very, much!
Reply With Quote
  #4   Spotlight this post!  
Unread 02-23-2010, 11:38 PM
Geek 2.0 Geek 2.0 is offline
Registered User
FRC #0107
Team Role: Programmer
 
Join Date: Sep 2009
Rookie Year: 2008
Location: Holland, MI
Posts: 120
Geek 2.0 will become famous soon enough
Re: Math.atan2 ?

Any reason why they didn't include the java.lang.Math ones? They really didn't include many in there...
Reply With Quote
  #5   Spotlight this post!  
Unread 02-24-2010, 02:52 PM
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: Math.atan2 ?

Quote:
Originally Posted by Geek 2.0 View Post
Any reason why they didn't include the java.lang.Math ones? They really didn't include many in there...
Quote:
Originally Posted by derekwhite View Post
(By language specification rules we aren't allowed to add non Java ME methods to the java.* package).
The CLDC was designed to target devices without a lot of resources, like cell phones. The extra Math functions weren't necessary.
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award
Reply With Quote
  #6   Spotlight this post!  
Unread 02-25-2010, 12:09 AM
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: Math.atan2 ?

Team 20 used some fancy calculus and made our own atan2 function, using a taylor series
Reply With Quote
  #7   Spotlight this post!  
Unread 02-25-2010, 11:07 AM
ericarseneau ericarseneau is offline
Registered User
no team
 
Join Date: Jan 2010
Location: San Diego
Posts: 30
ericarseneau is an unknown quantity at this point
Re: Math.atan2 ?

Unfortunately to be able to call this Java, we had to follow a specification that defines EXACTLY what classes and what methods exist on classes in the java.* and javax.* packages. For the Java that this VM implements, CLDC 1.1 and IMP 1.0, these functions dont exist.

The spec however, allows us to do whatever we want in OEM extensions, ie in other packages. So we added some of the functionality that we fealt was missing.

Its annoying, but it is what it is.
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
Tetra Math ZZII 527 General Forum 34 01-22-2005 02:13 PM
A math haiku mtrawls Chit-Chat 0 03-11-2004 08:22 PM
math.h library mightywombat Programming 24 01-17-2004 01:10 PM
Math Hermione692 Chit-Chat 15 02-21-2003 10:47 AM
Math Help!!! Leon Machado IV Chit-Chat 7 11-16-2001 07:38 PM


All times are GMT -5. The time now is 07:31 AM.

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