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