Thread: Angle from X,Y
View Single Post
  #9   Spotlight this post!  
Unread 10-04-2004, 22:51
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: Angle from X,Y

Quote:
Originally Posted by Astronouth7303
:WHAP: Duh

Unfortunately, you have to use a float for Angle because angles between -45 and 45 are as important as the others. I suppose I could flip X and Y around for that.

[Changed that tan to arctan]
You don't need a float to represent (Y/X). Just try ((Y*100)/X) and scale your arctangent function to reflect this. This works well if you are using a lookup table. However, I would use a float if I was using a McLaurin series. Otherwise you are likely to overload a long the when you start getting into the higher powers (100^5 is way too big). Also you might want to check to make sure X is not zero before dividing by it.

Quote:
Originally Posted by michael_obrien
I don't know much about programming, but I screwed around with winamp AVS for a while, and on that there was a function known as "atan2(x,y)" which was the same as atan but it automatically corrected for quadrants... isn't there anything simular in C? I mean, C is much more powerful than that AVS junk from what I understand, it should at least have the same capabilities.
IFI doen not provide us with libraries of functions like this, but C certainly has them. The standard atan function requires more prcessing and floating point math than most FIRST programmers want to put in thier RC
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"

Last edited by The Lucas : 10-04-2004 at 23:05.