# Thread:

1. ## [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?

2. I found the answer.

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!
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 2, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9201816916465759, "perplexity_flag": "middle"}