0
$\begingroup$

I am trying to calculate where a beam hits a mirror. The mirror is described by this curve (two facing spherical mirrors):

Mirror[x_] := Piecewise[{
   {{Sin[-87.5 °] + 0.5, Cos[-87.5 °]}, x < 0},
   {{Sin[-x ° - 87.5 °] + 0.5, 
     Cos[-x ° - 87.5 °]}, x >= 0 && x < 5},
   {{Sin[x ° + 82.5 °] - 0.5, 
     Cos[x ° + 82.5 °]}, x >= 5 && x < 10}
   }, {Sin[92.5 °] - 0.5, Cos[92.5 °]}]

Now, I am just trying to get the crossing point with a line:

p = {0, 0};
v = {1, 0};
Solve[Evaluate[
  Simplify[Mirror[s].{1, 0}] == (p + v t).{1, 0} &&
   Simplify[Mirror[s].{0, 1}] == (p + v t).{0, 1} 
  ], {s, t}]

The manual projection (.{1, 0}) is done because of the piecewise defined function, as they do not work with the usual Thread - we worked this out here. This code has been working well since then, but it does not for the current Mirror function. I have no idea what the problem could be. Any ideas?

$\endgroup$
0

1 Answer 1

1
$\begingroup$

For example:

f[x_] := x Pi/180;
Mirror[x_NumericQ] := 
 Piecewise[{{{Sin[-f[87.5 ]] + 0.5, Cos[-f[87.5 ]]}, x < 0}, 
            {{Sin[-x - f[87.5 ]] + 0.5, Cos[-x - f[87.5 ]]}, x >= 0 && x < f[5]}, 
            {{Sin[x + f[82.5 ]] - 0.5, Cos[x + f[82.5 ]]}, x >= f[5] && x < f[10]}},      
             {Sin[f[92.5 ]] - 0.5, Cos[f[92.5 ]]}]
p = {0, 0};
v = {1, 0};
FindRoot[Mirror[s].{1, 0} == (p + v t).{1, 0} && 
         Mirror[s].{0, 1} == (p + v t).{0, 1}, 
         {{s, 0}, {t, 0}}]
(*
{s -> 0.0436332, t -> -0.5}
*)

graphical insight:

ParametricPlot[{Mirror[t], (p + v t)}, {t, -.6, .6},  AxesOrigin -> {Automatic, -.04}]

Mathematica graphics

$\endgroup$
3
  • $\begingroup$ Unfortunately, this just gives me one solution. In this case, for example, it is the wrong one, as my beam is going in +t direction. The solving is done in a module, where the beam path is calculated recursively. With Solve, I could add "&& t > 0", with FindRoot, this doesn't seem to work. I do not understand why at least NSolve cannot solve the equation. $\endgroup$
    – mcandril
    Commented Sep 21, 2012 at 10:31
  • $\begingroup$ Yes this is the way to go (with some refinement), +1 $\endgroup$
    – acl
    Commented Oct 20, 2012 at 18:32
  • $\begingroup$ @acl Yep, but it's a pity the OP wasn't able to understand it $\endgroup$ Commented Oct 20, 2012 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.