# [SOLVED] A point that divides a line segment in a given ratio in polar

• Mar 17th 2010, 06:22 AM
dmw
[SOLVED] A point that divides a line segment in a given ratio in polar
Say we are given the Cartesian points P1=(x1, y1) and P2=(x2, y2).

P1-------------------P3-----------------------------------P2
|----------m--------| |----------------n-------------------|

We want to find the coordinates of P3. Use this formula:

$\displaystyle ([n*x_1 + m*x_2]/[m+n] , ([n*y_1 + m*y_2]/[m+n])$

Now what if the points were in polar: P1=(r1, theta1) and P2=(r2, theta2). What is the equivalent equation for polar coordinates?
• Mar 17th 2010, 08:11 AM
skeeter
Quote:

Originally Posted by dmw
Say we are given the Cartesian points P1=(x1, y1) and P2=(x2, y2).

P1-------------------P3-----------------------------------P2
|----------m--------| |----------------n-------------------|

If we want to find the coordinates of P3, we can use the formula:

http://www.mathhelpforum.com/math-he...e60823e0-1.gif

Now what if the points were in polar: P1=(r1, theta1) and P2=(r2, theta2). What would be the equivalent equation for polar coordinates?

make the following changes to your formula ...

$\displaystyle x_1 = r_1\cos{\theta_1}$

$\displaystyle y_1 = r_1\sin{\theta_1}$

$\displaystyle x_2 = r_2\cos{\theta_2}$

$\displaystyle y_2 = r_2\sin{\theta_2}$

note that the result will be in rectangular coordinates ... you'll need to change back to polar if that's what you desire.
• Mar 17th 2010, 08:28 AM
dmw
My current implementation does just what you are suggesting: convert the polar coordinates to cartesian, do the calculation, convert back to polar. This is an extra step that I would like to avoid because it is embedded in a radar simulation program that is making tundreds of thousands of calculations every 12 seconds. This would be a huge number crunching power savings.

Your quote even says "work smart, not hard." I would like to make my program work smart, not hard.

Can anyone else help me out?
• Mar 17th 2010, 09:33 AM
Tinyboss
Is there some difficulty with converting P1,P2 to cartesian, plugging into the above formula, and converting the resulting expression to polar?
• Mar 17th 2010, 09:33 AM
skeeter
Quote:

Originally Posted by dmw
My current implementation does just what you are suggesting: convert the polar coordinates to cartesian, do the calculation, convert back to polar. This is an extra step that I would like to avoid because it is embedded in a radar simulation program that is making tundreds of thousands of calculations every 12 seconds. This would be a huge number crunching power savings.

Your quote even says "work smart, not hard." I would like to make my program work smart, not hard.

Can anyone else help me out?

this link may help (scroll down to the section titled Points) ...

Math Forum: Ask Dr. Math FAQ: Polar Coordinates
• Mar 17th 2010, 10:16 AM
skeeter
Quote:

Originally Posted by Tinyboss
Is there some difficulty with converting P1,P2 to cartesian, plugging into the above formula, and converting the resulting expression to polar?

apparently, there is ...

http://www.mathhelpforum.com/math-he...ven-ratio.html

... although the OP won't tell you that until after the fact.
• Mar 17th 2010, 10:33 AM
dmw
.
• Mar 17th 2010, 10:47 AM
dmw
The problem is that I am making this calculation thousands of time per second in a radar simulation program and if I can help it, I would like to not waste system resources on unnecessary conversions. I found the answer by the way.

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 = $\displaystyle (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 = $\displaystyle 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!
• Mar 17th 2010, 10:50 AM
dmw
.