Calculate the spherical intersection location

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












Having the values (x1 y1 z1), Based on the figure below, I need to find the (x2 y2 z2)



O1 =0 0 0
r1 = R1



O2 = 0 0 L
r2 = R2



enter image description here







share|cite|improve this question





















  • You could start by considering an easier, 2D case. The $z$-direction is not taken into consideration. From the equation of the line, you know that $$ fracx_2y_2 = fracx_1y_2 $$ And then, from the definition of the sphere (with radius $r_2$), $$ x_2^2 + (y_2 - r_2)^2 = r^2 $$ From the two equations you can solve $x_2$ and $y_2$. Then expand the logic to three dimensions.
    – Matti P.
    Jul 31 at 8:10










  • @MattiP. thanks, but i don't understand second equation. would you please elaborate more?
    – alex
    Jul 31 at 8:28










  • It's the equation of the circle. What is the difficulty you're facing?
    – Matti P.
    Jul 31 at 8:32










  • @alex What do you really want? The intersections between the two spheres and the line (light blue)? For any line passing by the origin?
    – Cesareo
    Jul 31 at 9:13











  • @Cesareo , yes ,(x1,y1,z1) is intersection between big sphere and blue line that i know the values , and looking for (x2,y2,z2) coordinate that is the intersection between small sphere and blue line
    – alex
    Jul 31 at 9:58















up vote
1
down vote

favorite












Having the values (x1 y1 z1), Based on the figure below, I need to find the (x2 y2 z2)



O1 =0 0 0
r1 = R1



O2 = 0 0 L
r2 = R2



enter image description here







share|cite|improve this question





















  • You could start by considering an easier, 2D case. The $z$-direction is not taken into consideration. From the equation of the line, you know that $$ fracx_2y_2 = fracx_1y_2 $$ And then, from the definition of the sphere (with radius $r_2$), $$ x_2^2 + (y_2 - r_2)^2 = r^2 $$ From the two equations you can solve $x_2$ and $y_2$. Then expand the logic to three dimensions.
    – Matti P.
    Jul 31 at 8:10










  • @MattiP. thanks, but i don't understand second equation. would you please elaborate more?
    – alex
    Jul 31 at 8:28










  • It's the equation of the circle. What is the difficulty you're facing?
    – Matti P.
    Jul 31 at 8:32










  • @alex What do you really want? The intersections between the two spheres and the line (light blue)? For any line passing by the origin?
    – Cesareo
    Jul 31 at 9:13











  • @Cesareo , yes ,(x1,y1,z1) is intersection between big sphere and blue line that i know the values , and looking for (x2,y2,z2) coordinate that is the intersection between small sphere and blue line
    – alex
    Jul 31 at 9:58













up vote
1
down vote

favorite









up vote
1
down vote

favorite











Having the values (x1 y1 z1), Based on the figure below, I need to find the (x2 y2 z2)



O1 =0 0 0
r1 = R1



O2 = 0 0 L
r2 = R2



enter image description here







share|cite|improve this question













Having the values (x1 y1 z1), Based on the figure below, I need to find the (x2 y2 z2)



O1 =0 0 0
r1 = R1



O2 = 0 0 L
r2 = R2



enter image description here









share|cite|improve this question












share|cite|improve this question




share|cite|improve this question








edited Jul 31 at 8:08









amd

25.7k2943




25.7k2943









asked Jul 31 at 7:36









alex

1062




1062











  • You could start by considering an easier, 2D case. The $z$-direction is not taken into consideration. From the equation of the line, you know that $$ fracx_2y_2 = fracx_1y_2 $$ And then, from the definition of the sphere (with radius $r_2$), $$ x_2^2 + (y_2 - r_2)^2 = r^2 $$ From the two equations you can solve $x_2$ and $y_2$. Then expand the logic to three dimensions.
    – Matti P.
    Jul 31 at 8:10










  • @MattiP. thanks, but i don't understand second equation. would you please elaborate more?
    – alex
    Jul 31 at 8:28










  • It's the equation of the circle. What is the difficulty you're facing?
    – Matti P.
    Jul 31 at 8:32










  • @alex What do you really want? The intersections between the two spheres and the line (light blue)? For any line passing by the origin?
    – Cesareo
    Jul 31 at 9:13











  • @Cesareo , yes ,(x1,y1,z1) is intersection between big sphere and blue line that i know the values , and looking for (x2,y2,z2) coordinate that is the intersection between small sphere and blue line
    – alex
    Jul 31 at 9:58

















  • You could start by considering an easier, 2D case. The $z$-direction is not taken into consideration. From the equation of the line, you know that $$ fracx_2y_2 = fracx_1y_2 $$ And then, from the definition of the sphere (with radius $r_2$), $$ x_2^2 + (y_2 - r_2)^2 = r^2 $$ From the two equations you can solve $x_2$ and $y_2$. Then expand the logic to three dimensions.
    – Matti P.
    Jul 31 at 8:10










  • @MattiP. thanks, but i don't understand second equation. would you please elaborate more?
    – alex
    Jul 31 at 8:28










  • It's the equation of the circle. What is the difficulty you're facing?
    – Matti P.
    Jul 31 at 8:32










  • @alex What do you really want? The intersections between the two spheres and the line (light blue)? For any line passing by the origin?
    – Cesareo
    Jul 31 at 9:13











  • @Cesareo , yes ,(x1,y1,z1) is intersection between big sphere and blue line that i know the values , and looking for (x2,y2,z2) coordinate that is the intersection between small sphere and blue line
    – alex
    Jul 31 at 9:58
















You could start by considering an easier, 2D case. The $z$-direction is not taken into consideration. From the equation of the line, you know that $$ fracx_2y_2 = fracx_1y_2 $$ And then, from the definition of the sphere (with radius $r_2$), $$ x_2^2 + (y_2 - r_2)^2 = r^2 $$ From the two equations you can solve $x_2$ and $y_2$. Then expand the logic to three dimensions.
– Matti P.
Jul 31 at 8:10




You could start by considering an easier, 2D case. The $z$-direction is not taken into consideration. From the equation of the line, you know that $$ fracx_2y_2 = fracx_1y_2 $$ And then, from the definition of the sphere (with radius $r_2$), $$ x_2^2 + (y_2 - r_2)^2 = r^2 $$ From the two equations you can solve $x_2$ and $y_2$. Then expand the logic to three dimensions.
– Matti P.
Jul 31 at 8:10












@MattiP. thanks, but i don't understand second equation. would you please elaborate more?
– alex
Jul 31 at 8:28




@MattiP. thanks, but i don't understand second equation. would you please elaborate more?
– alex
Jul 31 at 8:28












It's the equation of the circle. What is the difficulty you're facing?
– Matti P.
Jul 31 at 8:32




It's the equation of the circle. What is the difficulty you're facing?
– Matti P.
Jul 31 at 8:32












@alex What do you really want? The intersections between the two spheres and the line (light blue)? For any line passing by the origin?
– Cesareo
Jul 31 at 9:13





@alex What do you really want? The intersections between the two spheres and the line (light blue)? For any line passing by the origin?
– Cesareo
Jul 31 at 9:13













@Cesareo , yes ,(x1,y1,z1) is intersection between big sphere and blue line that i know the values , and looking for (x2,y2,z2) coordinate that is the intersection between small sphere and blue line
– alex
Jul 31 at 9:58





@Cesareo , yes ,(x1,y1,z1) is intersection between big sphere and blue line that i know the values , and looking for (x2,y2,z2) coordinate that is the intersection between small sphere and blue line
– alex
Jul 31 at 9:58











2 Answers
2






active

oldest

votes

















up vote
1
down vote













Given



$$
C_1to ||P-O_1|| = R_1\
C_2to ||P-O_2|| = R_2\
P_1 = (x_1,y_1,z_1) in C_1
$$



with



$$
P = (x,y,z)\
O_1 = (0,0,0)\
O_2 = (0,0,L)
$$



how to obtain $P_2 = (x_2,y_2,z_2) in C_2$ such that $O_1, P_1$ and $P_2$ are aligned ?



Choosing the line



$$
Lto P = lambda vec v
$$



with $ vec v = P_1/R_1$ it's intersections with $C_2$ are obtained by solving for $lambda$



$$
||lambdavec v-O_2|| = R_2
$$



or squaring



$$
lambda^2||vec v||^2-2lambda <vec v, O_2 > + ||O_2||^2 = R_2^2
$$



or



$$
lambda = frac< vec v, O_2 > pmsqrt < vec v, O_2 > ^2-
$$



but here $vec v = P_1/R_1$ is an unit vector so



$$
lambda = frac1R_1 < P_1, O_2 >pm sqrtO_2
$$



or



$$
lambda = fracz_1 LR_1pm sqrtfracz_1^2 L^2R_1^2-L^2+R_2^2
$$



and thus we can have solutions for $P_2$ as



$$
P_2 = left(fracz_1 LR_1pm sqrtfracz_1^2 L^2R_1^2-L^2+R_2^2right)fracP_1R_1
$$



NOTE



Here $< cdot, cdot > $ represents the scalar product of two vectors.






share|cite|improve this answer























  • thanks,i'll test it out soon
    – alex
    Aug 1 at 15:36

















up vote
1
down vote













Let $P_2 = (x_1, y_1, z_1)$ be the intersection of the given ray with the sphere centered at $O_2.$
Construct a triangle $triangle O_1 O_2 P_2.$
Let angle $theta = angle O_2 O_1 P_2$; this is the angle between the ray and the positive $z$ axis.



Consider the triangle formed by the points $O_1 = (0,0,0),$
$(x_1,y_1,z_1),$ and $(0,0,z_1).$
This is a right triangle with the same angle $theta$ at $O_1.$
From this right triangle, by examining the ratio of the hypotenuse to the
leg along the $z$ axis we find that
$costheta = z_1/R_1.$



Applying the cosine law to triangle $triangle O_1 O_2 P_2,$
we have
$$ R_2^2 = L^2 + r^2 - 2costheta Lr. $$



Substitute $z_1/R_1$ for $costheta$ and rearrange the terms to make this a quadratic equation over $r$:
$$ r^2 - 2fracz_1R_1 Lr + L^2 - R_2^2 = 0. $$



This can be solved by the usual formula for roots of quadratic equations:
beginalign
r &= frac12 left(2fracz_1R_1 L
pm sqrtleft(2fracz_1R_1 Lright)^2 - 4(L^2 - R_2^2)right)\
&= fracz_1R_1 L
pm sqrtleft(fracz_1R_1 Lright)^2 - L^2 + R_2^2.
endalign



Now we want a point at distance $r$ from the origin in the same direction as
$(x_1,y_1,z_1).$
That is, we want a point $r/R_1$ times as far from the origin as $(x_1,y_1,z_1).$
Based on the diagram, we want to take the positive value of the $pm$ part in the formula above;
the negative value will give us a "backward" projection to the point where
the line from $(x_1,y_1,z_1)$ to $O_1$ intersects the smaller sphere on the other side of $O_1.$



So the final result is $(kx_1,ky_1,kz_1),$
where
$$k = frac1R_1 left(fracz_1R_1 L
+ sqrtleft(fracz_1R_1 Lright)^2 - L^2 + R_2^2right). $$






share|cite|improve this answer





















    Your Answer




    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "69"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2867763%2fcalculate-the-spherical-intersection-location%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    Given



    $$
    C_1to ||P-O_1|| = R_1\
    C_2to ||P-O_2|| = R_2\
    P_1 = (x_1,y_1,z_1) in C_1
    $$



    with



    $$
    P = (x,y,z)\
    O_1 = (0,0,0)\
    O_2 = (0,0,L)
    $$



    how to obtain $P_2 = (x_2,y_2,z_2) in C_2$ such that $O_1, P_1$ and $P_2$ are aligned ?



    Choosing the line



    $$
    Lto P = lambda vec v
    $$



    with $ vec v = P_1/R_1$ it's intersections with $C_2$ are obtained by solving for $lambda$



    $$
    ||lambdavec v-O_2|| = R_2
    $$



    or squaring



    $$
    lambda^2||vec v||^2-2lambda <vec v, O_2 > + ||O_2||^2 = R_2^2
    $$



    or



    $$
    lambda = frac< vec v, O_2 > pmsqrt < vec v, O_2 > ^2-
    $$



    but here $vec v = P_1/R_1$ is an unit vector so



    $$
    lambda = frac1R_1 < P_1, O_2 >pm sqrtO_2
    $$



    or



    $$
    lambda = fracz_1 LR_1pm sqrtfracz_1^2 L^2R_1^2-L^2+R_2^2
    $$



    and thus we can have solutions for $P_2$ as



    $$
    P_2 = left(fracz_1 LR_1pm sqrtfracz_1^2 L^2R_1^2-L^2+R_2^2right)fracP_1R_1
    $$



    NOTE



    Here $< cdot, cdot > $ represents the scalar product of two vectors.






    share|cite|improve this answer























    • thanks,i'll test it out soon
      – alex
      Aug 1 at 15:36














    up vote
    1
    down vote













    Given



    $$
    C_1to ||P-O_1|| = R_1\
    C_2to ||P-O_2|| = R_2\
    P_1 = (x_1,y_1,z_1) in C_1
    $$



    with



    $$
    P = (x,y,z)\
    O_1 = (0,0,0)\
    O_2 = (0,0,L)
    $$



    how to obtain $P_2 = (x_2,y_2,z_2) in C_2$ such that $O_1, P_1$ and $P_2$ are aligned ?



    Choosing the line



    $$
    Lto P = lambda vec v
    $$



    with $ vec v = P_1/R_1$ it's intersections with $C_2$ are obtained by solving for $lambda$



    $$
    ||lambdavec v-O_2|| = R_2
    $$



    or squaring



    $$
    lambda^2||vec v||^2-2lambda <vec v, O_2 > + ||O_2||^2 = R_2^2
    $$



    or



    $$
    lambda = frac< vec v, O_2 > pmsqrt < vec v, O_2 > ^2-
    $$



    but here $vec v = P_1/R_1$ is an unit vector so



    $$
    lambda = frac1R_1 < P_1, O_2 >pm sqrtO_2
    $$



    or



    $$
    lambda = fracz_1 LR_1pm sqrtfracz_1^2 L^2R_1^2-L^2+R_2^2
    $$



    and thus we can have solutions for $P_2$ as



    $$
    P_2 = left(fracz_1 LR_1pm sqrtfracz_1^2 L^2R_1^2-L^2+R_2^2right)fracP_1R_1
    $$



    NOTE



    Here $< cdot, cdot > $ represents the scalar product of two vectors.






    share|cite|improve this answer























    • thanks,i'll test it out soon
      – alex
      Aug 1 at 15:36












    up vote
    1
    down vote










    up vote
    1
    down vote









    Given



    $$
    C_1to ||P-O_1|| = R_1\
    C_2to ||P-O_2|| = R_2\
    P_1 = (x_1,y_1,z_1) in C_1
    $$



    with



    $$
    P = (x,y,z)\
    O_1 = (0,0,0)\
    O_2 = (0,0,L)
    $$



    how to obtain $P_2 = (x_2,y_2,z_2) in C_2$ such that $O_1, P_1$ and $P_2$ are aligned ?



    Choosing the line



    $$
    Lto P = lambda vec v
    $$



    with $ vec v = P_1/R_1$ it's intersections with $C_2$ are obtained by solving for $lambda$



    $$
    ||lambdavec v-O_2|| = R_2
    $$



    or squaring



    $$
    lambda^2||vec v||^2-2lambda <vec v, O_2 > + ||O_2||^2 = R_2^2
    $$



    or



    $$
    lambda = frac< vec v, O_2 > pmsqrt < vec v, O_2 > ^2-
    $$



    but here $vec v = P_1/R_1$ is an unit vector so



    $$
    lambda = frac1R_1 < P_1, O_2 >pm sqrtO_2
    $$



    or



    $$
    lambda = fracz_1 LR_1pm sqrtfracz_1^2 L^2R_1^2-L^2+R_2^2
    $$



    and thus we can have solutions for $P_2$ as



    $$
    P_2 = left(fracz_1 LR_1pm sqrtfracz_1^2 L^2R_1^2-L^2+R_2^2right)fracP_1R_1
    $$



    NOTE



    Here $< cdot, cdot > $ represents the scalar product of two vectors.






    share|cite|improve this answer















    Given



    $$
    C_1to ||P-O_1|| = R_1\
    C_2to ||P-O_2|| = R_2\
    P_1 = (x_1,y_1,z_1) in C_1
    $$



    with



    $$
    P = (x,y,z)\
    O_1 = (0,0,0)\
    O_2 = (0,0,L)
    $$



    how to obtain $P_2 = (x_2,y_2,z_2) in C_2$ such that $O_1, P_1$ and $P_2$ are aligned ?



    Choosing the line



    $$
    Lto P = lambda vec v
    $$



    with $ vec v = P_1/R_1$ it's intersections with $C_2$ are obtained by solving for $lambda$



    $$
    ||lambdavec v-O_2|| = R_2
    $$



    or squaring



    $$
    lambda^2||vec v||^2-2lambda <vec v, O_2 > + ||O_2||^2 = R_2^2
    $$



    or



    $$
    lambda = frac< vec v, O_2 > pmsqrt < vec v, O_2 > ^2-
    $$



    but here $vec v = P_1/R_1$ is an unit vector so



    $$
    lambda = frac1R_1 < P_1, O_2 >pm sqrtO_2
    $$



    or



    $$
    lambda = fracz_1 LR_1pm sqrtfracz_1^2 L^2R_1^2-L^2+R_2^2
    $$



    and thus we can have solutions for $P_2$ as



    $$
    P_2 = left(fracz_1 LR_1pm sqrtfracz_1^2 L^2R_1^2-L^2+R_2^2right)fracP_1R_1
    $$



    NOTE



    Here $< cdot, cdot > $ represents the scalar product of two vectors.







    share|cite|improve this answer















    share|cite|improve this answer



    share|cite|improve this answer








    edited Aug 1 at 16:07


























    answered Aug 1 at 12:19









    Cesareo

    5,5812412




    5,5812412











    • thanks,i'll test it out soon
      – alex
      Aug 1 at 15:36
















    • thanks,i'll test it out soon
      – alex
      Aug 1 at 15:36















    thanks,i'll test it out soon
    – alex
    Aug 1 at 15:36




    thanks,i'll test it out soon
    – alex
    Aug 1 at 15:36










    up vote
    1
    down vote













    Let $P_2 = (x_1, y_1, z_1)$ be the intersection of the given ray with the sphere centered at $O_2.$
    Construct a triangle $triangle O_1 O_2 P_2.$
    Let angle $theta = angle O_2 O_1 P_2$; this is the angle between the ray and the positive $z$ axis.



    Consider the triangle formed by the points $O_1 = (0,0,0),$
    $(x_1,y_1,z_1),$ and $(0,0,z_1).$
    This is a right triangle with the same angle $theta$ at $O_1.$
    From this right triangle, by examining the ratio of the hypotenuse to the
    leg along the $z$ axis we find that
    $costheta = z_1/R_1.$



    Applying the cosine law to triangle $triangle O_1 O_2 P_2,$
    we have
    $$ R_2^2 = L^2 + r^2 - 2costheta Lr. $$



    Substitute $z_1/R_1$ for $costheta$ and rearrange the terms to make this a quadratic equation over $r$:
    $$ r^2 - 2fracz_1R_1 Lr + L^2 - R_2^2 = 0. $$



    This can be solved by the usual formula for roots of quadratic equations:
    beginalign
    r &= frac12 left(2fracz_1R_1 L
    pm sqrtleft(2fracz_1R_1 Lright)^2 - 4(L^2 - R_2^2)right)\
    &= fracz_1R_1 L
    pm sqrtleft(fracz_1R_1 Lright)^2 - L^2 + R_2^2.
    endalign



    Now we want a point at distance $r$ from the origin in the same direction as
    $(x_1,y_1,z_1).$
    That is, we want a point $r/R_1$ times as far from the origin as $(x_1,y_1,z_1).$
    Based on the diagram, we want to take the positive value of the $pm$ part in the formula above;
    the negative value will give us a "backward" projection to the point where
    the line from $(x_1,y_1,z_1)$ to $O_1$ intersects the smaller sphere on the other side of $O_1.$



    So the final result is $(kx_1,ky_1,kz_1),$
    where
    $$k = frac1R_1 left(fracz_1R_1 L
    + sqrtleft(fracz_1R_1 Lright)^2 - L^2 + R_2^2right). $$






    share|cite|improve this answer

























      up vote
      1
      down vote













      Let $P_2 = (x_1, y_1, z_1)$ be the intersection of the given ray with the sphere centered at $O_2.$
      Construct a triangle $triangle O_1 O_2 P_2.$
      Let angle $theta = angle O_2 O_1 P_2$; this is the angle between the ray and the positive $z$ axis.



      Consider the triangle formed by the points $O_1 = (0,0,0),$
      $(x_1,y_1,z_1),$ and $(0,0,z_1).$
      This is a right triangle with the same angle $theta$ at $O_1.$
      From this right triangle, by examining the ratio of the hypotenuse to the
      leg along the $z$ axis we find that
      $costheta = z_1/R_1.$



      Applying the cosine law to triangle $triangle O_1 O_2 P_2,$
      we have
      $$ R_2^2 = L^2 + r^2 - 2costheta Lr. $$



      Substitute $z_1/R_1$ for $costheta$ and rearrange the terms to make this a quadratic equation over $r$:
      $$ r^2 - 2fracz_1R_1 Lr + L^2 - R_2^2 = 0. $$



      This can be solved by the usual formula for roots of quadratic equations:
      beginalign
      r &= frac12 left(2fracz_1R_1 L
      pm sqrtleft(2fracz_1R_1 Lright)^2 - 4(L^2 - R_2^2)right)\
      &= fracz_1R_1 L
      pm sqrtleft(fracz_1R_1 Lright)^2 - L^2 + R_2^2.
      endalign



      Now we want a point at distance $r$ from the origin in the same direction as
      $(x_1,y_1,z_1).$
      That is, we want a point $r/R_1$ times as far from the origin as $(x_1,y_1,z_1).$
      Based on the diagram, we want to take the positive value of the $pm$ part in the formula above;
      the negative value will give us a "backward" projection to the point where
      the line from $(x_1,y_1,z_1)$ to $O_1$ intersects the smaller sphere on the other side of $O_1.$



      So the final result is $(kx_1,ky_1,kz_1),$
      where
      $$k = frac1R_1 left(fracz_1R_1 L
      + sqrtleft(fracz_1R_1 Lright)^2 - L^2 + R_2^2right). $$






      share|cite|improve this answer























        up vote
        1
        down vote










        up vote
        1
        down vote









        Let $P_2 = (x_1, y_1, z_1)$ be the intersection of the given ray with the sphere centered at $O_2.$
        Construct a triangle $triangle O_1 O_2 P_2.$
        Let angle $theta = angle O_2 O_1 P_2$; this is the angle between the ray and the positive $z$ axis.



        Consider the triangle formed by the points $O_1 = (0,0,0),$
        $(x_1,y_1,z_1),$ and $(0,0,z_1).$
        This is a right triangle with the same angle $theta$ at $O_1.$
        From this right triangle, by examining the ratio of the hypotenuse to the
        leg along the $z$ axis we find that
        $costheta = z_1/R_1.$



        Applying the cosine law to triangle $triangle O_1 O_2 P_2,$
        we have
        $$ R_2^2 = L^2 + r^2 - 2costheta Lr. $$



        Substitute $z_1/R_1$ for $costheta$ and rearrange the terms to make this a quadratic equation over $r$:
        $$ r^2 - 2fracz_1R_1 Lr + L^2 - R_2^2 = 0. $$



        This can be solved by the usual formula for roots of quadratic equations:
        beginalign
        r &= frac12 left(2fracz_1R_1 L
        pm sqrtleft(2fracz_1R_1 Lright)^2 - 4(L^2 - R_2^2)right)\
        &= fracz_1R_1 L
        pm sqrtleft(fracz_1R_1 Lright)^2 - L^2 + R_2^2.
        endalign



        Now we want a point at distance $r$ from the origin in the same direction as
        $(x_1,y_1,z_1).$
        That is, we want a point $r/R_1$ times as far from the origin as $(x_1,y_1,z_1).$
        Based on the diagram, we want to take the positive value of the $pm$ part in the formula above;
        the negative value will give us a "backward" projection to the point where
        the line from $(x_1,y_1,z_1)$ to $O_1$ intersects the smaller sphere on the other side of $O_1.$



        So the final result is $(kx_1,ky_1,kz_1),$
        where
        $$k = frac1R_1 left(fracz_1R_1 L
        + sqrtleft(fracz_1R_1 Lright)^2 - L^2 + R_2^2right). $$






        share|cite|improve this answer













        Let $P_2 = (x_1, y_1, z_1)$ be the intersection of the given ray with the sphere centered at $O_2.$
        Construct a triangle $triangle O_1 O_2 P_2.$
        Let angle $theta = angle O_2 O_1 P_2$; this is the angle between the ray and the positive $z$ axis.



        Consider the triangle formed by the points $O_1 = (0,0,0),$
        $(x_1,y_1,z_1),$ and $(0,0,z_1).$
        This is a right triangle with the same angle $theta$ at $O_1.$
        From this right triangle, by examining the ratio of the hypotenuse to the
        leg along the $z$ axis we find that
        $costheta = z_1/R_1.$



        Applying the cosine law to triangle $triangle O_1 O_2 P_2,$
        we have
        $$ R_2^2 = L^2 + r^2 - 2costheta Lr. $$



        Substitute $z_1/R_1$ for $costheta$ and rearrange the terms to make this a quadratic equation over $r$:
        $$ r^2 - 2fracz_1R_1 Lr + L^2 - R_2^2 = 0. $$



        This can be solved by the usual formula for roots of quadratic equations:
        beginalign
        r &= frac12 left(2fracz_1R_1 L
        pm sqrtleft(2fracz_1R_1 Lright)^2 - 4(L^2 - R_2^2)right)\
        &= fracz_1R_1 L
        pm sqrtleft(fracz_1R_1 Lright)^2 - L^2 + R_2^2.
        endalign



        Now we want a point at distance $r$ from the origin in the same direction as
        $(x_1,y_1,z_1).$
        That is, we want a point $r/R_1$ times as far from the origin as $(x_1,y_1,z_1).$
        Based on the diagram, we want to take the positive value of the $pm$ part in the formula above;
        the negative value will give us a "backward" projection to the point where
        the line from $(x_1,y_1,z_1)$ to $O_1$ intersects the smaller sphere on the other side of $O_1.$



        So the final result is $(kx_1,ky_1,kz_1),$
        where
        $$k = frac1R_1 left(fracz_1R_1 L
        + sqrtleft(fracz_1R_1 Lright)^2 - L^2 + R_2^2right). $$







        share|cite|improve this answer













        share|cite|improve this answer



        share|cite|improve this answer











        answered Aug 1 at 16:29









        David K

        48k340107




        48k340107






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2867763%2fcalculate-the-spherical-intersection-location%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What is the equation of a 3D cone with generalised tilt?

            Color the edges and diagonals of a regular polygon

            Relationship between determinant of matrix and determinant of adjoint?