Go to Post COMPETE like crazy for the 2 minutes you are on the field, COOPERATE like crazy all the rest of the time. When we play this way, we all win. - Chris Fultz [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 18-02-2005, 11:16
the_undefined's Avatar
the_undefined the_undefined is offline
German FES
AKA: Felix Geisendörfer
#1648 (Gearbox Gangstas)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Germany
Posts: 77
the_undefined has a spectacular aura aboutthe_undefined has a spectacular aura about
atan Problem - Need Help

Hi Guys,

I have a little problem getting the atan function of Team 296's Math Library to work for me. What I need is calculating the Degree my Joystick is looking it by using atan(x,y).

I already know how to use the sin/cos function and how to work with the binary radians (-8,388,608 to 8,388,607) that the functions operate in.

But for some reason the results I get back from atan seem to be different from the one sin/cos give me or in different words: Say behave nonlinear in cases they should:

Here is what I tried (after I had problems with weird results):
Code:
short long brad; int int_brad;

// should give me 8388608/4 Brad = 45 Degree back, according to the way sin/cos work
brad = atan(1,1);

// Transform short long to int to be able to print the result with printf();
// Drop the last 8 Bit (Should be 32768/4=8192 after that)
brad>>=8;

// Put value in an Int
int_brad = (int)brad; 

// Print the Value to the Screen
printf("int_brad = %d\n", (int)int_brad); 

// ====Output===
int_brad = 8511
Converting this into Degree I got 46 Degree but I didn't like that because sin/cos worked way more accurate for me than this. So I tried different Values and that showed that there must be a problem:


Code:
atan(1,1) = 8511        (should be 32768/4=8192         = 45 Degree)
atan(1,-1) = 24256     (should be -32768/4=-8192      = -45 Degree)
atan(1,0) = 1799        (should be 0/32768=0)            = 0 Degree)
atan(1,2) = 1799        (should be 11548)                  = 63.43 Degree) 
atan(1,-2) = 1799       (should be-11548)                 = -63.43 Degree)
atan(2,1) = -1800       (should be 4736)                   = 26.57 Degree)
atan(2,-1) = -30969    (should be -4736                   = -26.57 Degree)
Anybody out there that has an Idea what I could do wrong or somebody that already has atan working?

Thanks for your Help,

Felix
 


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
Programming Problem: Extremely Frustrating chantilly_team Programming 19 12-02-2005 23:00
Physics Problem Venkatesh Math and Science 13 30-11-2004 20:30
Ok one problem cantwell03 Programming 3 13-02-2003 07:28
The problem with scouting... archiver 2001 10 23-06-2002 23:49
Major problem with chipphua motors aka Scott White Motors 18 19-03-2002 19:44


All times are GMT -5. The time now is 04: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