Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* Angle of maxima *)
- thetaMax[thetaG_, m_, lambda_: 0.6328, d_: 1.66667] := ArcSin[(m*(lambda))/d + Sin[thetaG]] - thetaG;
- (* Maxima distance from central maximum *)
- y[thetaG_, m_, x_: 1] := Sin[thetaMax[thetaG, m]]*x/Sqrt[1 - Sin[thetaMax[thetaG, m]]^2];
- (* Interactive Simulation *)
- Manipulate[
- Graphics[{
- (* Draw the Maxima *)
- PointSize[Large], Red, Point[{1, y[t, 0]}],
- If[y[t, -1] \[Element] Reals, Point[{1, y[t, -1]}]],
- If[y[t, -2] \[Element] Reals, Point[{1, y[t, -2]}]],
- If[y[t, 1] \[Element] Reals, Point[{1, y[t, 1]}]],
- If[y[t, 2] \[Element] Reals, Point[{1, y[t, 2]}]],
- (* Draw the rest of the shapes *)
- Black,
- Text[Style[
- "\!\(\*SubscriptBox[\(\[Theta]\), \(g\)]\) = " <>
- ToString[NumberForm[-t*180/Pi, 3]] <> "\[Degree]",
- FontSize -> 18, FontColor -> Darker[Green]], {0, 1}],
- If[thetaMax[t, m] \[Element] Reals,
- Text[Style[
- "\!\(\*SubscriptBox[\(\[Theta]\), \(m\)]\) = " <>
- ToString[NumberForm[thetaMax[t, m]*180/Pi, 3] // Chop] <>
- "\[Degree]", FontSize -> 18,
- FontColor -> Darker[Blue]], {0, -1}],
- Text[Style["\!\(\*SubscriptBox[\(\[Theta]\), \(max\)]\) = N/A",
- FontSize -> 18, FontColor -> Darker[Blue]], {0, -1}]],
- Red, Line[{{-1, 0}, {0, 0}}], Arrowheads[0.04],
- Arrow[{{-1, 0}, {-0.3, 0}}],
- If[y[t, m] \[Element] Reals, Arrow[{{0, 0}, {1, y[t, m]}}]],
- Black, Rectangle[{-1.25, -0.05}, {-0.9, 0.05}],
- Dashed, Line[{{0, 0}, {1, 0}}], Black,
- Rotate[Line[{{-0.5, 0}, {0, 0}}], -t, {0, 0}],
- Darker[Green], Circle[{0, 0}, 0.35, {Pi, Pi - t}],
- Darker[Blue],
- If[thetaMax[t, m] \[Element] Reals,
- Circle[{0, 0}, 0.5, {0, thetaMax[t, m]}]],
- Darker[Gray], Rotate[Rectangle[{-0.02, -0.4}, {0.02, 0.4}], -t]},
- PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}}],
- {{t, 0, "\!\(\*SubscriptBox[\(\[Theta]\), \(g\)]\)"}, -Pi/2,
- Pi/2}, {{m, 0}, {-2, -1, 0, 1, 2}},
- FrameLabel -> {"", "",
- Style["Diffraction Grating at an Angle", 18, Bold], ""},
- ControlPlacement -> Bottom]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement