4
votes

Background Info

Consider a spherical coordinate system like the one shown here:

Coordinate System
(source: shokhirev.com)

For a particular point, we specify its location by (r, theta, phi).

A plane can be described in this coordinate system as the set of all points (r, theta, phi) such that phi = phi'.

The Problem

Assume we have a single plane given by a fixed phi=phi'. For an arbitrary point (r, theta, phi) what are the fastest and simplest ways to compute the distance from (r, theta, phi) to the plane defined by phi=phi'?

Essentially, I am trying to find a simple formula for point to plane distance in spherical coordinates.

What I've tried

I think it would suffice to simple convert from spherical to Cartesian coordinates to generate a point (x,y,z) = (r, theta, phi) and then to generate a plane also in Cartesian coordinates. Then I could use standard formulae for the distance from a point to a plane in Cartesian coordinates. This approach is not optimal since I need to run this computation billions of times in the inner loop of my code.

An ideal answer would tell me how do compute this distance without transforming into Cartesian coordinates. However, it would also be useful if someone could verify that my idea in "What I've tried" is reasonable.

Thanks in advance!

4

4 Answers

1
votes

Your approach is "correct", but it is a bit to too generic for this problem. In your problem you are dealing with a specific kind of plane : A plane which passes through the z axis.

Given this fact, we can try a short-cut. Suppose we rotate the coordinate system about the z axis to get another system (X, Y, z) such that the plane you gave earlier is now the X-z plane.

In this new system the coordinates of the point are (r, theta, phi - phi'). Thus, the projection on the X-z plane is r * sin( theta ) * sin( phi - phi' ). This the final answer, since the length of the projection of the point on our plane is the same in both coordinate systems.

If we were dealing with a generic plane, your approach would have been better.

0
votes

If you are looking for the opposite side of r (not in the phi plane), that should be given by:

d = |r|sin(90 - theta)

Since we have a right triangle.

0
votes

Just another approach to get @Parakram Majumdar's answer.

A plane can be parametrized by a unit vector perpendicular to the plane n and by the distance of the plane from the origin, b (see http://mathworld.wolfram.com/Point-PlaneDistance.html). Since your plane passes through the origin, we have b=0, and the unit vector normal to the plane is the unit vector in phi direction, which is phi=[-sin(phi'), cos(phi'), 0]. The distance a of a point r form the plane is just the dot product, n*r:

n*r = [-sin(phi'), cos(phi'), 0] * [r*sin(theta)*cos(phi), r*sin(theta)*sin(phi), r cos(theta)] = r*sin(theta)*sin(phi-phi')
0
votes

Isn't it r*tan( phi )?

Drop into the xz plane (assuming the y-axis is the polar axis) and the angle phi is the angle between the "new plane" and the current phi position.

In the diagram below, phi actually equals (new phi - current phi).

enter image description here