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:
Now what if the points were in polar: P1=(r1, theta1) and P2=(r2, theta2). What is the equivalent equation for polar coordinates?
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
apparently, there is ...
http://www.mathhelpforum.com/math-he...ven-ratio.html
... although the OP won't tell you that until after the fact.
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 =
theta =
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:
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.Code:tempTheta = Math.atan2(tempRange, tempAz); if(tempTheta < 0) tempTheta += (2 * Math.PI);
For more on Points and Lines in Polar Coordinates, look here: Math Forum: Ask Dr. Math FAQ: Polar Coordinates
Thanks anyway!