Results 1 to 7 of 7

Math Help - How can I get coordinates for a position given a specified heading in degrees?

  1. #1
    Newbie
    Joined
    Dec 2009
    Posts
    4

    How can I get coordinates for a position given a specified heading in degrees?

    Hi Maths forum

    The problem I have is actually for a program I am writing, I just cant figure it out though.

    Let's say I have a fixed 2D cooridnate system using Y and X coords, I also have a character that can be facing in any direction. His direction is given as a heading in degrees. For example, 0 is north (Y direction), 180 is south (-Y direction) X is east...etc...

    Let's say I wish to find the coordinates of a point that is directly in front of the person, no matter which way he is facing. For instance, I might want the coords for 2 units in front of the character. How would I do this? To make it more clear, if the character is facing south (180), the position I am looking for will be (-2, 0)

    Can anyonep provide an equation for this?

    thanks for any answer Much appreciated
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    skeeter's Avatar
    Joined
    Jun 2008
    From
    North Texas
    Posts
    11,695
    Thanks
    450
    Quote Originally Posted by Aphex View Post
    Hi Maths forum

    The problem I have is actually for a program I am writing, I just cant figure it out though.

    Let's say I have a fixed 2D cooridnate system using Y and X coords, I also have a character that can be facing in any direction. His direction is given as a heading in degrees. For example, 0 is north (Y direction), 180 is south (-Y direction) X is east...etc...

    Let's say I wish to find the coordinates of a point that is directly in front of the person, no matter which way he is facing. For instance, I might want the coords for 2 units in front of the character. How would I do this? To make it more clear, if the character is facing south (180), the position I am looking for will be (-2, 0)

    Can anyonep provide an equation for this?

    thanks for any answer Much appreciated
    using a standard trig angle reference ... east = 0 degrees, north = 90 degrees, west = 180 degrees, south = 270 degrees

    x = r\cos{\theta}

    y = r\sin{\theta}

    where \theta is the angle referenced from east (0) , and r is the distance from the origin.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Dec 2009
    Posts
    4
    Thanks for that.

    Although, I haven't used sin and cos for so long, could you give me an brief worked example. Is something like this correct? The coordinates seem to come out wrong
    heading = 200 degrees from east
    distance from origin = 2

    x = 2 * cos(200)
    y = 2 * sin(200)

    x = -1.87
    y = -0.68
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor
    skeeter's Avatar
    Joined
    Jun 2008
    From
    North Texas
    Posts
    11,695
    Thanks
    450
    those coordinates are correct ... 200 degrees is in quad III , x and y are both negative.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Dec 2009
    Posts
    4
    Your right, they are pretty much correct, although, not quite how they should be. Here is another example though.

    heading = 300 degrees from east
    distance from origin = 2

    x = 2 * cos(300)
    y = 2 * sin(300)

    x = 1
    y = -1.73
    Surely thats not right.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    MHF Contributor
    skeeter's Avatar
    Joined
    Jun 2008
    From
    North Texas
    Posts
    11,695
    Thanks
    450
    note that angles are measured counter-clockwise from 0 degrees (east)

    300 degrees is in quadrant IV ... x is positive, y is negative ... and the values you calculated are correct.

    need more confirmation? go to the link ...

    Convert Polar to Rectangular Coordinates - Calculator
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Dec 2009
    Posts
    4
    Thanks for all your replies. This does make sense when thinking of it travelling counter-clockwise and starting from east.

    Cheers
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 4
    Last Post: January 26th 2011, 02:11 PM
  2. Replies: 0
    Last Post: January 25th 2011, 02:01 PM
  3. Replies: 2
    Last Post: April 28th 2010, 06:28 PM
  4. Replies: 5
    Last Post: January 13th 2010, 11:50 AM
  5. Replies: 2
    Last Post: April 6th 2009, 09:19 AM

Search Tags


/mathhelpforum @mathhelpforum