is this formula correct ?
Hi,
I'm a develepper and I need help with basic trigonometry.
In my application I have a image representing the level of the "artificial horizon" in a plane. Blue is the sky, brown is the ground.
http://f.cl.ly/items/2W3I353z0d3S472...29.38%20PM.png
When I move the nose of the plane up, I move the image down:
http://f.cl.ly/items/1U3G2o1e3u2e442...31.39%20PM.png
When I move the nose of the plane down, I move the picture up :
http://f.cl.ly/items/3B2S432l030r1x3...33.36%20PM.png
This is called the "pitch"
So far I've been modifying only the x axis of the image:
When I "roll" the plane I rotate the picture either to the left or right:
http://f.cl.ly/items/2D0K010q2l2p2i0...36.15%20PM.png
Now, the problem is that once I rotated the picture and want to modify the "pitch", I dont know which formula to use to find the correct x,y to move the picture towards the sky or ground direction:
http://f.cl.ly/items/1L0v3H2Y0X2g0L0...0PM%20copy.png
In other words, when I rotate the picture with an angle β, what are the x, y value to add to the center of the image to move it on the red line ?
I thought that using simple trigonometry should work:
http://f.cl.ly/items/192X3x2X251L3l0...0PM%20copy.png
cos(α) = x /h
sin(α) = y / h
so
x = h * cos(α)
y = h * sin(α)
then simply add the x and y to the current coordinates of the image. The resulting behaviour in my application is not correct though :(
Is this a correct formula to use ?
thanks,
Tex
Re: is this formula correct ?
Quote:
Originally Posted by
TexTwil
Hi,
I'm a develepper and I need help with basic trigonometry.
In my application I have a image representing the level of the "artificial horizon" in a plane. Blue is the sky, brown is the ground.
http://f.cl.ly/items/2W3I353z0d3S472...29.38%20PM.png
When I move the nose of the plane up, I move the image down:
http://f.cl.ly/items/1U3G2o1e3u2e442...31.39%20PM.png
When I move the nose of the plane down, I move the picture up :
http://f.cl.ly/items/3B2S432l030r1x3...33.36%20PM.png
This is called the "pitch"
So far I've been modifying only the x axis of the image:
When I "roll" the plane I rotate the picture either to the left or right:
http://f.cl.ly/items/2D0K010q2l2p2i0...36.15%20PM.png
Now, the problem is that once I rotated the picture and want to modify the "pitch", I dont know which formula to use to find the correct x,y to move the picture towards the sky or ground direction:
http://f.cl.ly/items/1L0v3H2Y0X2g0L0...0PM%20copy.png
In other words, when I rotate the picture with an angle β, what are the x, y value to add to the center of the image to move it on the red line ?
I thought that using simple
trigonometry should work:
http://f.cl.ly/items/192X3x2X251L3l0...0PM%20copy.png
cos(α) = x /h
sin(α) = y / h
so
x = h * cos(α)
y = h * sin(α)
then simply add the x and y to the current coordinates of the image. The resulting behaviour in my application is not correct though :(
Is this a correct formula to use ?
thanks,
Tex
simply adding them with the current coordinates won't work. you have to make sure that u have added them with correct sign. for example the x=h*cos(a) would be added with a negative sign while the y=h*sin(a) would be added with a positive sign.
Re: is this formula correct ?
Re: is this formula correct ?
It's "almost" working but there is still something wrong as you can see on the following video: in the beginning it behaves correctly but the image does not ends up on the same position where it started
http://<a href="http://www.youtube.c... - YouTube</a>
I wonder if I shall rotate the image all the time around the center of the screen instead of rotating it around its center (which moves when I apply the pitch)