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

1. ## 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

2. Originally Posted by Aphex
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.

3. 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

4. those coordinates are correct ... 200 degrees is in quad III , x and y are both negative.

5. 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.

6. 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

7. Thanks for all your replies. This does make sense when thinking of it travelling counter-clockwise and starting from east.

Cheers