What is the x-input and y-input? What do they represent?
Hello it has been quite some time since I was in high school math and I have a trigonometry question that I need help with for an Iphone game I have been working on. I need a function that takes 2 variables as inputs and return an angle (radians or degrees) as an output. Here is a simple chart of the inputs and outputs
input x | input y | output radians (output degrees)
0 | 1 | 1.57(180)
0 | -1 | 0
1 | 0 | .78(90)
.5 | -.5 | .39 (45)
-1 | 0 | 2.34(270)
Does that chart make sense? Let me know if you need additional clarifications. I supple the input and output and you supply me the function that created the outputs from the following inputs. I am not sure but I think ArcTan needs to be used. Thanks in advance.
It seems that the function should return the angle α such that vector (0, -1) rotated by α counterclockwise becomes vector (x, y).
Edit: The rotated vector (0, -1) does not have to become (x, y), but it should be parallel to it and point in the same direction.
The Iphone has 3 accelmeters in it. I care about 2 of them. The X and Y inputs represents the force of gravity in the x and y direction. They both range from 1 to -1. (example upright =1 and upside-down =-1 for the y.) So I assume the only thing that is relevant it the ratio of x and y and both of there signs.
I am not 100% sure what you mean by this. I suppose you could think of the input as a vector instead of 2 numbers.
Well, I believethe description concerning vector rotation is pretty clear. If you don't understand it, please point out exactly which word or phrase is not clear.I am not 100% sure what you mean by this. I suppose you could think of the input as a vector instead of 2 numbers.
In trigonimetry it is customary to count angles from the OX axis, and positive angles rotate counterclockwise. E.g., OY axis makes +90 degrees. Here is a function that I believe returns the angle between OX and the given vector (x, y); the return angle is in the range 0 ... 360 degrees.
Now, angles between (0, -1) and (x, y) are computed by g(x,y) whereCode:f(x,y) = if x = 0 if y > 0 return 90 else if y = 0 return undefined else if y < 0 return 270 else let a = arctan(y / x) in if x > 0 if y >= 0 return a // first quadrant else return 360 + a // fourth quadrant else return 180 + a // second and third quadrants
g(x,y) = f(-y,x)
This needs to be tested.
Edit: formatting.