Results 1 to 5 of 5

Math Help - vidoe gamer programmer needs help with a trigonometry qustion.

  1. #1
    Newbie
    Joined
    Apr 2011
    Posts
    2

    vidoe gamer programmer needs help with a trigonometry qustion.

    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.
    Last edited by topsquark; April 27th 2011 at 02:17 PM. Reason: Inappropriate comment
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Master Of Puppets
    pickslides's Avatar
    Joined
    Sep 2008
    From
    Melbourne
    Posts
    5,236
    Thanks
    28
    What is the x-input and y-input? What do they represent?
    Follow Math Help Forum on Facebook and Google+

  3. #3
    MHF Contributor
    Joined
    Oct 2009
    Posts
    5,527
    Thanks
    773
    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.
    Last edited by emakarov; April 27th 2011 at 03:14 PM.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Apr 2011
    Posts
    2
    Quote Originally Posted by pickslides View Post
    What is the x-input and y-input? What do they represent?
    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.

    Quote Originally Posted by emakarov View Post
    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.
    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.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    MHF Contributor
    Joined
    Oct 2009
    Posts
    5,527
    Thanks
    773
    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.

    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.

    Code:
    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
    Now, angles between (0, -1) and (x, y) are computed by g(x,y) where

    g(x,y) = f(-y,x)

    This needs to be tested.

    Edit: formatting.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. groups qustion
    Posted in the Discrete Math Forum
    Replies: 5
    Last Post: September 29th 2010, 03:47 PM
  2. Qustion about vector identity
    Posted in the Advanced Algebra Forum
    Replies: 4
    Last Post: August 21st 2010, 02:07 AM
  3. Qustion on the remainder theorem:
    Posted in the Algebra Forum
    Replies: 8
    Last Post: September 23rd 2009, 02:04 PM
  4. cube cross product qustion..
    Posted in the Advanced Applied Math Forum
    Replies: 2
    Last Post: August 23rd 2009, 10:41 AM
  5. cross product qustion..
    Posted in the Advanced Applied Math Forum
    Replies: 1
    Last Post: August 22nd 2009, 12:11 AM

Search Tags


/mathhelpforum @mathhelpforum