Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm trying to work out an algorithm where, given the equation for a spiral in polar coordinates, $r(\theta)$, and a point rectilinear coordinates, $P(x,y)$, I can work out the minimum distance between that point and the curve traced by that spiral. I was hoping to have a general solution for any spiral form, but if that's not possible, then a solution for a Fermat spiral $$r(\theta)=\pm a\sqrt{\theta}$$ would be most preferable.

I've tried to find a global minima using the second and third differential of the distance equation, but I keep getting stumped. Any one have any ideas? Thanks very much in advance.

share|improve this question
2  
You could convert the point into polar coordinates, $(r_P,\theta_P)$, so that the square of its distance from $(r,\theta)$ is $r^2+r_P^2-2rr_P\cos(\theta-\theta_P)$. That seems easier to differentiate as a function of $\theta$. –  Rahul Jul 25 '12 at 15:38

2 Answers 2

Suppose the spiral is $r = f(\theta)$. So, any point on the spiral can be represented as $(f(\theta),\theta)$. The reference point $P(x,y)$ is fixed. For easier computation, convert P to polar coordinates as $P(r_0,\theta_0)$. Let $D(\theta)$ denote the squared distance between the point $(f(\theta),\theta)$ on the spiral and the reference point P.

$$D(\theta) = f^2(\theta)+r_0^2 - 2f(\theta)r_0\cos(\theta-\theta_0)$$ For the spiral that you have mentioned, consider the positive branch $f(\theta) = a\sqrt{\theta}$ .

$$D(\theta) = a^2\theta + r_0^2 -2 a r_0\sqrt{\theta}\cos(\theta-\theta_0)$$ $$D'(\theta) = a^2 +2ar_0\sqrt{\theta}\sin(\theta-\theta_0)-\frac{ar_0\cos(\theta-\theta_0)}{\sqrt{\theta}}$$

If $D'(\theta)=0$, $$g(\theta)=\frac{\cos(\theta-\theta_0)-2\theta\sin(\theta-\theta_0)}{\sqrt{\theta}} = \frac{a}{r_0}$$
Though no easy closed form solution presents itself, the problem is very easy to solve numerically as the LHS is just a function of $\theta$ while the RHS is a constant. You just need to keep evaluating $g(\theta)$ in a suitable interval until $g(\theta)\approx\frac{a}{r_0}$ up to the desired tolerance.

In order to find out the required interval, note that $g(\theta) \le \frac{1+2\theta}{\sqrt{\theta}}$. So, we get an upper bound on $\theta$, say $\theta^*$, for the given $a$. Search in $(0,\theta^*)$ for a value of $\theta$ that satisfies $g(\theta) =\frac{a}{r_0}$.

Similarly, you can deal with the negative branch $f(\theta) = -a\sqrt{\theta}$.

share|improve this answer
    
@BarryCipra - Thanks. Corrected it. –  dexter04 Dec 23 '13 at 12:42

Use a golden logarithmic spiral. The distance from any point to the origin (in either polar or rectangular coordinates) is equal to a(phi)^(theta/(pi/2)) where a is the distance from an intersection of the spiral an the x axis, and theta is the angle of rotation (of the spiral) when said point lies on its curve.

To find the minimum distance of the point to an arm of the spiral when the spiral arm is between the point and origin, simply subtract the radius value of the closest arm to the point from the distance of the point to the origin.

When the point is between the spiral arm and the origin, its minimum distance from the spiral arm is the absolute value of the radius of that part of the spiral minus the distance from the point to the origin.

Since all spirals have rotational symmetry, this method works for all spirals (Fermat's included). Using the golden spiral is simply easiest because of how "intuitive" it is and the properties of phi (makes calculations far simpler than any other spiral).

Feel free to contact me at andrewbarton15@yahoo.com if you have any questions or need clarification.

share|improve this answer
    
You seem to be assuming that the closest point on the spiral lies along the line from the origin to the point in question, which is not correct. –  Rahul Dec 17 '13 at 19:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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