0

Hi I'm doing some programming challenges for fun and I am trying to work out the maths required to solve this problem. It has been 10 years since I did any maths in anger like this so i'm a bit rusty. Any help gratefully received.

I have boiled it down to the following given points p0, p1, p2, p3 and factors a and b, find pS subject to the following conditions.

  • pS is r0 from p0
  • pS is a * r0 from p1
  • pS is r1 from p2
  • pS is b * r1 from p3
  • i've tried a number of ways of doing this but I think the most promising is by creating 4 equations:

    $$(x_S - x_0)^2 + (y_S - y_0)^2 = r_0^2 \tag 1$$ $$(x_S - x_1)^2 + (y_S - y_1)^2 = a^2r_0^2 \tag 2 $$ $$(x_S - x_2)^2 + (y_S - y_2)^2 = r_1^2 \tag 3 $$ $$(x_S - x_3)^2 + (y_S - y_3)^2 = a^2r_1^2 \tag 4 $$

    this gives me 4 unknowns, xS, yS, r1 and r0

    so I am trying to work through the maths to simplify an equation down so that I can solve it programatically.

    I can eliminate r0 and r1 quite easily but eliminating xS or yS is where I am struggling

    using equations 1 and 2 I've got to the below which is where I have got stuck.

    xS^2(1 - a^2) - 2xS(x1 - a^2 * x0) + yS^2(1 - a^2) - 2yS(y1 - a^2 * y0) + a^2(x0^2 + y0^2) + x1^2 + y1^2 = 0

    How can I rearrange this for yS? so that I can use it to solve equations 3 and 4?

    xS^2(1 - b^2) - 2xS(x3 - b^2 * x2) + yS^2(1 - b^2) - 2yS(y3 - b^2 * y2) + b^2(x2^2 + y2^2) + x3^2 + y3^2 = 0

    or am I going about this completely the wrong way?

    thanks Shep


    Further Progress

    Thanks to Yves for the guidance on removing the square terms but I am now stuck again as I don't seem to have enough equations to eliminate all of the variables.

    $$2x_S(x_0 - x_1) + 2y_S(y_0-y_1) + x_1^2 - x_0^2 + y_1^2 - y_0^2 = r_0^2(a^2-1)\tag5$$ $$2x_S(x_0 - x_2) + 2y_S(y_0-y_2) + x_2^2 - x_0^2 + y_2^2 - y_0^2 = r_1^2 - r_0^2\tag6$$ $$2x_S(x_0 - x_3) + 2y_S(y_0-y_3) + x_3^2 - x_0^2 + y_3^2 - y_0^2 = b^2r_1^2 - r_0^2\tag7$$

    my next step would be to rearrange 5 for r0^2 and substitute into 6 and 7 which I've done and then to rearrange for r1^2 and substitute again however this still leaves me with only 1 equation containing x and y.

    • Subtracting the first equation from the other three gives you three linear equations, much easier to handle. –  Oct 11 '14 at 14:32
    • thank you! that's something to get me started! I'm just working this through now! – shepRCS Oct 11 '14 at 14:55
    • So i've worked this through and hit a problem. While subtracting equation 1 from 2, 3 and 4 eliminates the square terms it doesn't eliminate a variable which means I'm one equation short to solve for 4 variables. – shepRCS Oct 11 '14 at 16:52
    • Your equations are wrong. This might help set them up correctly. – dshin Oct 11 '14 at 17:21
    • @dshin which ones? the first 4 or my new ones? the first 4 I got from http://www.mathsisfun.com/algebra/circle-equations.html – shepRCS Oct 11 '14 at 17:26
    • The link's formulas are correct but you did not copy them correctly. Your first 4. – dshin Oct 11 '14 at 17:28
    • @dshin Ah I see that's a typo in my question. The follow through workings are based off my notes which are correct. Will correct my question. – shepRCS Oct 11 '14 at 17:33

    1 Answers1

    0

    Equations 1 and 2 imply that the point lies on a circle. You can find the equation of that circle by eliminating r0.

    Similarly find the equation of the circle implied by equations 3 and 4.

    Then your problem boils down to finding the intersection of two circles. This can be easily solved, see here.

    Be careful about edge cases.

    dshin
    • 1,525