# Calculate Cartesian coordinates based on the distance and the angle

i'm trying to calculate the X and Z coordinate of a coordinate based on the angle and the distance of the origin (0,0,0). Even though I use a 3-dimensional system I watch from top down which basically means I ignore the Y-axis. See the image reference below so you can see what I mean.

Assuming I have the correct distance in Meters and the angle in Degrees I could calculate the cartesian coordinates relative to the center.

For this I use the following formulas:

X coordinate: d * cos(a * π / 180)

Z coordinate: d * sin(a * π / 180)

The 'd' is the distance, the 'a' is the angle.

The formula's above are the only ones that I found online in terms of calculating cartesian coordinates based on angle and distance, so I figured they are correct. As you can see in the image below the Z-axis (or the Y-Axis) is reversed. But even when I multiply the Z value with -1 I get wrong values.

Example: If I were to have a distance of 5 and a angle of 45 degrees I should basically have the (rounded) coordinate (3,53, 0, -3,53). Again, if you take the referenced image it makes more sense. I just replaced the Y with the Z axis.

Are the formulas wrong or am I doing something wrong? If you need something clearer just ask me and i'll try to explain it :)

Grid visualization image link (imgur)

• Is the "distance" you speak of the distance to the origin in 3-space or 2-space? If You start with the point $(x,y,z)$ at distance $5$ from the origin, and project it to the point $(x,0,z)$, the projection will not be at distance $5$ from the origin (unless $y$ was $0$ to begin with.) – saulspatz Feb 16 '18 at 15:22
• according to your picture, $z=-\cos(a\pi/180)$, $x= \sin(a\pi/180)$ – Vasya Feb 16 '18 at 15:23
• @Vasya Tested it on paper, you seem to be correct. Thanks! – Dubb Feb 16 '18 at 15:27

The main problem is that your equations are not consistent with your coordinate system.

Your equations are consistent with this coordinates, which is much more commonly used in mathematics: Unless otherwise specified, mathematical articles usually use this coordinate system when dealing with 2D problems.

There are two main characteristics:

1. The vertical axis increases upward, and the horizontal axis increases rightward.

2. The angles are consistent with the right-hand grip rule: angle increases in the anticlockwise direction.

For your coordinate system, you need to modify your equations, which are stated in one of the comments on your question.