0
$\begingroup$

How can I determine the 3D coordinates (x,y,z) from a given distance r with origin at (0,0,0).

I know that in case of 2D (x,y),
x = r.sin(theta) and
y = r.cos(theta),
where theta is angle in degrees.

Do we have a similar formula for the 3D case?

$\endgroup$
4
  • $\begingroup$ Look it up here: spherical coordinates $\endgroup$
    – AsafHaas
    Apr 10, 2017 at 13:04
  • $\begingroup$ @AsafHaas link is broken $\endgroup$
    – nashynash
    Apr 10, 2017 at 13:10
  • $\begingroup$ @nashynash: no, it's not. Wikipedia. $\endgroup$
    – user65203
    Apr 10, 2017 at 13:10
  • $\begingroup$ ok. Now it shows correctly $\endgroup$
    – nashynash
    Apr 10, 2017 at 13:13

3 Answers 3

1
$\begingroup$

You have spherical coordinates: \begin{align} x&=r\sin\phi\cos\theta\\ y&=r\sin\phi\sin\theta\\ z&=r\cos\phi\\ \end{align} $\phi$ and $\theta$ are the equivalent of latitude and longitude.

$\endgroup$
3
  • $\begingroup$ Is θ between [0,360]. If so what about ϕ? $\endgroup$
    – nashynash
    Apr 10, 2017 at 13:11
  • $\begingroup$ $0\le\phi\le\pi$, $0\le\theta\le2\,\pi$ (in radians.) $\endgroup$ Apr 10, 2017 at 13:15
  • $\begingroup$ Thank you very much. You answer works perfect for me. $\endgroup$
    – nashynash
    Apr 10, 2017 at 13:17
0
$\begingroup$

The $\theta$-thing is called "parameterization". Because the distance between $(x,y)$ and $(0,0)$ in $\mathbb{R}^{2}$ (think of this as your "2D") is defined as $\sqrt{x^{2}+y^{2}}$, so you saw that we can write $(x,y)$ using only one parameter, $\theta$, given the distance, $r$. In the same token, since in $\mathbb{R}^{3}$ (think of this as your "3D") the distance between $(x,y,z)$ and $(0,0,0)$ is defined as $\sqrt{x^{2}+y^{2}+z^{2}}$, we can use what is called "spherical parameterization" to write $(x,y,z)$ in another form. In case you just want to know the intuition behind this this: note that $r = \sqrt{x^{2} + y^{2}}$ is equivalent to $r^{2} = x^{2} + y^{2}$ (does this remind you of a circle of center $(0,0)$ and radius $r$? It should!); note that $r = \sqrt{x^{2}+y^{2}+z^{2}}$ is equivalent to $r^{2} = x^{2}+y^{2}+z^{2}$, which is the Cartesian equation for a sphere of center $(0,0,0)$ and radius $r$ in $\mathbb{R}^{3}$.

$\endgroup$
3
  • $\begingroup$ Thank you. But @Julian answer is what I am looking for. $\endgroup$
    – nashynash
    Apr 10, 2017 at 13:18
  • $\begingroup$ @nashynash, no problem no worries. You can still "make it up" by upvoting :D $\endgroup$
    – Megadeth
    Apr 10, 2017 at 13:19
  • $\begingroup$ I tried that already but I need 2 more points to do that :( $\endgroup$
    – nashynash
    Apr 10, 2017 at 13:23
0
$\begingroup$

Besides spherical coordinates, you can work by normalizing an arbitrary vector.

In 2D,

$$r\frac{\vec v}{\|\vec v\|}=\left(r\frac{v_x}{\sqrt{v_x^2+v_y^2}},r\frac{v_y}{\sqrt{v_x^2+v_y^2}}\right),$$

and in 3D...

$$r\frac{\vec v}{\|\vec v\|}=\left(r\frac{v_x}{\sqrt{v_x^2+v_y^2+v_z^2}},r\frac{v_y}{\sqrt{v_x^2+v_y^2+v_z^2}},r\frac{v_z}{\sqrt{v_x^2+v_y^2+v_z^2}}\right).$$

$\endgroup$
1
  • $\begingroup$ Thank you. But @Julian answer is what I am looking for. $\endgroup$
    – nashynash
    Apr 10, 2017 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.