Results 1 to 4 of 4

Math Help - is this formula correct ?

  1. #1
    Newbie
    Joined
    Jul 2011
    Posts
    3

    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.



    When I move the nose of the plane up, I move the image down:



    When I move the nose of the plane down, I move the picture up :



    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:




    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:



    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:



    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
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Senior Member abhishekkgp's Avatar
    Joined
    Jan 2011
    From
    India
    Posts
    495
    Thanks
    1

    Re: is this formula correct ?

    Quote Originally Posted by TexTwil View Post
    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.



    When I move the nose of the plane up, I move the image down:



    When I move the nose of the plane down, I move the picture up :



    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:




    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:



    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:



    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.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jul 2011
    Posts
    3

    Re: is this formula correct ?

    Quote Originally Posted by abhishekkgp View Post
    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.
    you mean :

    if I'm in 0, \pi/2
    imageX = imageX + h * cos(α)
    imageY = imageY + h * sin(α)

    if I'm in \pi/2, \pi
    imageX = imageX - h * cos(α)
    imageY = imageY + h * sin(α)

    if I'm in \pi, 3 \pi/2
    imageX = imageX - h * cos(α)
    imageY = imageY - h * sin(α)

    if I'm in 3 \pi/2, 0
    imageX = imageX + h * cos(α)
    imageY = imageY - h * sin(α)

    ?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Jul 2011
    Posts
    3

    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



    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)
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 15
    Last Post: July 29th 2011, 02:39 AM
  2. Showing that the formula is correct.
    Posted in the Algebra Forum
    Replies: 3
    Last Post: April 7th 2011, 12:23 PM
  3. Replies: 8
    Last Post: September 5th 2010, 01:11 PM
  4. Is this formula correct?
    Posted in the Calculus Forum
    Replies: 1
    Last Post: March 14th 2010, 02:00 PM
  5. Correct formula for average headcount
    Posted in the Math Topics Forum
    Replies: 2
    Last Post: January 21st 2007, 12:41 PM

Search Tags


/mathhelpforum @mathhelpforum