I am trying to learn how to calculate the XYZ coordinates of a point using the XYZ coordinates of an origin point, a horizontal and vertical angle, and 3d distance. I can make the calculations simply by projecting the points onto 2D planes, but is there a more straightforward way to do this in 3D?
I am trying to understand how a surveying total station calculates new point locations based on it's measured location, the 3d (slope) distance that it measures to a new point, and the measured horizontal and vertical angles that sight onto the new point location.
Thanks,
E
Just a note on conventions: 2D polar coordinates often use (radius, theta)
, where theta
is the 'horizontal' or 'azimuth' angle. It ranges from: theta=0
, the 2D point (x,y) = (radius,0)
on the X-axis, to: theta=2*PI
on the XY plane - an anti-clockwise direction as theta
increases. Now to confuse matters...
3D spherical coordinates (maintaining a right-handed coordinate system) often use coordinates: (radius, theta, phi)
. In this case, theta
is used for the 'vertical' or 'zenith' angle, ranging from theta=0
(the Z axis) to theta=PI
(the -Z axis). phi
is used for the azimuth angle.
Other texts will use different conventions - but this seems to be favoured by physicists and (some) mathematics texts. What matters is that you pick a convention and use it consistently.
Following this:
radius
: distance to the point. given an point (x,y,z)
in cartesian coordinates, we have the (pythagorean) radius: r = sqrt(x * x + y * y + z * z)
, e.g., 0 <= radius < +infinity
theta
: the zenith angle, where theta=0
is directly above (the +Z axis), and theta=PI
is directly below (the -Z axis), and theta=PI/2
is what you would consider an 'elevation' of 0 degrees, e.g.,0 <= theta <= PI
phi
: the azimuth angle, where phi=0
is to the 'right' (the +X axis), and as you turn 'anticlockwise', phi=PI/2
(the +Y axis), phi=PI
(the -X axis), phi=3*PI/2
(the -Y axis), and phi=2*PI
- equivalent to the phi=0
(back to the +X axis). e.g., 0 <= phi < 2*PI
Pseudo-code: (standard math library trigonometric functions)
From (radius, theta, phi)
you can find the point (x,y,z)
:
x = radius * sin(theta) * cos(phi);
y = radius * sin(theta) * sin(phi);
z = radius * cos(theta);
Conversely, you can find a (radius, theta, phi)
from (x,y,z)
:
radius = sqrt(x * x + y * y + z * z);
theta = acos(z / radius);
phi = atan2(y, x);
Note: it is important to use atan2
in the final equation, not atan
!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With