10 Replies  1613 Views  Last Post: 17 March 2013  03:56 PM
#1
Algorithms that convert x and y value to an angle (degrees or radian.
Posted 21 February 2013  02:58 AM
I am looking for algorithms that can convert x and y value on a Cartesian plane (x,y) to an angle. The angle can be 0360 degrees or 02π radian.
Does anyone know of such algorithms?
I have looked for geometric algorithms on Google. I have also found a list of algorithms on Wikipedia, but no luck finding this particular algorithm.
Also are there search databases that solely contain algorithms?
Thank you in Advance.
Here can you see a simple visual representation:
Replies To: Algorithms that convert x and y value to an angle (degrees or radian.
#2
Re: Algorithms that convert x and y value to an angle (degrees or radian.
Posted 21 February 2013  03:53 AM
#3
Re: Algorithms that convert x and y value to an angle (degrees or radian.
Posted 21 February 2013  08:30 AM
How is you linear algebra?
#4
Re: Algorithms that convert x and y value to an angle (degrees or radian.
Posted 21 February 2013  08:39 AM
stayscrisp, on 21 February 2013  03:53 AM, said:
Okej i'll try a different approach. See new image.
For example in the image if have a coordinate (1.5,2).
From this coordinates i want to calculate angle z.
Numbers on the x and y axis can be positive or negative.
The algorithm:
Input: An x and y value. (For example input (1.5,5).
Output: angle (z). (105 degrees) (i don't know if this is right just example />)
#5
Re: Algorithms that convert x and y value to an angle (degrees or radian.
Posted 21 February 2013  08:45 AM
ButchDean, on 21 February 2013  08:30 AM, said:
How is you linear algebra?
You are thinking to difficult />
#6
Re: Algorithms that convert x and y value to an angle (degrees or radian.
Posted 21 February 2013  09:12 AM
#7
Re: Algorithms that convert x and y value to an angle (degrees or radian.
Posted 22 February 2013  01:31 AM
stayscrisp, on 21 February 2013  09:12 AM, said:
I know how i can calculate this angle with atan2. I know math
I was not asking for a function how to calculate it. I was asking for a algorithm example.
Because i am learning about algorithms.
I have posted this question on 5 diffent forums.
I have gotten few algorithms for calculating this angle.
This helps me understand algorithms.
_____________________________________________________
From johng on mathhelpforum.com
____________________________________________________
double angle(x,y)
d=x*x+y*y
if (d is 0) return error
d=sqrt(d)
v=arccos(x/d)
if (y<0) v=2*piv
return v
________________________________________________________
From Mathmom on answer.yahoo.com
_________________________________________________________
Q1: If x > 0, y > 0 > θ = arctan(y/x)
Q2: If x < 0, y > 0 > θ = arctan(y/x) + 180° or arctan(y/x) + π
Q3: If x < 0, y < 0 > θ = arctan(y/x) + 180° or arctan(y/x) + π
Q4: If x > 0, y < 0 > θ = arctan(y/x) + 360° or arctan(y/x) + 2π
If you guys know another algorithm?
The more the better. I want to analyse the difference between them.
_________________________________________________________
#8
Re: Algorithms that convert x and y value to an angle (degrees or radian.
Posted 22 February 2013  12:21 PM
How do you intend analyzing these algorithms? They're pretty basic.
#9
Re: Algorithms that convert x and y value to an angle (degrees or radian.
Posted 17 March 2013  07:48 AM
"No i don't know any algorithms"
I'm doing a application Android application test. I'm testing battery use and speed of algorithms using different sensors.
I have already made 2 algorithms myself and collected 4 algorithms from forums and researchliterature.
So i'm done. Despite the unneccesary discussion, thank you for your time.
ButchDean, on 22 February 2013  12:21 PM, said:
How do you intend analyzing these algorithms? They're pretty basic.
#10
Re: Algorithms that convert x and y value to an angle (degrees or radian.
Posted 17 March 2013  10:55 AM
Good luck!
#11
Re: Algorithms that convert x and y value to an angle (degrees or radian.
Posted 17 March 2013  03:56 PM
JeffreyR, on 22 February 2013  04:31 AM, said:
_________________________________________________________
Q1: If x > 0, y > 0 > θ = arctan(y/x)
Q2: If x < 0, y > 0 > θ = arctan(y/x) + 180° or arctan(y/x) + π
Q3: If x < 0, y < 0 > θ = arctan(y/x) + 180° or arctan(y/x) + π
Q4: If x > 0, y < 0 > θ = arctan(y/x) + 360° or arctan(y/x) + 2π
If you guys know another algorithm?
The more the better. I want to analyse the difference between them.
_________________________________________________________
This is the atan2() function.
Quote
In the context of your question, the math and algorithms are one and the same. An algorithm is just a finite series of steps that return a specific result. As such, the math falls under the scope of an algorithm here. The inverse trig functions return angles, and are defined on restricted domains. You can get the correct values on all the domains by breaking them up piecewise and compensating appropriately. That's how the atan2() function works, as well as your approach with inverse cosine. You could play around with inverse sine in the same way.
You were getting a lot of direct and relevant answers on this.
