# [SOLVED] Equation for a point on a line in polar coords

• Mar 16th 2010, 05:16 AM
dmw
[SOLVED] Equation for a point on a line in polar coords
[FONT=&quot]Suppose we are given the Polar points P1=(r1, θ1) and P2=(r2, θ2) and we are given a distance D1. How would I find the coordinates of the point P3=(r3, θ3) that lies along the line segment between P1 and P2, and is a distance D1 from point P1?

It would look something like this:

P1--------------P3----------------------P2
|------D1-----|

So we know P1, P2 and distance D1.
I need a formula to find the point P3.

I would like to be able to solve this without converting to Cartesian coordinates because it is in a program that needs to loop as fast as possible - I've done it with the conversion and it is just taking too long. Not to mention the minor precision loss.

Any thoughts?
• Mar 18th 2010, 04:29 AM
dmw

For anyone else who might be looking for this solution:

The coordinates of the point dividing the line segment P1P2 in the ratio a/b are:

range = $(sqrt[b*b*r_1*r_1+a*a*r_2*r_2+2*a*b*r_1*r_2*cos(theta_2-theta_1)]/[a+b]$

theta = $arctan([b*r_1*sin(theta_1)+a*r_2*sin(theta_2)]/[b*r_1*cos(theta_1)+a*r_2*cos(theta_2)])$

It looks intimidating, but it isn't. The hardest part is making sure you have the correct sign after calculating arctan(). If you are implementing it in Java, you can use:

Code:

```tempTheta = Math.atan2(tempRange, tempAz); if(tempTheta < 0) tempTheta += (2 * Math.PI);```
Math.atan2(y, x) computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi. In the case of being negative, just add 2*PI.

For more on Points and Lines in Polar Coordinates, look here: Math Forum: Ask Dr. Math FAQ: Polar Coordinates

Thanks anyway!