![]() |
Angle from X,Y
How do you find the angle from (X, Y)? :confused:
And how do you optimize this for realtime on the FRC? :confused: And One Of Astronouth's Rare Contensts: Why would I care? :D |
Re: Angle from X,Y
Angle from (x,y) (I'm assuming on a normal Cartesian Plane) to what in relation to what as a vertex?
ie. angle between (x,y) and x-axis with origin as vertex. |
Re: Angle from X,Y
The angle between (0,0) and (x,y) in relation to the x axis (A horizantal line, y=0)
|
Re: Angle from X,Y
The inverse tangent function (arctan) will give you the angle from the origin to a point. For example: given (x,y), arctan(y/x) = the angle from the origin to the point (x,y).
If you search CD for something like "arctan" or "trig" or "trigonometry", you should get a fair amount of results already covering implementation of trigonometric functions on the FRC controller. I don't have any experience using these, myself, but I've heard that a few teams have had success with using an arbitrary degree Taylor series approximation of trig functions. |
Re: Angle from X,Y
Doesn't arc tangent return an angle for a given slope? As in: -90 to 90.
I'm talking about 360 degrees. Like a Rectangular to Polar converter thing. |
Re: Angle from X,Y
Quote:
|
Re: Angle from X,Y
:WHAP: Duh
Code:
unsigned int GetAngle(signed int X, signed int Y)[Changed that tan to arctan] |
Re: Angle from X,Y
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.
|
Re: Angle from X,Y
Quote:
Quote:
|
Re: Angle from X,Y
This is the formula that LeoM posted a while back to get the angle from rectangular coordinates. Worked extremely well back in 2002
Temp1 was the positive distance in X direction Temp2 was the positive distance in Y direction temp3 = (temp2*127) / SQR((temp1*temp1)+(temp2*temp2)) 'Make values on a 127 unit circle ss_degrees = ((1-(temp3/118))*(((temp3+181)*temp3+744)/769))+((temp3/118)*(((((3*temp3-707)*temp3+42611)/20))+((temp3-115)/3))) ss_degrees = (ss_degrees*180)/128 'Convert to Degrees |
Re: Angle from X,Y
Ay. The problem is I don't get what it's doing.
|
Re: Angle from X,Y
My current code is like this:
Code:
#define abs(Num) ( ((Num) < 0) ? (0 - (Num)) : (Num) ) |
Re: Angle from X,Y
Quote:
The best advice I've ever heard about optimization is "Don't -- until you need to." You generally want to get your code working, and only then worry about optimizing -- if necessary. |
Re: Angle from X,Y
I was refeing to post 1:
Quote:
|
Re: Angle from X,Y
Quote:
|
| All times are GMT -5. The time now is 11:49. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi