Constructing A Simple Optical System

Manipulate[Column[{Show[Graphics[{{Opacity[0.8], GeometricTransformation[{AbsoluteThickness[1], AbsolutePointSize[1], EdgeForm[], RGBColor[0.4, 0.6, 0.8], Polygon[Dynamic[(Function[{element}, Take[#1, element]] /@ {{1, 27}} & )[polygons113200200710102030024133[θ3, PlanoConvexLensFocalLength, PlanoConvexLensThickness]]]]}, Dynamic[{{{1, 0}, {0, 1}}, {x3, y3}}]], GeometricTransformation[{AbsoluteThickness[1], AbsolutePointSize[1], EdgeForm[], RGBColor[0.4, 0.6, 0.8], Polygon[Dynamic[(Function[{element}, Take[#1, element]] /@ {{1, 27}} & )[polygons123200200710102030043537[θ9]]]]}, Dynamic[{{{1, 0}, {0, 1}}, {x9, y9}}]], GeometricTransformation[{AbsoluteThickness[1], AbsolutePointSize[1], EdgeForm[], RGBColor[0.4, 0.6, 0.8], Polygon[Dynamic[(Function[{element}, Take[#1, element]] /@ {{1, 27}} & )[polygons133200200710102030079069[θ4, PlanoConcaveLensFocalLength, PlanoConcaveLensThickness]]]]}, Dynamic[{{{1, 0}, {0, 1}}, {x4, y4}}]], GeometricTransformation[{AbsoluteThickness[1], AbsolutePointSize[1], EdgeForm[], RGBColor[0.4, 0.6, 0.8], Polygon[Dynamic[(Function[{element}, Take[#1, element]] /@ {{1, 27}} & )[polygons143200200710102030099685[θ5]]]]}, Dynamic[{{{1, 0}, {0, 1}}, {x5, y5}}]], GeometricTransformation[{AbsoluteThickness[1], AbsolutePointSize[1], EdgeForm[], RGBColor[0.4, 0.6, 0.8], Polygon[Dynamic[(Function[{element}, Take[#1, element]] /@ {{1, 27}} & )[polygons153200200710102030120567[θ6]]]]}, Dynamic[{{{1, 0}, {0, 1}}, {x6, y6}}]], GeometricTransformation[{AbsoluteThickness[1], AbsolutePointSize[1], EdgeForm[], RGBColor[0.4, 0.6, 0.8], Polygon[Dynamic[(Function[{element}, Take[#1, element]] /@ {{1, 27}} & )[polygons163200200710102030139107[θ10]]]]}, Dynamic[{{{1, 0}, {0, 1}}, {x10, y10}}]], GeometricTransformation[{GrayLevel[0], AbsoluteThickness[0.5], Line[{{{0., -50.}, {0., -41.66666666666667}, {0., -33.333333333333336}, {0., -25.000000000000004}, {0., -16.66666666666667}, {0., -8.333333333333343}, {0., -7.105427357601002*^-15}, {0., 8.333333333333329}, {0., 16.666666666666657}, {0., 24.999999999999986}, {0., 33.333333333333314}, {0., 41.66666666666666}, {0., 49.999999999999986}, {0., 50.}, {0., 41.66666666666667}, {0., 33.333333333333336}, {0., 25.000000000000004}, {0., 16.66666666666667}, {0., 8.333333333333343}, {0., 7.105427357601002*^-15}, {0., -8.333333333333329}, {0., -16.666666666666657}, {0., -24.999999999999986}, {0., -33.333333333333314}, {0., -41.66666666666666}, {0., -49.999999999999986}, {0., -50.}}}]}, Dynamic[{{{1, 0}, {0, 1}}, {x8, 0}}]], {GrayLevel[0], AbsoluteThickness[0.5], Line[{{{200., 100.}, {200., -100.}, {200., -100.}, {200., 100.}, {200., 100.}}, {{200., -100.}, {0., -100.}, {0., -100.}, {200., -100.}, {200., -100.}}, {{0., -100.}, {0., 100.}, {0., 100.}, {0., -100.}, {0., -100.}}, {{0., 100.}, {200., 100.}, {200., 100.}, {0., 100.}, {0., 100.}}, {{200., -100.}, {200., 100.}, {0., 100.}, {0., -100.}, {200., -100.}}, {{200., 100.}, {200., -100.}, {0., -100.}, {0., 100.}, {200., 100.}}}]}, Opacity[1], Dynamic[(RGBColor[Abs[-0.3183098861837907*ArcTan[63.75 - 0.25*Abs[-500. + 2.*Mod[100. + 500.*#1, 500.]]] + 0.3183098861837907*ArcTan[43. - 0.1*Abs[-500. + 2.*Mod[100. + 500.*#1, 500.]]]], Abs[0.3183098861837907*ArcTan[60. - 0.2*Abs[-500. + 2.*Mod[100. + 500.*#1, 500.]]] - 0.3183098861837907*ArcTan[18. - 0.1*Abs[-500. + 2.*Mod[100. + 500.*#1, 500.]]]], Abs[-0.3183098861837907*ArcTan[10. - 0.2*Abs[-500. + 2.*Mod[100. + 500.*#1, 500.]]] + 0.3183098861837907*ArcTan[22.5 - 0.125*Abs[-500. + 2.*Mod[100. + 500.*#1, 500.]]]]] & )[λ]], AbsoluteThickness[Medium], Line[Dynamic[({#1[[{1, 2}]], #1[[{4, 5}]]} & ) /@ Select[raytracefunction13200200710102030153833[λ, PlanoConcaveLensFocalLength, PlanoConcaveLensThickness, PlanoConvexLensFocalLength, PlanoConvexLensThickness, x10, x3, x4, x5, x6, x8, x9, y10, y3, y4, y5, y6, y9, θ10, θ3, θ4, θ5, θ6, θ9], #1[[1]] > -9.87654321*^8 & ]]], Arrowheads[Large], Thickness[Large], Dashing[{Small, Small}], RGBColor[1, 1, 0], Arrow[Dynamic[If[laststartposθ3 != {x3, y3} || lastθ3 =!= θ3, laststartposθ3 = {x3, y3}; lastθ3 = θ3; {xθ3, yθ3} = laststartposθ3 + radiusθ3*{Cos[θ3*Degree], Sin[θ3*Degree]}]; {laststartposθ3, {xθ3, yθ3}}, ({laststartposθ3, {xθ3, yθ3}} = #1) & ]], Tooltip[Locator[Dynamic[If[{xθ3, yθ3} != lastlocposθ3 || lastθ3 != θ3, lastlocposθ3 = {xθ3, yθ3}; lastθ3 = θ3; {xθ3, yθ3} = laststartposθ3 + radiusθ3*{Cos[θ3*Degree], Sin[θ3*Degree]}]; {xθ3, yθ3}, ({xθ3, yθ3} = #1; xoffθ3 = xθ3 - x3; yoffθ3 = yθ3 - y3; radiusθ3 = Sqrt[xoffθ3^2 + yoffθ3^2]; θ3 = Chop[ArcTan[xoffθ3, yoffθ3]/Degree]; {xθ3, yθ3}) & ], Graphics[{RGBColor[1/3, 1/3, 1], Disk[{0, 0}, 0.5]}, ImageSize -> 10]], Dynamic[StringJoin["θ3 = ", ToString[θ3]]]], Arrowheads[Large], Thickness[Large], Dashing[{Small, Small}], RGBColor[1, 1, 0], Arrow[Dynamic[If[laststartposθ9 != {x9, y9} || lastθ9 =!= θ9, laststartposθ9 = {x9, y9}; lastθ9 = θ9; {xθ9, yθ9} = laststartposθ9 + radiusθ9*{Cos[θ9*Degree], Sin[θ9*Degree]}]; {laststartposθ9, {xθ9, yθ9}}, ({laststartposθ9, {xθ9, yθ9}} = #1) & ]], Tooltip[Locator[Dynamic[If[{xθ9, yθ9} != lastlocposθ9 || lastθ9 != θ9, lastlocposθ9 = {xθ9, yθ9}; lastθ9 = θ9; {xθ9, yθ9} = laststartposθ9 + radiusθ9*{Cos[θ9*Degree], Sin[θ9*Degree]}]; {xθ9, yθ9}, ({xθ9, yθ9} = #1; xoffθ9 = xθ9 - x9; yoffθ9 = yθ9 - y9; radiusθ9 = Sqrt[xoffθ9^2 + yoffθ9^2]; θ9 = Chop[ArcTan[xoffθ9, yoffθ9]/Degree]; {xθ9, yθ9}) & ], Graphics[{RGBColor[1/3, 1/3, 1], Disk[{0, 0}, 0.5]}, ImageSize -> 10]], Dynamic[StringJoin["θ9 = ", ToString[θ9]]]], Arrowheads[Large], Thickness[Large], Dashing[{Small, Small}], RGBColor[1, 1, 0], Arrow[Dynamic[If[laststartposθ4 != {x4, y4} || lastθ4 =!= θ4, laststartposθ4 = {x4, y4}; lastθ4 = θ4; {xθ4, yθ4} = laststartposθ4 + radiusθ4*{Cos[θ4*Degree], Sin[θ4*Degree]}]; {laststartposθ4, {xθ4, yθ4}}, ({laststartposθ4, {xθ4, yθ4}} = #1) & ]], Tooltip[Locator[Dynamic[If[{xθ4, yθ4} != lastlocposθ4 || lastθ4 != θ4, lastlocposθ4 = {xθ4, yθ4}; lastθ4 = θ4; {xθ4, yθ4} = laststartposθ4 + radiusθ4*{Cos[θ4*Degree], Sin[θ4*Degree]}]; {xθ4, yθ4}, ({xθ4, yθ4} = #1; xoffθ4 = xθ4 - x4; yoffθ4 = yθ4 - y4; radiusθ4 = Sqrt[xoffθ4^2 + yoffθ4^2]; θ4 = Chop[ArcTan[xoffθ4, yoffθ4]/Degree]; {xθ4, yθ4}) & ], Graphics[{RGBColor[1/3, 1/3, 1], Disk[{0, 0}, 0.5]}, ImageSize -> 10]], Dynamic[StringJoin["θ4 = ", ToString[θ4]]]], Arrowheads[Large], Thickness[Large], Dashing[{Small, Small}], RGBColor[1, 1, 0], Arrow[Dynamic[If[laststartposθ5 != {x5, y5} || lastθ5 =!= θ5, laststartposθ5 = {x5, y5}; lastθ5 = θ5; {xθ5, yθ5} = laststartposθ5 + radiusθ5*{Cos[θ5*Degree], Sin[θ5*Degree]}]; {laststartposθ5, {xθ5, yθ5}}, ({laststartposθ5, {xθ5, yθ5}} = #1) & ]], Tooltip[Locator[Dynamic[If[{xθ5, yθ5} != lastlocposθ5 || lastθ5 != θ5, lastlocposθ5 = {xθ5, yθ5}; lastθ5 = θ5; {xθ5, yθ5} = laststartposθ5 + radiusθ5*{Cos[θ5*Degree], Sin[θ5*Degree]}]; {xθ5, yθ5}, ({xθ5, yθ5} = #1; xoffθ5 = xθ5 - x5; yoffθ5 = yθ5 - y5; radiusθ5 = Sqrt[xoffθ5^2 + yoffθ5^2]; θ5 = Chop[ArcTan[xoffθ5, yoffθ5]/Degree]; {xθ5, yθ5}) & ], Graphics[{RGBColor[1/3, 1/3, 1], Disk[{0, 0}, 0.5]}, ImageSize -> 10]], Dynamic[StringJoin["θ5 = ", ToString[θ5]]]], Arrowheads[Large], Thickness[Large], Dashing[{Small, Small}], RGBColor[1, 1, 0], Arrow[Dynamic[If[laststartposθ6 != {x6, y6} || lastθ6 =!= θ6, laststartposθ6 = {x6, y6}; lastθ6 = θ6; {xθ6, yθ6} = laststartposθ6 + radiusθ6*{Cos[θ6*Degree], Sin[θ6*Degree]}]; {laststartposθ6, {xθ6, yθ6}}, ({laststartposθ6, {xθ6, yθ6}} = #1) & ]], Tooltip[Locator[Dynamic[If[{xθ6, yθ6} != lastlocposθ6 || lastθ6 != θ6, lastlocposθ6 = {xθ6, yθ6}; lastθ6 = θ6; {xθ6, yθ6} = laststartposθ6 + radiusθ6*{Cos[θ6*Degree], Sin[θ6*Degree]}]; {xθ6, yθ6}, ({xθ6, yθ6} = #1; xoffθ6 = xθ6 - x6; yoffθ6 = yθ6 - y6; radiusθ6 = Sqrt[xoffθ6^2 + yoffθ6^2]; θ6 = Chop[ArcTan[xoffθ6, yoffθ6]/Degree]; {xθ6, yθ6}) & ], Graphics[{RGBColor[1/3, 1/3, 1], Disk[{0, 0}, 0.5]}, ImageSize -> 10]], Dynamic[StringJoin["θ6 = ", ToString[θ6]]]], Arrowheads[Large], Thickness[Large], Dashing[{Small, Small}], RGBColor[1, 1, 0], Arrow[Dynamic[If[laststartposθ10 != {x10, y10} || lastθ10 =!= θ10, laststartposθ10 = {x10, y10}; lastθ10 = θ10; {xθ10, yθ10} = laststartposθ10 + radiusθ10*{Cos[θ10*Degree], Sin[θ10*Degree]}]; {laststartposθ10, {xθ10, yθ10}}, ({laststartposθ10, {xθ10, yθ10}} = #1) & ]], Tooltip[Locator[Dynamic[If[{xθ10, yθ10} != lastlocposθ10 || lastθ10 != θ10, lastlocposθ10 = {xθ10, yθ10}; lastθ10 = θ10; {xθ10, yθ10} = laststartposθ10 + radiusθ10*{Cos[θ10*Degree], Sin[θ10*Degree]}]; {xθ10, yθ10}, ({xθ10, yθ10} = #1; xoffθ10 = xθ10 - x10; yoffθ10 = yθ10 - y10; radiusθ10 = Sqrt[xoffθ10^2 + yoffθ10^2]; θ10 = Chop[ArcTan[xoffθ10, yoffθ10]/Degree]; {xθ10, yθ10}) & ], Graphics[{RGBColor[1/3, 1/3, 1], Disk[{0, 0}, 0.5]}, ImageSize -> 10]], Dynamic[StringJoin["θ10 = ", ToString[θ10]]]], Tooltip[Locator[Dynamic[{x3, y3}, ({x3, y3} = Chop[#1]) & ], Graphics[{RGBColor[1, 1/3, 1/3], Disk[{0, 0}, 0.8]}, ImageSize -> 10]], Dynamic[StringJoin["{x3, y3} = ", ToString[Chop[{x3, y3}]]]]], Tooltip[Locator[Dynamic[{x9, y9}, ({x9, y9} = Chop[#1]) & ], Graphics[{RGBColor[1, 1/3, 1/3], Disk[{0, 0}, 0.8]}, ImageSize -> 10]], Dynamic[StringJoin["{x9, y9} = ", ToString[Chop[{x9, y9}]]]]], Tooltip[Locator[Dynamic[{x4, y4}, ({x4, y4} = Chop[#1]) & ], Graphics[{RGBColor[1, 1/3, 1/3], Disk[{0, 0}, 0.8]}, ImageSize -> 10]], Dynamic[StringJoin["{x4, y4} = ", ToString[Chop[{x4, y4}]]]]], Tooltip[Locator[Dynamic[{x5, y5}, ({x5, y5} = Chop[#1]) & ], Graphics[{RGBColor[1, 1/3, 1/3], Disk[{0, 0}, 0.8]}, ImageSize -> 10]], Dynamic[StringJoin["{x5, y5} = ", ToString[Chop[{x5, y5}]]]]], Tooltip[Locator[Dynamic[{x6, y6}, ({x6, y6} = Chop[#1]) & ], Graphics[{RGBColor[1, 1/3, 1/3], Disk[{0, 0}, 0.8]}, ImageSize -> 10]], Dynamic[StringJoin["{x6, y6} = ", ToString[Chop[{x6, y6}]]]]], Tooltip[Locator[Dynamic[{x10, y10}, ({x10, y10} = Chop[#1]) & ], Graphics[{RGBColor[1, 1/3, 1/3], Disk[{0, 0}, 0.8]}, ImageSize -> 10]], Dynamic[StringJoin["{x10, y10} = ", ToString[Chop[{x10, y10}]]]]], Tooltip[Locator[Dynamic[{x8, 0}, (x8 = Chop[#1[[1]]]) & ], Graphics[{RGBColor[1, 1/3, 1/3], Disk[{0, 0}, 0.8]}, ImageSize -> 10]], Dynamic[StringJoin["x8 = ", ToString[x8]]]]}}], {Axes -> True, ImageSize -> {425,425}, AspectRatio -> Automatic}]}, Center], 

Style["planoconcave lens",Bold],
{{PlanoConcaveLensFocalLength,-100,"focal length"},-100,-47,.01,Appearance->"Labeled",ImageSize->Tiny},
{{PlanoConcaveLensThickness,1,"thickness"},1,5,Appearance->"Labeled",ImageSize->Tiny},
Style["planoconvex lens",Bold],
{{PlanoConvexLensFocalLength,70,"focal length"},70,120,.01,Appearance->"Labeled",ImageSize->Tiny},
{{PlanoConvexLensThickness,10,"thickness"},10,15,Appearance->"Labeled",ImageSize->Tiny}, 
Delimiter,
{{λ,.5,"wavelength"},.4,.7,.01,Appearance->"Labeled",ImageSize->Tiny},

{{PlanoConcaveLensFocalLength, -49.8149}, ControlType -> None}, 
{{PlanoConcaveLensThickness, 2.5}, ControlType -> None}, 
{{PlanoConvexLensFocalLength, 100.}, ControlType -> None}, 
{{PlanoConvexLensThickness, 10.}, ControlType -> None}, 
{{x10, 60.}, ControlType -> None}, {{x3, 50.}, ControlType -> None}, {{x4, 90.}, ControlType -> None}, {{x5, 75.}, ControlType -> None}, {{x6, 100.}, ControlType -> None}, {{x8, 190.}, ControlType -> None}, {{x9, 10.}, ControlType -> None}, {{y10, -75.}, ControlType -> None}, {{y3, 0.}, ControlType -> None}, {{y4, -75.}, ControlType -> None}, {{y5, 0.}, ControlType -> None}, {{y6, -75.}, ControlType -> None}, {{y9, -75.}, ControlType -> None}, {{θ10, 0.}, ControlType -> None}, {{θ3, 0.}, ControlType -> None}, {{θ4, 0.}, ControlType -> None}, {{θ5, 0.}, ControlType -> None}, {{θ6, 0.}, ControlType -> None}, {{θ9, 0.}, ControlType -> None}, {{xθ3, 55.20953470592178}, ControlType -> None}, {{yθ3, 0.}, ControlType -> None}, {{radiusθ3, 5.209534705921783}, ControlType -> None}, {{xoffθ3, 5.209534705921783}, ControlType -> None}, {{yoffθ3, 0.}, ControlType -> None}, {{laststartposθ3, {50., 0.}}, ControlType -> None}, {{lastlocposθ3, {55.20953470592178, 0.}}, ControlType -> None}, {{lastθ3, 0}, ControlType -> None}, {{xθ9, 15.209534705921783}, ControlType -> None}, {{yθ9, -75.}, ControlType -> None}, {{radiusθ9, 5.209534705921783}, ControlType -> None}, {{xoffθ9, 5.209534705921783}, ControlType -> None}, {{yoffθ9, 0.}, ControlType -> None}, {{laststartposθ9, {10., -75.}}, ControlType -> None}, {{lastlocposθ9, {15.209534705921783, -75.}}, ControlType -> None}, {{lastθ9, 0}, ControlType -> None}, {{xθ4, 95.20953470592178}, ControlType -> None}, {{yθ4, -75.}, ControlType -> None}, {{radiusθ4, 5.209534705921783}, ControlType -> None}, {{xoffθ4, 5.209534705921783}, ControlType -> None}, {{yoffθ4, 0.}, ControlType -> None}, {{laststartposθ4, {90., -75.}}, ControlType -> None}, {{lastlocposθ4, {95.20953470592178, -75.}}, ControlType -> None}, {{lastθ4, 0}, ControlType -> None}, {{xθ5, 80.20953470592178}, ControlType -> None}, {{yθ5, 0.}, ControlType -> None}, {{radiusθ5, 5.209534705921783}, ControlType -> None}, {{xoffθ5, 5.209534705921783}, ControlType -> None}, {{yoffθ5, 0.}, ControlType -> None}, {{laststartposθ5, {75., 0.}}, ControlType -> None}, {{lastlocposθ5, {80.20953470592178, 0.}}, ControlType -> None}, {{lastθ5, 0}, ControlType -> None}, {{xθ6, 105.20953470592178}, ControlType -> None}, {{yθ6, -75.}, ControlType -> None}, {{radiusθ6, 5.209534705921783}, ControlType -> None}, {{xoffθ6, 5.209534705921783}, ControlType -> None}, {{yoffθ6, 0.}, ControlType -> None}, {{laststartposθ6, {100., -75.}}, ControlType -> None}, {{lastlocposθ6, {105.20953470592178, -75.}}, ControlType -> None}, {{lastθ6, 0}, ControlType -> None}, {{xθ10, 65.20953470592178}, ControlType -> None}, {{yθ10, -75.}, ControlType -> None}, {{radiusθ10, 5.209534705921783}, ControlType -> None}, {{xoffθ10, 5.209534705921783}, ControlType -> None}, {{yoffθ10, 0.}, ControlType -> None}, {{laststartposθ10, {60., -75.}}, ControlType -> None}, {{lastlocposθ10, {65.20953470592178, -75.}}, ControlType -> None}, {{lastθ10, 0}, ControlType -> None},
ControlPlacement->Left, AutorunSequencing->{1,3,5},Initialization :> (raytracefunction13200200710102030153833 = Compile[{{λ, _Real}, {PlanoConcaveLensFocalLength, _Real}, {PlanoConcaveLensThickness, _Real}, {PlanoConvexLensFocalLength, _Real}, {PlanoConvexLensThickness, _Real}, {x10, _Real}, {x3, _Real}, {x4, _Real}, {x5, _Real}, {x6, _Real}, {x8, _Real}, {x9, _Real}, {y10, _Real}, {y3, _Real}, {y4, _Real}, {y5, _Real}, {y6, _Real}, {y9, _Real}, {θ10, _Real}, {θ3, _Real}, {θ4, _Real}, {θ5, _Real}, {θ6, _Real}, {θ9, _Real}}, Module[{activeregion, allcreatedamplitudes, allcreatedrays, allowzeroraylength, alternateindex, amplitude, axismagnitude, axismatrix, clonedata, clonegenerationnumber, cloneinput, clonenumber, cloneposition, clonereportedrays, clonerotation, clonescale, clonescalevector, clonesorthistogram, clonetraceinput, clonetraceoutput, closestdistances, closestposition, closestpositions, closestraylength, completedray, componentnumber, cosangle, crossmatrix, deflecteddummyrayspresent, deflectedlocalrays, deflectedrays, deflectedrayspresent, dummymatrix, dummymatrixlist, dummyvector, frontid, generationlimit, generationnumber, holeintersections, holeQ, holeQlist, hor, index, index1, index2, inrays, intensity, intensityscale, intersectionnumber, intersections, intersectionslist, intersectionspresent, localdummyoutrayspresent, localoutrays, localoutrayspresent, magnitude, maxclonegenerationnumber, maximumposition, minimumraylength, minresonateraylength, n12, newcomponentnumber, newdeflectedrays, newdistance, newsurfaceid, newsurfacenumber, nonintersectingrays, normalizedpolarization, oldgenerationnumber, opticallength, originalray, originalraytilt, originalrotation, originalsurfnorm, outrays, parallelamplitude, PAxis, perpendicularamplitude, phaseshift, pol1, pol2, pol3, previoustilt, propagate, propagatedrays, r1, r2, r3, r4, r5, r6, r7, r8, r9, ray1, ray2, ray3, RayL, rayslot, raysreported, raytiltx, raytiltz, reporteddummyrayspresent, reportedlocalrays, reportedrays, reportedrayspresent, resonateintersections, resonatenumber, resonateraylength, rex, rey, rez, rotationaxis, rsx, RSx, rsy, RSy, rsz, RSz, RTx, RTy, RTz, rx, rxhlp, ry, ryhlp, rz, rzhlp, SCx, SCy, sid, sinangle, sno1, sno2, sno3, sno4, surfaceid, surfacenumber, surfacerotationmatrix, surfacetranslationvector, surfnorm, symr1, symr2, symr3, symr4, symr5, symr6, symr7, symr8, symr9, tempclonedata, terminatedeflection, thresholdintensity, tiltmagnitude, transmatrix, TV1, TV10, TV2, TV3, TV4, TV5, TV6, TV7, TV8, TV9, u, unfilteredintersections, unit, uu, ver, wavelength, XAxis, xunit, YAxis, yunit, ZAxis, zunit}, activeregion = 1.; allcreatedamplitudes = {{0. + 0.*I, 0. + 0.*I, 0. + 0.*I}}; allcreatedrays = {{1.}}; allowzeroraylength = True; alternateindex = 1.; amplitude = {1. + 0.*I, 0. + 0.*I, 0. + 0.*I}; axismagnitude = 1.; axismatrix = {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}; clonedata = {{1.}}; clonegenerationnumber = 1.; cloneinput = {1.}; clonenumber = 1; cloneposition = {0., 0., 0.}; clonereportedrays = {{1.}}; clonerotation = {{1.}}; clonescale = 1.; clonescalevector = {1.}; clonesorthistogram = {1}; clonetraceinput = {{1.}}; clonetraceoutput = {{1.}}; closestdistances = {1.}; closestposition = 0; closestpositions = {0}; closestraylength = 1.; completedray = {1.}; componentnumber = -1.; cosangle = 1.; crossmatrix = {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}; deflecteddummyrayspresent = False; deflectedlocalrays = {{1.}}; deflectedrays = {{1.}}; deflectedrayspresent = False; dummymatrix = {{1.}}; dummymatrixlist = {{{1.}}}; dummyvector = {1.}; frontid = 1.; generationlimit = 200.; generationnumber = 1.; holeintersections = {{-1., 0., 0.}}; holeQ = False; holeQlist = {0}; hor = 1. + 0.*I; index = 1.; index1 = 1.; index2 = 1.; inrays = {{1.}}; intensity = 1.; intensityscale = 1.; intersectionnumber = 1.; intersections = {{-1., 0., 0.}}; intersectionslist = {{{-1., 0., 0.}}}; intersectionspresent = False; localdummyoutrayspresent = False; localoutrays = {{1.}}; localoutrayspresent = False; magnitude = 1.; maxclonegenerationnumber = 1.; maximumposition = 1; minimumraylength = 0.0001; minresonateraylength = 1.; n12 = 1.; newcomponentnumber = -1.; newdeflectedrays = {{1.}}; newdistance = 1.; newsurfaceid = -1.; newsurfacenumber = -1.; nonintersectingrays = {{1.}}; normalizedpolarization = {1., 1.}; oldgenerationnumber = 1.; opticallength = 1.; originalray = {1.}; originalraytilt = {1.}; originalrotation = {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}; originalsurfnorm = {{1.}}; outrays = {{1.}}; parallelamplitude = 1. + 0.*I; PAxis = {1., 0., 0.}; perpendicularamplitude = 1. + 0.*I; phaseshift = 0.; pol1 = 1.; pol2 = 1.; pol3 = 1.; previoustilt = {1., 0., 0.}; propagate = True; propagatedrays = {{1.}}; r1 = 1.; r2 = 1.; r3 = 1.; r4 = 1.; r5 = 1.; r6 = 1.; r7 = 1.; r8 = 1.; r9 = 1.; ray1 = 1.; ray2 = 1.; ray3 = 1.; RayL = 1.; rayslot = 1.; raysreported = False; raytiltx = 1.; raytiltz = 1.; reporteddummyrayspresent = False; reportedlocalrays = {{1.}}; reportedrays = {{1.}}; reportedrayspresent = False; resonateintersections = {{-1., 0., 0.}}; resonatenumber = 0; resonateraylength = 1.; rex = 1.; rey = 1.; rez = 1.; rsx = 1.; RSx = 1.; rsy = 1.; RSy = 1.; rsz = 1.; RSz = 1.; RTx = 1.; RTy = 1.; RTz = 1.; rx = 1.; rxhlp = 1.; ry = 1.; ryhlp = 1.; rz = 1.; rzhlp = 1.; SCx = 1.; SCy = 1.; sid = 1.; sinangle = 1.; sno1 = 1.; sno2 = 1.; sno3 = 1.; sno4 = 1.; surfaceid = -1.; surfacenumber = -1.; surfacerotationmatrix = {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}; surfacetranslationvector = {0., 0., 0.}; surfnorm = {{1.}}; symr1 = 1.; symr2 = 1.; symr3 = 1.; symr4 = 1.; symr5 = 1.; symr6 = 1.; symr7 = 1.; symr8 = 1.; symr9 = 1.; tempclonedata = {{1.}}; terminatedeflection = False; thresholdintensity = 1.; tiltmagnitude = 1.; transmatrix = {{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}}; TV1 = 1.; TV10 = 1.; TV2 = 1.; TV3 = 1.; TV4 = 1.; TV5 = 1.; TV6 = 1.; TV7 = 1.; TV8 = 1.; TV9 = 1.; u = {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}; unfilteredintersections = {{-1., 0., 0.}}; unit = {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}; uu = {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}; ver = 0. + 0.*I; wavelength = 1.; XAxis = {1., 0., 0.}; xunit = 1.; YAxis = {1., 0., 0.}; yunit = 1.; ZAxis = {1., 0., 0.}; zunit = 1.; propagatedrays = Join[(({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; wavelength = λ; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}) & ) /@ {{0., -22.5, 0., 0., -22.5, 0., 1., 0., 0., 0., 1., 0., 0., 0., 1., 0.5, 100., 0.14285714285714285, 0., 1.0002701958763696, 0., 0., 1., 0., 0., 0., 0., 5256., 5256., 1., 7., 1., 0., 1., 0., 0., 0., 1., 0.}, {0., -15., 0., 0., -15., 0., 1., 0., 0., 0., 1., 0., 0., 0., 1., 0.5, 100., 0.14285714285714285, 0., 1.0002701958763696, 0., 0., 1., 0., 0., 0., 0., 5256., 5256., 2., 7., 2., 0., 1., 0., 0., 0., 1., 0.}, {0., -7.5, 0., 0., -7.5, 0., 1., 0., 0., 0., 1., 0., 0., 0., 1., 0.5, 100., 0.14285714285714285, 0., 1.0002701958763696, 0., 0., 1., 0., 0., 0., 0., 5256., 5256., 3., 7., 3., 0., 1., 0., 0., 0., 1., 0.}, {0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 1., 0., 0., 0., 1., 0.5, 100., 0.14285714285714285, 0., 1.0002701958763696, 0., 0., 1., 0., 0., 0., 0., 5256., 5256., 4., 7., 4., 0., 1., 0., 0., 0., 1., 0.}, {0., 7.5, 0., 0., 7.5, 0., 1., 0., 0., 0., 1., 0., 0., 0., 1., 0.5, 100., 0.14285714285714285, 0., 1.0002701958763696, 0., 0., 1., 0., 0., 0., 0., 5256., 5256., 5., 7., 5., 0., 1., 0., 0., 0., 1., 0.}, {0., 15., 0., 0., 15., 0., 1., 0., 0., 0., 1., 0., 0., 0., 1., 0.5, 100., 0.14285714285714285, 0., 1.0002701958763696, 0., 0., 1., 0., 0., 0., 0., 5256., 5256., 6., 7., 6., 0., 1., 0., 0., 0., 1., 0.}, {0., 22.5, 0., 0., 22.5, 0., 1., 0., 0., 0., 1., 0., 0., 0., 1., 0.5, 100., 0.14285714285714285, 0., 1.0002701958763696, 0., 0., 1., 0., 0., 0., 0., 5256., 5256., 7., 7., 7., 0., 1., 0., 0., 0., 1., 0.}}]; propagatedrays = (({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; componentnumber = 1.; frontid = 1.; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}) & ) /@ propagatedrays; thresholdintensity = 1.; generationlimit = 200.; reportedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, 0, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; generationnumber = 0.; (inrays = propagatedrays; outrays = {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}; deflectedrayspresent = True; reportedrayspresent = False; propagate = True; While[deflectedrayspresent && propagate, generationnumber += 1.; (deflecteddummyrayspresent = False; deflectedrayspresent = False; reportedrayspresent = False; reporteddummyrayspresent = True; localdummyoutrayspresent = False; localoutrayspresent = False; {deflectedlocalrays, localoutrays, reportedlocalrays} = (Flatten[#1, 1] & ) /@ Transpose[(({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; If[intensity > thresholdintensity && generationnumber < generationlimit, (resonatenumber = 0; resonateraylength = 9.87654321*^8; resonateintersections = {{-1., 0., 0.}}; MapIndexed[If[#1[[1,1]] > -1. && #1[[1,1]] < resonateraylength, resonateraylength = #1[[1,1]]; resonateintersections = #1; resonatenumber = First[#2], resonatenumber] & , intersectionslist = {{{-1., 0., 0.}}}; holeQlist = {0}; ({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ3]] + r2*Re[Sin[0.017453292519943295*θ3]]; yunit = r2*Re[Cos[0.017453292519943295*θ3]] - 1.*r1*Re[Sin[0.017453292519943295*θ3]]; zunit = r3*Re[Cos[0.017453292519943295*θ3]^2 + Sin[0.017453292519943295*θ3]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = (rex - 1.*Re[x3])*Re[Cos[0.017453292519943295*θ3]] + (rey - 1.*Re[y3])*Re[Sin[0.017453292519943295*θ3]]; ry = (rey - 1.*Re[y3])*Re[Cos[0.017453292519943295*θ3]] - 1.*(rex - 1.*Re[x3])*Re[Sin[0.017453292519943295*θ3]]; rz = rez*Re[Cos[0.017453292519943295*θ3]^2 + Sin[0.017453292519943295*θ3]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = Block[{TempVar, TempVar1, TempVar2, TempVar3, RayL, SCx, SCy}, TempVar1 = 1.; TempVar2 = 1.; TempVar3 = 1.; TempVar = {{-1., 0., 0.}}; RayL = 1.; SCx = 1.; SCy = 1.; TempVar1 = rx^2 + ry^2 + rz^2; TempVar2 = rx*xunit + ry*yunit + rz*zunit - ((14921604*PlanoConvexLensFocalLength)/28766183)*xunit; TempVar3 = -TempVar1 + TempVar2^2 + 2*rx*((14921604*PlanoConvexLensFocalLength)/28766183); TempVar3 = Re[TempVar3]; If[N[Chop[TempVar3]] >= 0., TempVar3 = Sqrt[TempVar3]; TempVar = {{RayL, SCx, SCy} = {-TempVar2 - TempVar3, ry - (TempVar2 + TempVar3)*yunit, rz - (TempVar2 + TempVar3)*zunit}; If[N[Chop[RayL]] >= 0. && SCx^2 + SCy^2 <= 625. && Abs[ry + RayL*yunit - SCx] + Abs[rz + RayL*zunit - SCy] + Abs[(-14921604*PlanoConvexLensFocalLength)/28766183 + rx + RayL*xunit + Sqrt[(222654265932816*PlanoConvexLensFocalLength^2)/827493284389489 - SCx^2 - SCy^2]*Sign[PlanoConvexLensFocalLength]] < 1.*^-7, {RayL, SCx, SCy}, {-1., 0., 0.}], {RayL, SCx, SCy} = {-TempVar2 + TempVar3, ry + (-TempVar2 + TempVar3)*yunit, rz + (-TempVar2 + TempVar3)*zunit}; If[N[Chop[RayL]] >= 0. && SCx^2 + SCy^2 <= 625. && Abs[ry + RayL*yunit - SCx] + Abs[rz + RayL*zunit - SCy] + Abs[(-14921604*PlanoConvexLensFocalLength)/28766183 + rx + RayL*xunit + Sqrt[(222654265932816*PlanoConvexLensFocalLength^2)/827493284389489 - SCx^2 - SCy^2]*Sign[PlanoConvexLensFocalLength]] < 1.*^-7, {RayL, SCx, SCy}, {-1., 0., 0.}]}; If[TempVar[[1]] == TempVar[[2]], {TempVar[[1]]}, TempVar], {{-1., 0., 0.}}]]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5294.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ3]] + r2*Re[Sin[0.017453292519943295*θ3]]; yunit = r2*Re[Cos[0.017453292519943295*θ3]] - 1.*r1*Re[Sin[0.017453292519943295*θ3]]; zunit = r3*Re[Cos[0.017453292519943295*θ3]^2 + Sin[0.017453292519943295*θ3]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = Re[Cos[0.017453292519943295*θ3]]*(rex - 1.*Re[x3 + PlanoConvexLensThickness*Cos[0.017453292519943295*θ3]]) + Re[Sin[0.017453292519943295*θ3]]*(rey - 1.*Re[y3 + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]]); ry = -1.*(rex - 1.*Re[x3 + PlanoConvexLensThickness*Cos[0.017453292519943295*θ3]])*Re[Sin[0.017453292519943295*θ3]] + Re[Cos[0.017453292519943295*θ3]]*(rey - 1.*Re[y3 + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]]); rz = rez*Re[Cos[0.017453292519943295*θ3]^2 + Sin[0.017453292519943295*θ3]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = If[Chop[xunit] != 0, {(If[N[Chop[#1[[1]]]] >= 0. && #1[[2]]^2 + #1[[3]]^2 <= 625., {#1[[1]], #1[[2]], #1[[3]]}, {-1., 0., 0.}] & )[{-(rx/xunit), ry - (rx*yunit)/xunit, rz - (rx*zunit)/xunit}]}, {{-1., 0., 0.}}]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5295.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ9]] + r2*Re[Sin[0.017453292519943295*θ9]]; yunit = r2*Re[Cos[0.017453292519943295*θ9]] - 1.*r1*Re[Sin[0.017453292519943295*θ9]]; zunit = r3*Re[Cos[0.017453292519943295*θ9]^2 + Sin[0.017453292519943295*θ9]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = (rex - 1.*Re[x9])*Re[Cos[0.017453292519943295*θ9]] + (rey - 1.*Re[y9])*Re[Sin[0.017453292519943295*θ9]]; ry = (rey - 1.*Re[y9])*Re[Cos[0.017453292519943295*θ9]] - 1.*(rex - 1.*Re[x9])*Re[Sin[0.017453292519943295*θ9]]; rz = rez*Re[Cos[0.017453292519943295*θ9]^2 + Sin[0.017453292519943295*θ9]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = Block[{TempVar, TempVar1, TempVar2, TempVar3, RayL, SCx, SCy}, TempVar1 = 1.; TempVar2 = 1.; TempVar3 = 1.; TempVar = {{-1., 0., 0.}}; RayL = 1.; SCx = 1.; SCy = 1.; TempVar1 = rx^2 + ry^2 + rz^2; TempVar2 = rx*xunit + ry*yunit + rz*zunit - 30.614874029872187*xunit; TempVar3 = -TempVar1 + TempVar2^2 + 2*rx*30.614874029872187; TempVar3 = Re[TempVar3]; If[N[Chop[TempVar3]] >= 0., TempVar3 = Sqrt[TempVar3]; TempVar = {{RayL, SCx, SCy} = {-TempVar2 - TempVar3, ry - (TempVar2 + TempVar3)*yunit, rz - (TempVar2 + TempVar3)*zunit}; If[N[Chop[RayL]] >= 0. && SCx^2 + SCy^2 <= 645.16 && Abs[ry + RayL*yunit - SCx] + Abs[rz + RayL*zunit - SCy] + Abs[-30.614874029872187 + rx + RayL*xunit + Sqrt[937.2705118649425 - SCx^2 - SCy^2]] < 1.*^-7, {RayL, SCx, SCy}, {-1., 0., 0.}], {RayL, SCx, SCy} = {-TempVar2 + TempVar3, ry + (-TempVar2 + TempVar3)*yunit, rz + (-TempVar2 + TempVar3)*zunit}; If[N[Chop[RayL]] >= 0. && SCx^2 + SCy^2 <= 645.16 && Abs[ry + RayL*yunit - SCx] + Abs[rz + RayL*zunit - SCy] + Abs[-30.614874029872187 + rx + RayL*xunit + Sqrt[937.2705118649425 - SCx^2 - SCy^2]] < 1.*^-7, {RayL, SCx, SCy}, {-1., 0., 0.}]}; If[TempVar[[1]] == TempVar[[2]], {TempVar[[1]]}, TempVar], {{-1., 0., 0.}}]]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5358.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ9]] + r2*Re[Sin[0.017453292519943295*θ9]]; yunit = r2*Re[Cos[0.017453292519943295*θ9]] - 1.*r1*Re[Sin[0.017453292519943295*θ9]]; zunit = r3*Re[Cos[0.017453292519943295*θ9]^2 + Sin[0.017453292519943295*θ9]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = Re[Cos[0.017453292519943295*θ9]]*(rex - 1.*Re[x9 + 28.*Cos[0.017453292519943295*θ9]]) + Re[Sin[0.017453292519943295*θ9]]*(rey - 1.*Re[y9 + 28.*Sin[0.017453292519943295*θ9]]); ry = -1.*(rex - 1.*Re[x9 + 28.*Cos[0.017453292519943295*θ9]])*Re[Sin[0.017453292519943295*θ9]] + Re[Cos[0.017453292519943295*θ9]]*(rey - 1.*Re[y9 + 28.*Sin[0.017453292519943295*θ9]]); rz = rez*Re[Cos[0.017453292519943295*θ9]^2 + Sin[0.017453292519943295*θ9]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = Block[{TempVar, TempVar1, TempVar2, TempVar3, RayL, SCx, SCy}, TempVar1 = 1.; TempVar2 = 1.; TempVar3 = 1.; TempVar = {{-1., 0., 0.}}; RayL = 1.; SCx = 1.; SCy = 1.; TempVar1 = rx^2 + ry^2 + rz^2; TempVar2 = rx*xunit + ry*yunit + rz*zunit - -30.614874029872187*xunit; TempVar3 = -TempVar1 + TempVar2^2 + 2*rx*-30.614874029872187; TempVar3 = Re[TempVar3]; If[N[Chop[TempVar3]] >= 0., TempVar3 = Sqrt[TempVar3]; TempVar = {{RayL, SCx, SCy} = {-TempVar2 - TempVar3, ry - (TempVar2 + TempVar3)*yunit, rz - (TempVar2 + TempVar3)*zunit}; If[N[Chop[RayL]] >= 0. && SCx^2 + SCy^2 <= 645.16 && Abs[ry + RayL*yunit - SCx] + Abs[rz + RayL*zunit - SCy] + Abs[30.614874029872187 + rx + RayL*xunit - Sqrt[937.2705118649425 - SCx^2 - SCy^2]] < 1.*^-7, {RayL, SCx, SCy}, {-1., 0., 0.}], {RayL, SCx, SCy} = {-TempVar2 + TempVar3, ry + (-TempVar2 + TempVar3)*yunit, rz + (-TempVar2 + TempVar3)*zunit}; If[N[Chop[RayL]] >= 0. && SCx^2 + SCy^2 <= 645.16 && Abs[ry + RayL*yunit - SCx] + Abs[rz + RayL*zunit - SCy] + Abs[30.614874029872187 + rx + RayL*xunit - Sqrt[937.2705118649425 - SCx^2 - SCy^2]] < 1.*^-7, {RayL, SCx, SCy}, {-1., 0., 0.}]}; If[TempVar[[1]] == TempVar[[2]], {TempVar[[1]]}, TempVar], {{-1., 0., 0.}}]]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5359.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ4]] + r2*Re[Sin[0.017453292519943295*θ4]]; yunit = r2*Re[Cos[0.017453292519943295*θ4]] - 1.*r1*Re[Sin[0.017453292519943295*θ4]]; zunit = r3*Re[Cos[0.017453292519943295*θ4]^2 + Sin[0.017453292519943295*θ4]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = (rex - 1.*Re[x4])*Re[Cos[0.017453292519943295*θ4]] + (rey - 1.*Re[y4])*Re[Sin[0.017453292519943295*θ4]]; ry = (rey - 1.*Re[y4])*Re[Cos[0.017453292519943295*θ4]] - 1.*(rex - 1.*Re[x4])*Re[Sin[0.017453292519943295*θ4]]; rz = rez*Re[Cos[0.017453292519943295*θ4]^2 + Sin[0.017453292519943295*θ4]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = Block[{TempVar, TempVar1, TempVar2, TempVar3, RayL, SCx, SCy}, TempVar1 = 1.; TempVar2 = 1.; TempVar3 = 1.; TempVar = {{-1., 0., 0.}}; RayL = 1.; SCx = 1.; SCy = 1.; TempVar1 = rx^2 + ry^2 + rz^2; TempVar2 = rx*xunit + ry*yunit + rz*zunit - ((14921604*PlanoConcaveLensFocalLength)/28766183)*xunit; TempVar3 = -TempVar1 + TempVar2^2 + 2*rx*((14921604*PlanoConcaveLensFocalLength)/28766183); TempVar3 = Re[TempVar3]; If[N[Chop[TempVar3]] >= 0., TempVar3 = Sqrt[TempVar3]; TempVar = {{RayL, SCx, SCy} = {-TempVar2 - TempVar3, ry - (TempVar2 + TempVar3)*yunit, rz - (TempVar2 + TempVar3)*zunit}; If[N[Chop[RayL]] >= 0. && SCx^2 + SCy^2 <= 362.90250000000003 && Abs[ry + RayL*yunit - SCx] + Abs[rz + RayL*zunit - SCy] + Abs[(-14921604*PlanoConcaveLensFocalLength)/28766183 + rx + RayL*xunit + Sqrt[(222654265932816*PlanoConcaveLensFocalLength^2)/827493284389489 - SCx^2 - SCy^2]*Sign[PlanoConcaveLensFocalLength]] < 1.*^-7, {RayL, SCx, SCy}, {-1., 0., 0.}], {RayL, SCx, SCy} = {-TempVar2 + TempVar3, ry + (-TempVar2 + TempVar3)*yunit, rz + (-TempVar2 + TempVar3)*zunit}; If[N[Chop[RayL]] >= 0. && SCx^2 + SCy^2 <= 362.90250000000003 && Abs[ry + RayL*yunit - SCx] + Abs[rz + RayL*zunit - SCy] + Abs[(-14921604*PlanoConcaveLensFocalLength)/28766183 + rx + RayL*xunit + Sqrt[(222654265932816*PlanoConcaveLensFocalLength^2)/827493284389489 - SCx^2 - SCy^2]*Sign[PlanoConcaveLensFocalLength]] < 1.*^-7, {RayL, SCx, SCy}, {-1., 0., 0.}]}; If[TempVar[[1]] == TempVar[[2]], {TempVar[[1]]}, TempVar], {{-1., 0., 0.}}]]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5423.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ4]] + r2*Re[Sin[0.017453292519943295*θ4]]; yunit = r2*Re[Cos[0.017453292519943295*θ4]] - 1.*r1*Re[Sin[0.017453292519943295*θ4]]; zunit = r3*Re[Cos[0.017453292519943295*θ4]^2 + Sin[0.017453292519943295*θ4]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = Re[Cos[0.017453292519943295*θ4]]*(rex - 1.*Re[x4 + PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4]]) + Re[Sin[0.017453292519943295*θ4]]*(rey - 1.*Re[y4 + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]]); ry = -1.*(rex - 1.*Re[x4 + PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4]])*Re[Sin[0.017453292519943295*θ4]] + Re[Cos[0.017453292519943295*θ4]]*(rey - 1.*Re[y4 + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]]); rz = rez*Re[Cos[0.017453292519943295*θ4]^2 + Sin[0.017453292519943295*θ4]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = If[Chop[xunit] != 0, {(If[N[Chop[#1[[1]]]] >= 0. && #1[[2]]^2 + #1[[3]]^2 <= 362.90250000000003, {#1[[1]], #1[[2]], #1[[3]]}, {-1., 0., 0.}] & )[{-(rx/xunit), ry - (rx*yunit)/xunit, rz - (rx*zunit)/xunit}]}, {{-1., 0., 0.}}]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5424.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ5]] + r2*Re[Sin[0.017453292519943295*θ5]]; yunit = r2*Re[Cos[0.017453292519943295*θ5]] - 1.*r1*Re[Sin[0.017453292519943295*θ5]]; zunit = r3*Re[Cos[0.017453292519943295*θ5]^2 + Sin[0.017453292519943295*θ5]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = (rex - 1.*Re[x5])*Re[Cos[0.017453292519943295*θ5]] + (rey - 1.*Re[y5])*Re[Sin[0.017453292519943295*θ5]]; ry = (rey - 1.*Re[y5])*Re[Cos[0.017453292519943295*θ5]] - 1.*(rex - 1.*Re[x5])*Re[Sin[0.017453292519943295*θ5]]; rz = rez*Re[Cos[0.017453292519943295*θ5]^2 + Sin[0.017453292519943295*θ5]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = If[Chop[xunit] != 0, {(If[N[Chop[#1[[1]]]] >= 0. && #1[[2]]^2 + #1[[3]]^2 <= 625., {#1[[1]], #1[[2]], #1[[3]]}, {-1., 0., 0.}] & )[{-(rx/xunit), ry - (rx*yunit)/xunit, rz - (rx*zunit)/xunit}]}, {{-1., 0., 0.}}]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5488.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ5]] + r2*Re[Sin[0.017453292519943295*θ5]]; yunit = r2*Re[Cos[0.017453292519943295*θ5]] - 1.*r1*Re[Sin[0.017453292519943295*θ5]]; zunit = r3*Re[Cos[0.017453292519943295*θ5]^2 + Sin[0.017453292519943295*θ5]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = Re[Cos[0.017453292519943295*θ5]]*(rex - 1.*Re[x5 + 5.*Cos[0.017453292519943295*θ5]]) + Re[Sin[0.017453292519943295*θ5]]*(rey - 1.*Re[y5 + 5.*Sin[0.017453292519943295*θ5]]); ry = -1.*(rex - 1.*Re[x5 + 5.*Cos[0.017453292519943295*θ5]])*Re[Sin[0.017453292519943295*θ5]] + Re[Cos[0.017453292519943295*θ5]]*(rey - 1.*Re[y5 + 5.*Sin[0.017453292519943295*θ5]]); rz = rez*Re[Cos[0.017453292519943295*θ5]^2 + Sin[0.017453292519943295*θ5]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = If[Chop[xunit] != 0, {(If[N[Chop[#1[[1]]]] >= 0. && #1[[2]]^2 + #1[[3]]^2 <= 625., {#1[[1]], #1[[2]], #1[[3]]}, {-1., 0., 0.}] & )[{-(rx/xunit), ry - (rx*yunit)/xunit, rz - (rx*zunit)/xunit}]}, {{-1., 0., 0.}}]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5489.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ6]] + r2*Re[Sin[0.017453292519943295*θ6]]; yunit = r2*Re[Cos[0.017453292519943295*θ6]] - 1.*r1*Re[Sin[0.017453292519943295*θ6]]; zunit = r3*Re[Cos[0.017453292519943295*θ6]^2 + Sin[0.017453292519943295*θ6]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = (rex - 1.*Re[x6])*Re[Cos[0.017453292519943295*θ6]] + (rey - 1.*Re[y6])*Re[Sin[0.017453292519943295*θ6]]; ry = (rey - 1.*Re[y6])*Re[Cos[0.017453292519943295*θ6]] - 1.*(rex - 1.*Re[x6])*Re[Sin[0.017453292519943295*θ6]]; rz = rez*Re[Cos[0.017453292519943295*θ6]^2 + Sin[0.017453292519943295*θ6]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = If[Chop[xunit] != 0, {(If[N[Chop[#1[[1]]]] >= 0. && #1[[2]]^2 + #1[[3]]^2 <= 625., {#1[[1]], #1[[2]], #1[[3]]}, {-1., 0., 0.}] & )[{-(rx/xunit), ry - (rx*yunit)/xunit, rz - (rx*zunit)/xunit}]}, {{-1., 0., 0.}}]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5553.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ6]] + r2*Re[Sin[0.017453292519943295*θ6]]; yunit = r2*Re[Cos[0.017453292519943295*θ6]] - 1.*r1*Re[Sin[0.017453292519943295*θ6]]; zunit = r3*Re[Cos[0.017453292519943295*θ6]^2 + Sin[0.017453292519943295*θ6]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = Re[Cos[0.017453292519943295*θ6]]*(rex - 1.*Re[x6 + 5.*Cos[0.017453292519943295*θ6]]) + Re[Sin[0.017453292519943295*θ6]]*(rey - 1.*Re[y6 + 5.*Sin[0.017453292519943295*θ6]]); ry = -1.*(rex - 1.*Re[x6 + 5.*Cos[0.017453292519943295*θ6]])*Re[Sin[0.017453292519943295*θ6]] + Re[Cos[0.017453292519943295*θ6]]*(rey - 1.*Re[y6 + 5.*Sin[0.017453292519943295*θ6]]); rz = rez*Re[Cos[0.017453292519943295*θ6]^2 + Sin[0.017453292519943295*θ6]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = If[Chop[xunit] != 0, {(If[N[Chop[#1[[1]]]] >= 0. && #1[[2]]^2 + #1[[3]]^2 <= 625., {#1[[1]], #1[[2]], #1[[3]]}, {-1., 0., 0.}] & )[{-(rx/xunit), ry - (rx*yunit)/xunit, rz - (rx*zunit)/xunit}]}, {{-1., 0., 0.}}]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5554.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ10]] + r2*Re[Sin[0.017453292519943295*θ10]]; yunit = r2*Re[Cos[0.017453292519943295*θ10]] - 1.*r1*Re[Sin[0.017453292519943295*θ10]]; zunit = r3*Re[Cos[0.017453292519943295*θ10]^2 + Sin[0.017453292519943295*θ10]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = (rex - 1.*Re[x10])*Re[Cos[0.017453292519943295*θ10]] + (rey - 1.*Re[y10])*Re[Sin[0.017453292519943295*θ10]]; ry = (rey - 1.*Re[y10])*Re[Cos[0.017453292519943295*θ10]] - 1.*(rex - 1.*Re[x10])*Re[Sin[0.017453292519943295*θ10]]; rz = rez*Re[Cos[0.017453292519943295*θ10]^2 + Sin[0.017453292519943295*θ10]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = Block[{TempVar, TempVar1, TempVar2, TempVar3, RayL, SCx, SCy}, TempVar1 = 1.; TempVar2 = 1.; TempVar3 = 1.; TempVar = {{-1., 0., 0.}}; RayL = 1.; SCx = 1.; SCy = 1.; TempVar1 = rx^2 + ry^2 + rz^2; TempVar2 = rx*xunit + ry*yunit + rz*zunit - -91.80458356418029*xunit; TempVar3 = -TempVar1 + TempVar2^2 + 2*rx*-91.80458356418029; TempVar3 = Re[TempVar3]; If[N[Chop[TempVar3]] >= 0., TempVar3 = Sqrt[TempVar3]; TempVar = {{RayL, SCx, SCy} = {-TempVar2 - TempVar3, ry - (TempVar2 + TempVar3)*yunit, rz - (TempVar2 + TempVar3)*zunit}; If[N[Chop[RayL]] >= 0. && SCx^2 + SCy^2 <= 625. && Abs[ry + RayL*yunit - SCx] + Abs[rz + RayL*zunit - SCy] + Abs[91.80458356418029 + rx + RayL*xunit - Sqrt[8428.081563392561 - SCx^2 - SCy^2]] < 1.*^-7, {RayL, SCx, SCy}, {-1., 0., 0.}], {RayL, SCx, SCy} = {-TempVar2 + TempVar3, ry + (-TempVar2 + TempVar3)*yunit, rz + (-TempVar2 + TempVar3)*zunit}; If[N[Chop[RayL]] >= 0. && SCx^2 + SCy^2 <= 625. && Abs[ry + RayL*yunit - SCx] + Abs[rz + RayL*zunit - SCy] + Abs[91.80458356418029 + rx + RayL*xunit - Sqrt[8428.081563392561 - SCx^2 - SCy^2]] < 1.*^-7, {RayL, SCx, SCy}, {-1., 0., 0.}]}; If[TempVar[[1]] == TempVar[[2]], {TempVar[[1]]}, TempVar], {{-1., 0., 0.}}]]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5617.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ10]] + r2*Re[Sin[0.017453292519943295*θ10]]; yunit = r2*Re[Cos[0.017453292519943295*θ10]] - 1.*r1*Re[Sin[0.017453292519943295*θ10]]; zunit = r3*Re[Cos[0.017453292519943295*θ10]^2 + Sin[0.017453292519943295*θ10]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = Re[Cos[0.017453292519943295*θ10]]*(rex - 1.*Re[x10 + 3.*Cos[0.017453292519943295*θ10]]) + Re[Sin[0.017453292519943295*θ10]]*(rey - 1.*Re[y10 + 3.*Sin[0.017453292519943295*θ10]]); ry = -1.*(rex - 1.*Re[x10 + 3.*Cos[0.017453292519943295*θ10]])*Re[Sin[0.017453292519943295*θ10]] + Re[Cos[0.017453292519943295*θ10]]*(rey - 1.*Re[y10 + 3.*Sin[0.017453292519943295*θ10]]); rz = rez*Re[Cos[0.017453292519943295*θ10]^2 + Sin[0.017453292519943295*θ10]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = Block[{TempVar, TempVar1, TempVar2, TempVar3, RayL, SCx, SCy}, TempVar1 = 1.; TempVar2 = 1.; TempVar3 = 1.; TempVar = {{-1., 0., 0.}}; RayL = 1.; SCx = 1.; SCy = 1.; TempVar1 = rx^2 + ry^2 + rz^2; TempVar2 = rx*xunit + ry*yunit + rz*zunit - 91.80458356418029*xunit; TempVar3 = -TempVar1 + TempVar2^2 + 2*rx*91.80458356418029; TempVar3 = Re[TempVar3]; If[N[Chop[TempVar3]] >= 0., TempVar3 = Sqrt[TempVar3]; TempVar = {{RayL, SCx, SCy} = {-TempVar2 - TempVar3, ry - (TempVar2 + TempVar3)*yunit, rz - (TempVar2 + TempVar3)*zunit}; If[N[Chop[RayL]] >= 0. && SCx^2 + SCy^2 <= 625. && Abs[ry + RayL*yunit - SCx] + Abs[rz + RayL*zunit - SCy] + Abs[-91.80458356418029 + rx + RayL*xunit + Sqrt[8428.081563392561 - SCx^2 - SCy^2]] < 1.*^-7, {RayL, SCx, SCy}, {-1., 0., 0.}], {RayL, SCx, SCy} = {-TempVar2 + TempVar3, ry + (-TempVar2 + TempVar3)*yunit, rz + (-TempVar2 + TempVar3)*zunit}; If[N[Chop[RayL]] >= 0. && SCx^2 + SCy^2 <= 625. && Abs[ry + RayL*yunit - SCx] + Abs[rz + RayL*zunit - SCy] + Abs[-91.80458356418029 + rx + RayL*xunit + Sqrt[8428.081563392561 - SCx^2 - SCy^2]] < 1.*^-7, {RayL, SCx, SCy}, {-1., 0., 0.}]}; If[TempVar[[1]] == TempVar[[2]], {TempVar[[1]]}, TempVar], {{-1., 0., 0.}}]]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5618.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]); holeQlist = Drop[holeQlist, 1]; Drop[intersectionslist, 1]]); Which[resonatenumber == 1, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ3]] + r2*Re[Sin[0.017453292519943295*θ3]]; yunit = r2*Re[Cos[0.017453292519943295*θ3]] - 1.*r1*Re[Sin[0.017453292519943295*θ3]]; zunit = r3*Re[Cos[0.017453292519943295*θ3]^2 + Sin[0.017453292519943295*θ3]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = (rex - 1.*Re[x3])*Re[Cos[0.017453292519943295*θ3]] + (rey - 1.*Re[y3])*Re[Sin[0.017453292519943295*θ3]]; ry = (rey - 1.*Re[y3])*Re[Cos[0.017453292519943295*θ3]] - 1.*(rex - 1.*Re[x3])*Re[Sin[0.017453292519943295*θ3]]; rz = rez*Re[Cos[0.017453292519943295*θ3]^2 + Sin[0.017453292519943295*θ3]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {1., 1., 5294.}; {componentnumber, surfacenumber, surfaceid} = {1., 1., 5294.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = Re[x3] + rxhlp*Re[Cos[0.017453292519943295*θ3]] - 1.*ryhlp*Re[Sin[0.017453292519943295*θ3]]; rey = Re[y3] + ryhlp*Re[Cos[0.017453292519943295*θ3]] + rxhlp*Re[Sin[0.017453292519943295*θ3]]; rez = rzhlp*Re[Cos[0.017453292519943295*θ3]^2 + Sin[0.017453292519943295*θ3]^2]; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., -1.*((Sign[PlanoConvexLensFocalLength]*ray2)/(0.2690707829696608*PlanoConvexLensFocalLength^2 - 1.*ray2^2 - 1.*ray3^2)^0.5), -1.*((Sign[PlanoConvexLensFocalLength]*ray3)/(0.2690707829696608*PlanoConvexLensFocalLength^2 - 1.*ray2^2 - 1.*ray3^2)^0.5)}, {(Sign[PlanoConvexLensFocalLength]*ray2)/(0.2690707829696608*PlanoConvexLensFocalLength^2 - 1.*ray2^2 - 1.*ray3^2)^0.5, 1., 0.}, {(Sign[PlanoConvexLensFocalLength]*ray3)/(0.2690707829696608*PlanoConvexLensFocalLength^2 - 1.*ray2^2 - 1.*ray3^2)^0.5, 0., 1.}}]; dummymatrix = ({{Re[Cos[0.017453292519943295*θ3]], -1.*Re[Sin[0.017453292519943295*θ3]], 0.}, {Re[Sin[0.017453292519943295*θ3]], Re[Cos[0.017453292519943295*θ3]], 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{Re[Cos[0.017453292519943295*θ3]], Re[Sin[0.017453292519943295*θ3]], 0.}, {-1.*Re[Sin[0.017453292519943295*θ3]], Re[Cos[0.017453292519943295*θ3]], 0.}, {0., 0., 1.}}; surfacetranslationvector = {Re[x3], Re[y3], 0.}; activeregion = 1.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; ZAxis = First[surfnorm]*Sign[First[surfnorm] . {r1, r2, r3}]; raytiltz = ZAxis . {r1, r2, r3}; raytiltx = 1 - raytiltz^2; If[raytiltx < 2.220446049250313*^-16, raytiltx = 0., raytiltx = Sqrt[raytiltx]]; XAxis = {r1, r2, r3} - ZAxis*raytiltz; If[Abs[raytiltx] < 1.*^-7, XAxis = surfnorm[[2]], XAxis = XAxis/raytiltx]; YAxis = {-(ZAxis[[3]]*XAxis[[2]]) + ZAxis[[2]]*XAxis[[3]], ZAxis[[3]]*XAxis[[1]] - ZAxis[[1]]*XAxis[[3]], -(ZAxis[[2]]*XAxis[[1]]) + ZAxis[[1]]*XAxis[[2]]}; YAxis = YAxis/Sqrt[YAxis . YAxis]; PAxis = ZAxis*{r1, r2, r3} . XAxis - XAxis*{r1, r2, r3} . ZAxis; PAxis = PAxis/Sqrt[PAxis . PAxis]; normalizedpolarization = {pol1, pol2, pol3}[[{1, 2}]]; normalizedpolarization = normalizedpolarization/Sqrt[normalizedpolarization . normalizedpolarization]; allcreatedamplitudes = {{I*0., I*0., I*0.}}; amplitude = Sqrt[intensity]*(normalizedpolarization[[1]]*{r4, r5, r6} + normalizedpolarization[[2]]*{r7, r8, r9}*Exp[I*pol3*0.017453292519943295]); perpendicularamplitude = amplitude . YAxis; parallelamplitude = amplitude . PAxis; If[activeregion*(surfacerotationmatrix . {r1, r2, r3})[[1]] > 0, index2 = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]], index2 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]]]; n12 = index1/index2; index = index2; If[1 - n12^2*raytiltx^2 >= 0., dummyvector = n12*{r1, r2, r3} + ZAxis*(-(n12*raytiltz) + Sqrt[1 - n12^2*raytiltx^2]); {r1, r2, r3} = dummyvector; 1., If[{r1, r2, r3} . surfnorm[[1]] > 0, phaseshift = phaseshift + 0.5, 1.]; index2 = index1; index = index1; dummyvector = {r1, r2, r3} - 2*ZAxis*ZAxis . {r1, r2, r3}; {r1, r2, r3} = dummyvector; dummyvector = {pol1, pol2, pol3} + {0, 0, -180}; {pol1, pol2, pol3} = dummyvector; 1.]; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; originalrotation = Partition[Take[originalray, {7, 15}], 3]; previoustilt = originalrotation[[1]]; transmatrix = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; rotationaxis = Cross[{1., 0., 0.}, {r1, r2, r3}]; axismagnitude = Sqrt[rotationaxis . rotationaxis]; If[Chop[axismagnitude] != 0., rotationaxis = rotationaxis/axismagnitude; axismatrix = (#1*rotationaxis & ) /@ rotationaxis; crossmatrix = {{0., -rotationaxis[[3]], rotationaxis[[2]]}, {rotationaxis[[3]], 0., -rotationaxis[[1]]}, {-rotationaxis[[2]], rotationaxis[[1]], 0.}}; cosangle = {1., 0., 0.} . {r1, r2, r3}; If[1. - cosangle < 2.220446049250313*^-16, cosangle = 1.]; sinangle = 1 - cosangle^2; If[sinangle < 2.220446049250313*^-16, sinangle = 0., sinangle = Sqrt[sinangle]]; axismatrix + ({{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}} - axismatrix)*cosangle + crossmatrix*sinangle, {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = If[Sign[{1., 0., 0.} . {r1, r2, r3}] === 1, {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}, {{-1., 0., 0.}, {0., -1., 0.}, {0., 0., 1.}}]]) & , allcreatedrays]; allcreatedrays = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = Function[mm, (mm . #1 & ) /@ {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}][transmatrix[[First[#2]]]]; tiltmagnitude = {r1, r2, r3} . {r1, r2, r3}; If[Abs[tiltmagnitude - 1.] > 1.*^-6, dummyvector = {r1, r2, r3}/Sqrt[tiltmagnitude]; {r1, r2, r3} = dummyvector; dummymatrix = (#1/Sqrt[#1 . #1] & ) /@ {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}}; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = dummymatrix; 1., 1.]; If[allcreatedamplitudes != {{I*0., I*0., I*0.}}, amplitude = allcreatedamplitudes[[First[#2]]]; hor = {r4, r5, r6} . amplitude; ver = {r7, r8, r9} . amplitude; If[Abs[hor] > 0. || Abs[ver] > 0., {pol1, pol2, pol3} = {Abs[hor], Abs[ver], 0.}; dummyvector = {pol1, pol2, pol3}/Sqrt[{pol1, pol2, pol3} . {pol1, pol2, pol3}]; {pol1, pol2, pol3} = dummyvector; dummyvector = ReplacePart[{pol1, pol2, pol3}, (If[ver == 0., 0., Arg[ver]] - If[hor == 0., 0., Arg[hor]])/Degree, 3]; {pol1, pol2, pol3} = dummyvector]; 1., 1.]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}) & , allcreatedrays]); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 2, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ3]] + r2*Re[Sin[0.017453292519943295*θ3]]; yunit = r2*Re[Cos[0.017453292519943295*θ3]] - 1.*r1*Re[Sin[0.017453292519943295*θ3]]; zunit = r3*Re[Cos[0.017453292519943295*θ3]^2 + Sin[0.017453292519943295*θ3]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = Re[Cos[0.017453292519943295*θ3]]*(rex - 1.*Re[x3 + PlanoConvexLensThickness*Cos[0.017453292519943295*θ3]]) + Re[Sin[0.017453292519943295*θ3]]*(rey - 1.*Re[y3 + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]]); ry = -1.*(rex - 1.*Re[x3 + PlanoConvexLensThickness*Cos[0.017453292519943295*θ3]])*Re[Sin[0.017453292519943295*θ3]] + Re[Cos[0.017453292519943295*θ3]]*(rey - 1.*Re[y3 + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]]); rz = rez*Re[Cos[0.017453292519943295*θ3]^2 + Sin[0.017453292519943295*θ3]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {1., 2., 5295.}; {componentnumber, surfacenumber, surfaceid} = {1., 2., 5295.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = rxhlp*Re[Cos[0.017453292519943295*θ3]] + Re[x3 + PlanoConvexLensThickness*Cos[0.017453292519943295*θ3]] - 1.*ryhlp*Re[Sin[0.017453292519943295*θ3]]; rey = ryhlp*Re[Cos[0.017453292519943295*θ3]] + rxhlp*Re[Sin[0.017453292519943295*θ3]] + Re[y3 + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]]; rez = rzhlp*Re[Cos[0.017453292519943295*θ3]^2 + Sin[0.017453292519943295*θ3]^2]; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}]; dummymatrix = ({{Re[Cos[0.017453292519943295*θ3]], -1.*Re[Sin[0.017453292519943295*θ3]], 0.}, {Re[Sin[0.017453292519943295*θ3]], Re[Cos[0.017453292519943295*θ3]], 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{Re[Cos[0.017453292519943295*θ3]], Re[Sin[0.017453292519943295*θ3]], 0.}, {-1.*Re[Sin[0.017453292519943295*θ3]], Re[Cos[0.017453292519943295*θ3]], 0.}, {0., 0., 1.}}; surfacetranslationvector = {Re[x3 + PlanoConvexLensThickness*Cos[0.017453292519943295*θ3]], Re[y3 + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]], 0.}; activeregion = -1.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; ZAxis = First[surfnorm]*Sign[First[surfnorm] . {r1, r2, r3}]; raytiltz = ZAxis . {r1, r2, r3}; raytiltx = 1 - raytiltz^2; If[raytiltx < 2.220446049250313*^-16, raytiltx = 0., raytiltx = Sqrt[raytiltx]]; XAxis = {r1, r2, r3} - ZAxis*raytiltz; If[Abs[raytiltx] < 1.*^-7, XAxis = surfnorm[[2]], XAxis = XAxis/raytiltx]; YAxis = {-(ZAxis[[3]]*XAxis[[2]]) + ZAxis[[2]]*XAxis[[3]], ZAxis[[3]]*XAxis[[1]] - ZAxis[[1]]*XAxis[[3]], -(ZAxis[[2]]*XAxis[[1]]) + ZAxis[[1]]*XAxis[[2]]}; YAxis = YAxis/Sqrt[YAxis . YAxis]; PAxis = ZAxis*{r1, r2, r3} . XAxis - XAxis*{r1, r2, r3} . ZAxis; PAxis = PAxis/Sqrt[PAxis . PAxis]; normalizedpolarization = {pol1, pol2, pol3}[[{1, 2}]]; normalizedpolarization = normalizedpolarization/Sqrt[normalizedpolarization . normalizedpolarization]; allcreatedamplitudes = {{I*0., I*0., I*0.}}; amplitude = Sqrt[intensity]*(normalizedpolarization[[1]]*{r4, r5, r6} + normalizedpolarization[[2]]*{r7, r8, r9}*Exp[I*pol3*0.017453292519943295]); perpendicularamplitude = amplitude . YAxis; parallelamplitude = amplitude . PAxis; If[activeregion*(surfacerotationmatrix . {r1, r2, r3})[[1]] > 0, index2 = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]], index2 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]]]; n12 = index1/index2; index = index2; If[1 - n12^2*raytiltx^2 >= 0., dummyvector = n12*{r1, r2, r3} + ZAxis*(-(n12*raytiltz) + Sqrt[1 - n12^2*raytiltx^2]); {r1, r2, r3} = dummyvector; 1., If[{r1, r2, r3} . surfnorm[[1]] > 0, phaseshift = phaseshift + 0.5, 1.]; index2 = index1; index = index1; dummyvector = {r1, r2, r3} - 2*ZAxis*ZAxis . {r1, r2, r3}; {r1, r2, r3} = dummyvector; dummyvector = {pol1, pol2, pol3} + {0, 0, -180}; {pol1, pol2, pol3} = dummyvector; 1.]; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; originalrotation = Partition[Take[originalray, {7, 15}], 3]; previoustilt = originalrotation[[1]]; transmatrix = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; rotationaxis = Cross[{1., 0., 0.}, {r1, r2, r3}]; axismagnitude = Sqrt[rotationaxis . rotationaxis]; If[Chop[axismagnitude] != 0., rotationaxis = rotationaxis/axismagnitude; axismatrix = (#1*rotationaxis & ) /@ rotationaxis; crossmatrix = {{0., -rotationaxis[[3]], rotationaxis[[2]]}, {rotationaxis[[3]], 0., -rotationaxis[[1]]}, {-rotationaxis[[2]], rotationaxis[[1]], 0.}}; cosangle = {1., 0., 0.} . {r1, r2, r3}; If[1. - cosangle < 2.220446049250313*^-16, cosangle = 1.]; sinangle = 1 - cosangle^2; If[sinangle < 2.220446049250313*^-16, sinangle = 0., sinangle = Sqrt[sinangle]]; axismatrix + ({{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}} - axismatrix)*cosangle + crossmatrix*sinangle, {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = If[Sign[{1., 0., 0.} . {r1, r2, r3}] === 1, {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}, {{-1., 0., 0.}, {0., -1., 0.}, {0., 0., 1.}}]]) & , allcreatedrays]; allcreatedrays = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = Function[mm, (mm . #1 & ) /@ {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}][transmatrix[[First[#2]]]]; tiltmagnitude = {r1, r2, r3} . {r1, r2, r3}; If[Abs[tiltmagnitude - 1.] > 1.*^-6, dummyvector = {r1, r2, r3}/Sqrt[tiltmagnitude]; {r1, r2, r3} = dummyvector; dummymatrix = (#1/Sqrt[#1 . #1] & ) /@ {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}}; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = dummymatrix; 1., 1.]; If[allcreatedamplitudes != {{I*0., I*0., I*0.}}, amplitude = allcreatedamplitudes[[First[#2]]]; hor = {r4, r5, r6} . amplitude; ver = {r7, r8, r9} . amplitude; If[Abs[hor] > 0. || Abs[ver] > 0., {pol1, pol2, pol3} = {Abs[hor], Abs[ver], 0.}; dummyvector = {pol1, pol2, pol3}/Sqrt[{pol1, pol2, pol3} . {pol1, pol2, pol3}]; {pol1, pol2, pol3} = dummyvector; dummyvector = ReplacePart[{pol1, pol2, pol3}, (If[ver == 0., 0., Arg[ver]] - If[hor == 0., 0., Arg[hor]])/Degree, 3]; {pol1, pol2, pol3} = dummyvector]; 1., 1.]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}) & , allcreatedrays]); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 3, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ9]] + r2*Re[Sin[0.017453292519943295*θ9]]; yunit = r2*Re[Cos[0.017453292519943295*θ9]] - 1.*r1*Re[Sin[0.017453292519943295*θ9]]; zunit = r3*Re[Cos[0.017453292519943295*θ9]^2 + Sin[0.017453292519943295*θ9]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = (rex - 1.*Re[x9])*Re[Cos[0.017453292519943295*θ9]] + (rey - 1.*Re[y9])*Re[Sin[0.017453292519943295*θ9]]; ry = (rey - 1.*Re[y9])*Re[Cos[0.017453292519943295*θ9]] - 1.*(rex - 1.*Re[x9])*Re[Sin[0.017453292519943295*θ9]]; rz = rez*Re[Cos[0.017453292519943295*θ9]^2 + Sin[0.017453292519943295*θ9]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {1., 3., 5358.}; {componentnumber, surfacenumber, surfaceid} = {1., 3., 5358.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = Re[x9] + rxhlp*Re[Cos[0.017453292519943295*θ9]] - 1.*ryhlp*Re[Sin[0.017453292519943295*θ9]]; rey = Re[y9] + ryhlp*Re[Cos[0.017453292519943295*θ9]] + rxhlp*Re[Sin[0.017453292519943295*θ9]]; rez = rzhlp*Re[Cos[0.017453292519943295*θ9]^2 + Sin[0.017453292519943295*θ9]^2]; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., -(ray2/(937.2705118649425 - ray2^2 - ray3^2)^2^(-1)), -(ray3/(937.2705118649425 - ray2^2 - ray3^2)^2^(-1))}, {ray2/(937.2705118649425 - ray2^2 - ray3^2)^2^(-1), 1., 0.}, {ray3/(937.2705118649425 - ray2^2 - ray3^2)^2^(-1), 0., 1.}}]; dummymatrix = ({{Re[Cos[0.017453292519943295*θ9]], -1.*Re[Sin[0.017453292519943295*θ9]], 0.}, {Re[Sin[0.017453292519943295*θ9]], Re[Cos[0.017453292519943295*θ9]], 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{Re[Cos[0.017453292519943295*θ9]], Re[Sin[0.017453292519943295*θ9]], 0.}, {-1.*Re[Sin[0.017453292519943295*θ9]], Re[Cos[0.017453292519943295*θ9]], 0.}, {0., 0., 1.}}; surfacetranslationvector = {Re[x9], Re[y9], 0.}; activeregion = 1.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; ZAxis = First[surfnorm]*Sign[First[surfnorm] . {r1, r2, r3}]; raytiltz = ZAxis . {r1, r2, r3}; raytiltx = 1 - raytiltz^2; If[raytiltx < 2.220446049250313*^-16, raytiltx = 0., raytiltx = Sqrt[raytiltx]]; XAxis = {r1, r2, r3} - ZAxis*raytiltz; If[Abs[raytiltx] < 1.*^-7, XAxis = surfnorm[[2]], XAxis = XAxis/raytiltx]; YAxis = {-(ZAxis[[3]]*XAxis[[2]]) + ZAxis[[2]]*XAxis[[3]], ZAxis[[3]]*XAxis[[1]] - ZAxis[[1]]*XAxis[[3]], -(ZAxis[[2]]*XAxis[[1]]) + ZAxis[[1]]*XAxis[[2]]}; YAxis = YAxis/Sqrt[YAxis . YAxis]; PAxis = ZAxis*{r1, r2, r3} . XAxis - XAxis*{r1, r2, r3} . ZAxis; PAxis = PAxis/Sqrt[PAxis . PAxis]; normalizedpolarization = {pol1, pol2, pol3}[[{1, 2}]]; normalizedpolarization = normalizedpolarization/Sqrt[normalizedpolarization . normalizedpolarization]; allcreatedamplitudes = {{I*0., I*0., I*0.}}; amplitude = Sqrt[intensity]*(normalizedpolarization[[1]]*{r4, r5, r6} + normalizedpolarization[[2]]*{r7, r8, r9}*Exp[I*pol3*0.017453292519943295]); perpendicularamplitude = amplitude . YAxis; parallelamplitude = amplitude . PAxis; If[activeregion*(surfacerotationmatrix . {r1, r2, r3})[[1]] > 0, index2 = Sqrt[1.957925419324613 + 0.048255135182472264*wavelength^2 + 0.1422250055971522/wavelength^2 - 0.05660788966187853/wavelength^4 + 0.01140110294469355/wavelength^6 - 0.000875836614554464/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]], index2 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[1.957925419324613 + 0.048255135182472264*wavelength^2 + 0.1422250055971522/wavelength^2 - 0.05660788966187853/wavelength^4 + 0.01140110294469355/wavelength^6 - 0.000875836614554464/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[1.957925419324613 + 0.048255135182472264*wavelength^2 + 0.1422250055971522/wavelength^2 - 0.05660788966187853/wavelength^4 + 0.01140110294469355/wavelength^6 - 0.000875836614554464/wavelength^8]]]; n12 = index1/index2; index = index2; If[1 - n12^2*raytiltx^2 >= 0., dummyvector = n12*{r1, r2, r3} + ZAxis*(-(n12*raytiltz) + Sqrt[1 - n12^2*raytiltx^2]); {r1, r2, r3} = dummyvector; 1., If[{r1, r2, r3} . surfnorm[[1]] > 0, phaseshift = phaseshift + 0.5, 1.]; index2 = index1; index = index1; dummyvector = {r1, r2, r3} - 2*ZAxis*ZAxis . {r1, r2, r3}; {r1, r2, r3} = dummyvector; dummyvector = {pol1, pol2, pol3} + {0, 0, -180}; {pol1, pol2, pol3} = dummyvector; 1.]; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; originalrotation = Partition[Take[originalray, {7, 15}], 3]; previoustilt = originalrotation[[1]]; transmatrix = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; rotationaxis = Cross[{1., 0., 0.}, {r1, r2, r3}]; axismagnitude = Sqrt[rotationaxis . rotationaxis]; If[Chop[axismagnitude] != 0., rotationaxis = rotationaxis/axismagnitude; axismatrix = (#1*rotationaxis & ) /@ rotationaxis; crossmatrix = {{0., -rotationaxis[[3]], rotationaxis[[2]]}, {rotationaxis[[3]], 0., -rotationaxis[[1]]}, {-rotationaxis[[2]], rotationaxis[[1]], 0.}}; cosangle = {1., 0., 0.} . {r1, r2, r3}; If[1. - cosangle < 2.220446049250313*^-16, cosangle = 1.]; sinangle = 1 - cosangle^2; If[sinangle < 2.220446049250313*^-16, sinangle = 0., sinangle = Sqrt[sinangle]]; axismatrix + ({{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}} - axismatrix)*cosangle + crossmatrix*sinangle, {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = If[Sign[{1., 0., 0.} . {r1, r2, r3}] === 1, {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}, {{-1., 0., 0.}, {0., -1., 0.}, {0., 0., 1.}}]]) & , allcreatedrays]; allcreatedrays = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = Function[mm, (mm . #1 & ) /@ {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}][transmatrix[[First[#2]]]]; tiltmagnitude = {r1, r2, r3} . {r1, r2, r3}; If[Abs[tiltmagnitude - 1.] > 1.*^-6, dummyvector = {r1, r2, r3}/Sqrt[tiltmagnitude]; {r1, r2, r3} = dummyvector; dummymatrix = (#1/Sqrt[#1 . #1] & ) /@ {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}}; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = dummymatrix; 1., 1.]; If[allcreatedamplitudes != {{I*0., I*0., I*0.}}, amplitude = allcreatedamplitudes[[First[#2]]]; hor = {r4, r5, r6} . amplitude; ver = {r7, r8, r9} . amplitude; If[Abs[hor] > 0. || Abs[ver] > 0., {pol1, pol2, pol3} = {Abs[hor], Abs[ver], 0.}; dummyvector = {pol1, pol2, pol3}/Sqrt[{pol1, pol2, pol3} . {pol1, pol2, pol3}]; {pol1, pol2, pol3} = dummyvector; dummyvector = ReplacePart[{pol1, pol2, pol3}, (If[ver == 0., 0., Arg[ver]] - If[hor == 0., 0., Arg[hor]])/Degree, 3]; {pol1, pol2, pol3} = dummyvector]; 1., 1.]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}) & , allcreatedrays]); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 4, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ9]] + r2*Re[Sin[0.017453292519943295*θ9]]; yunit = r2*Re[Cos[0.017453292519943295*θ9]] - 1.*r1*Re[Sin[0.017453292519943295*θ9]]; zunit = r3*Re[Cos[0.017453292519943295*θ9]^2 + Sin[0.017453292519943295*θ9]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = Re[Cos[0.017453292519943295*θ9]]*(rex - 1.*Re[x9 + 28.*Cos[0.017453292519943295*θ9]]) + Re[Sin[0.017453292519943295*θ9]]*(rey - 1.*Re[y9 + 28.*Sin[0.017453292519943295*θ9]]); ry = -1.*(rex - 1.*Re[x9 + 28.*Cos[0.017453292519943295*θ9]])*Re[Sin[0.017453292519943295*θ9]] + Re[Cos[0.017453292519943295*θ9]]*(rey - 1.*Re[y9 + 28.*Sin[0.017453292519943295*θ9]]); rz = rez*Re[Cos[0.017453292519943295*θ9]^2 + Sin[0.017453292519943295*θ9]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {1., 4., 5359.}; {componentnumber, surfacenumber, surfaceid} = {1., 4., 5359.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = rxhlp*Re[Cos[0.017453292519943295*θ9]] + Re[x9 + 28.*Cos[0.017453292519943295*θ9]] - 1.*ryhlp*Re[Sin[0.017453292519943295*θ9]]; rey = ryhlp*Re[Cos[0.017453292519943295*θ9]] + rxhlp*Re[Sin[0.017453292519943295*θ9]] + Re[y9 + 28.*Sin[0.017453292519943295*θ9]]; rez = rzhlp*Re[Cos[0.017453292519943295*θ9]^2 + Sin[0.017453292519943295*θ9]^2]; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., -(-(ray2/(937.2705118649425 - ray2^2 - ray3^2)^2^(-1))), -(-(ray3/(937.2705118649425 - ray2^2 - ray3^2)^2^(-1)))}, {-(ray2/(937.2705118649425 - ray2^2 - ray3^2)^2^(-1)), 1., 0.}, {-(ray3/(937.2705118649425 - ray2^2 - ray3^2)^2^(-1)), 0., 1.}}]; dummymatrix = ({{Re[Cos[0.017453292519943295*θ9]], -1.*Re[Sin[0.017453292519943295*θ9]], 0.}, {Re[Sin[0.017453292519943295*θ9]], Re[Cos[0.017453292519943295*θ9]], 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{Re[Cos[0.017453292519943295*θ9]], Re[Sin[0.017453292519943295*θ9]], 0.}, {-1.*Re[Sin[0.017453292519943295*θ9]], Re[Cos[0.017453292519943295*θ9]], 0.}, {0., 0., 1.}}; surfacetranslationvector = {Re[x9 + 28.*Cos[0.017453292519943295*θ9]], Re[y9 + 28.*Sin[0.017453292519943295*θ9]], 0.}; activeregion = -1.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; ZAxis = First[surfnorm]*Sign[First[surfnorm] . {r1, r2, r3}]; raytiltz = ZAxis . {r1, r2, r3}; raytiltx = 1 - raytiltz^2; If[raytiltx < 2.220446049250313*^-16, raytiltx = 0., raytiltx = Sqrt[raytiltx]]; XAxis = {r1, r2, r3} - ZAxis*raytiltz; If[Abs[raytiltx] < 1.*^-7, XAxis = surfnorm[[2]], XAxis = XAxis/raytiltx]; YAxis = {-(ZAxis[[3]]*XAxis[[2]]) + ZAxis[[2]]*XAxis[[3]], ZAxis[[3]]*XAxis[[1]] - ZAxis[[1]]*XAxis[[3]], -(ZAxis[[2]]*XAxis[[1]]) + ZAxis[[1]]*XAxis[[2]]}; YAxis = YAxis/Sqrt[YAxis . YAxis]; PAxis = ZAxis*{r1, r2, r3} . XAxis - XAxis*{r1, r2, r3} . ZAxis; PAxis = PAxis/Sqrt[PAxis . PAxis]; normalizedpolarization = {pol1, pol2, pol3}[[{1, 2}]]; normalizedpolarization = normalizedpolarization/Sqrt[normalizedpolarization . normalizedpolarization]; allcreatedamplitudes = {{I*0., I*0., I*0.}}; amplitude = Sqrt[intensity]*(normalizedpolarization[[1]]*{r4, r5, r6} + normalizedpolarization[[2]]*{r7, r8, r9}*Exp[I*pol3*0.017453292519943295]); perpendicularamplitude = amplitude . YAxis; parallelamplitude = amplitude . PAxis; If[activeregion*(surfacerotationmatrix . {r1, r2, r3})[[1]] > 0, index2 = Sqrt[1.957925419324613 + 0.048255135182472264*wavelength^2 + 0.1422250055971522/wavelength^2 - 0.05660788966187853/wavelength^4 + 0.01140110294469355/wavelength^6 - 0.000875836614554464/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]], index2 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[1.957925419324613 + 0.048255135182472264*wavelength^2 + 0.1422250055971522/wavelength^2 - 0.05660788966187853/wavelength^4 + 0.01140110294469355/wavelength^6 - 0.000875836614554464/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[1.957925419324613 + 0.048255135182472264*wavelength^2 + 0.1422250055971522/wavelength^2 - 0.05660788966187853/wavelength^4 + 0.01140110294469355/wavelength^6 - 0.000875836614554464/wavelength^8]]]; n12 = index1/index2; index = index2; If[1 - n12^2*raytiltx^2 >= 0., dummyvector = n12*{r1, r2, r3} + ZAxis*(-(n12*raytiltz) + Sqrt[1 - n12^2*raytiltx^2]); {r1, r2, r3} = dummyvector; 1., If[{r1, r2, r3} . surfnorm[[1]] > 0, phaseshift = phaseshift + 0.5, 1.]; index2 = index1; index = index1; dummyvector = {r1, r2, r3} - 2*ZAxis*ZAxis . {r1, r2, r3}; {r1, r2, r3} = dummyvector; dummyvector = {pol1, pol2, pol3} + {0, 0, -180}; {pol1, pol2, pol3} = dummyvector; 1.]; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; originalrotation = Partition[Take[originalray, {7, 15}], 3]; previoustilt = originalrotation[[1]]; transmatrix = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; rotationaxis = Cross[{1., 0., 0.}, {r1, r2, r3}]; axismagnitude = Sqrt[rotationaxis . rotationaxis]; If[Chop[axismagnitude] != 0., rotationaxis = rotationaxis/axismagnitude; axismatrix = (#1*rotationaxis & ) /@ rotationaxis; crossmatrix = {{0., -rotationaxis[[3]], rotationaxis[[2]]}, {rotationaxis[[3]], 0., -rotationaxis[[1]]}, {-rotationaxis[[2]], rotationaxis[[1]], 0.}}; cosangle = {1., 0., 0.} . {r1, r2, r3}; If[1. - cosangle < 2.220446049250313*^-16, cosangle = 1.]; sinangle = 1 - cosangle^2; If[sinangle < 2.220446049250313*^-16, sinangle = 0., sinangle = Sqrt[sinangle]]; axismatrix + ({{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}} - axismatrix)*cosangle + crossmatrix*sinangle, {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = If[Sign[{1., 0., 0.} . {r1, r2, r3}] === 1, {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}, {{-1., 0., 0.}, {0., -1., 0.}, {0., 0., 1.}}]]) & , allcreatedrays]; allcreatedrays = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = Function[mm, (mm . #1 & ) /@ {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}][transmatrix[[First[#2]]]]; tiltmagnitude = {r1, r2, r3} . {r1, r2, r3}; If[Abs[tiltmagnitude - 1.] > 1.*^-6, dummyvector = {r1, r2, r3}/Sqrt[tiltmagnitude]; {r1, r2, r3} = dummyvector; dummymatrix = (#1/Sqrt[#1 . #1] & ) /@ {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}}; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = dummymatrix; 1., 1.]; If[allcreatedamplitudes != {{I*0., I*0., I*0.}}, amplitude = allcreatedamplitudes[[First[#2]]]; hor = {r4, r5, r6} . amplitude; ver = {r7, r8, r9} . amplitude; If[Abs[hor] > 0. || Abs[ver] > 0., {pol1, pol2, pol3} = {Abs[hor], Abs[ver], 0.}; dummyvector = {pol1, pol2, pol3}/Sqrt[{pol1, pol2, pol3} . {pol1, pol2, pol3}]; {pol1, pol2, pol3} = dummyvector; dummyvector = ReplacePart[{pol1, pol2, pol3}, (If[ver == 0., 0., Arg[ver]] - If[hor == 0., 0., Arg[hor]])/Degree, 3]; {pol1, pol2, pol3} = dummyvector]; 1., 1.]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}) & , allcreatedrays]); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 5, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ4]] + r2*Re[Sin[0.017453292519943295*θ4]]; yunit = r2*Re[Cos[0.017453292519943295*θ4]] - 1.*r1*Re[Sin[0.017453292519943295*θ4]]; zunit = r3*Re[Cos[0.017453292519943295*θ4]^2 + Sin[0.017453292519943295*θ4]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = (rex - 1.*Re[x4])*Re[Cos[0.017453292519943295*θ4]] + (rey - 1.*Re[y4])*Re[Sin[0.017453292519943295*θ4]]; ry = (rey - 1.*Re[y4])*Re[Cos[0.017453292519943295*θ4]] - 1.*(rex - 1.*Re[x4])*Re[Sin[0.017453292519943295*θ4]]; rz = rez*Re[Cos[0.017453292519943295*θ4]^2 + Sin[0.017453292519943295*θ4]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {1., 5., 5423.}; {componentnumber, surfacenumber, surfaceid} = {1., 5., 5423.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = Re[x4] + rxhlp*Re[Cos[0.017453292519943295*θ4]] - 1.*ryhlp*Re[Sin[0.017453292519943295*θ4]]; rey = Re[y4] + ryhlp*Re[Cos[0.017453292519943295*θ4]] + rxhlp*Re[Sin[0.017453292519943295*θ4]]; rez = rzhlp*Re[Cos[0.017453292519943295*θ4]^2 + Sin[0.017453292519943295*θ4]^2]; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., -1.*((Sign[PlanoConcaveLensFocalLength]*ray2)/(0.2690707829696608*PlanoConcaveLensFocalLength^2 - 1.*ray2^2 - 1.*ray3^2)^0.5), -1.*((Sign[PlanoConcaveLensFocalLength]*ray3)/(0.2690707829696608*PlanoConcaveLensFocalLength^2 - 1.*ray2^2 - 1.*ray3^2)^0.5)}, {(Sign[PlanoConcaveLensFocalLength]*ray2)/(0.2690707829696608*PlanoConcaveLensFocalLength^2 - 1.*ray2^2 - 1.*ray3^2)^0.5, 1., 0.}, {(Sign[PlanoConcaveLensFocalLength]*ray3)/(0.2690707829696608*PlanoConcaveLensFocalLength^2 - 1.*ray2^2 - 1.*ray3^2)^0.5, 0., 1.}}]; dummymatrix = ({{Re[Cos[0.017453292519943295*θ4]], -1.*Re[Sin[0.017453292519943295*θ4]], 0.}, {Re[Sin[0.017453292519943295*θ4]], Re[Cos[0.017453292519943295*θ4]], 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{Re[Cos[0.017453292519943295*θ4]], Re[Sin[0.017453292519943295*θ4]], 0.}, {-1.*Re[Sin[0.017453292519943295*θ4]], Re[Cos[0.017453292519943295*θ4]], 0.}, {0., 0., 1.}}; surfacetranslationvector = {Re[x4], Re[y4], 0.}; activeregion = 1.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; ZAxis = First[surfnorm]*Sign[First[surfnorm] . {r1, r2, r3}]; raytiltz = ZAxis . {r1, r2, r3}; raytiltx = 1 - raytiltz^2; If[raytiltx < 2.220446049250313*^-16, raytiltx = 0., raytiltx = Sqrt[raytiltx]]; XAxis = {r1, r2, r3} - ZAxis*raytiltz; If[Abs[raytiltx] < 1.*^-7, XAxis = surfnorm[[2]], XAxis = XAxis/raytiltx]; YAxis = {-(ZAxis[[3]]*XAxis[[2]]) + ZAxis[[2]]*XAxis[[3]], ZAxis[[3]]*XAxis[[1]] - ZAxis[[1]]*XAxis[[3]], -(ZAxis[[2]]*XAxis[[1]]) + ZAxis[[1]]*XAxis[[2]]}; YAxis = YAxis/Sqrt[YAxis . YAxis]; PAxis = ZAxis*{r1, r2, r3} . XAxis - XAxis*{r1, r2, r3} . ZAxis; PAxis = PAxis/Sqrt[PAxis . PAxis]; normalizedpolarization = {pol1, pol2, pol3}[[{1, 2}]]; normalizedpolarization = normalizedpolarization/Sqrt[normalizedpolarization . normalizedpolarization]; allcreatedamplitudes = {{I*0., I*0., I*0.}}; amplitude = Sqrt[intensity]*(normalizedpolarization[[1]]*{r4, r5, r6} + normalizedpolarization[[2]]*{r7, r8, r9}*Exp[I*pol3*0.017453292519943295]); perpendicularamplitude = amplitude . YAxis; parallelamplitude = amplitude . PAxis; If[activeregion*(surfacerotationmatrix . {r1, r2, r3})[[1]] > 0, index2 = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]], index2 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]]]; n12 = index1/index2; index = index2; If[1 - n12^2*raytiltx^2 >= 0., dummyvector = n12*{r1, r2, r3} + ZAxis*(-(n12*raytiltz) + Sqrt[1 - n12^2*raytiltx^2]); {r1, r2, r3} = dummyvector; 1., If[{r1, r2, r3} . surfnorm[[1]] > 0, phaseshift = phaseshift + 0.5, 1.]; index2 = index1; index = index1; dummyvector = {r1, r2, r3} - 2*ZAxis*ZAxis . {r1, r2, r3}; {r1, r2, r3} = dummyvector; dummyvector = {pol1, pol2, pol3} + {0, 0, -180}; {pol1, pol2, pol3} = dummyvector; 1.]; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; originalrotation = Partition[Take[originalray, {7, 15}], 3]; previoustilt = originalrotation[[1]]; transmatrix = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; rotationaxis = Cross[{1., 0., 0.}, {r1, r2, r3}]; axismagnitude = Sqrt[rotationaxis . rotationaxis]; If[Chop[axismagnitude] != 0., rotationaxis = rotationaxis/axismagnitude; axismatrix = (#1*rotationaxis & ) /@ rotationaxis; crossmatrix = {{0., -rotationaxis[[3]], rotationaxis[[2]]}, {rotationaxis[[3]], 0., -rotationaxis[[1]]}, {-rotationaxis[[2]], rotationaxis[[1]], 0.}}; cosangle = {1., 0., 0.} . {r1, r2, r3}; If[1. - cosangle < 2.220446049250313*^-16, cosangle = 1.]; sinangle = 1 - cosangle^2; If[sinangle < 2.220446049250313*^-16, sinangle = 0., sinangle = Sqrt[sinangle]]; axismatrix + ({{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}} - axismatrix)*cosangle + crossmatrix*sinangle, {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = If[Sign[{1., 0., 0.} . {r1, r2, r3}] === 1, {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}, {{-1., 0., 0.}, {0., -1., 0.}, {0., 0., 1.}}]]) & , allcreatedrays]; allcreatedrays = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = Function[mm, (mm . #1 & ) /@ {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}][transmatrix[[First[#2]]]]; tiltmagnitude = {r1, r2, r3} . {r1, r2, r3}; If[Abs[tiltmagnitude - 1.] > 1.*^-6, dummyvector = {r1, r2, r3}/Sqrt[tiltmagnitude]; {r1, r2, r3} = dummyvector; dummymatrix = (#1/Sqrt[#1 . #1] & ) /@ {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}}; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = dummymatrix; 1., 1.]; If[allcreatedamplitudes != {{I*0., I*0., I*0.}}, amplitude = allcreatedamplitudes[[First[#2]]]; hor = {r4, r5, r6} . amplitude; ver = {r7, r8, r9} . amplitude; If[Abs[hor] > 0. || Abs[ver] > 0., {pol1, pol2, pol3} = {Abs[hor], Abs[ver], 0.}; dummyvector = {pol1, pol2, pol3}/Sqrt[{pol1, pol2, pol3} . {pol1, pol2, pol3}]; {pol1, pol2, pol3} = dummyvector; dummyvector = ReplacePart[{pol1, pol2, pol3}, (If[ver == 0., 0., Arg[ver]] - If[hor == 0., 0., Arg[hor]])/Degree, 3]; {pol1, pol2, pol3} = dummyvector]; 1., 1.]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}) & , allcreatedrays]); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 6, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ4]] + r2*Re[Sin[0.017453292519943295*θ4]]; yunit = r2*Re[Cos[0.017453292519943295*θ4]] - 1.*r1*Re[Sin[0.017453292519943295*θ4]]; zunit = r3*Re[Cos[0.017453292519943295*θ4]^2 + Sin[0.017453292519943295*θ4]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = Re[Cos[0.017453292519943295*θ4]]*(rex - 1.*Re[x4 + PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4]]) + Re[Sin[0.017453292519943295*θ4]]*(rey - 1.*Re[y4 + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]]); ry = -1.*(rex - 1.*Re[x4 + PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4]])*Re[Sin[0.017453292519943295*θ4]] + Re[Cos[0.017453292519943295*θ4]]*(rey - 1.*Re[y4 + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]]); rz = rez*Re[Cos[0.017453292519943295*θ4]^2 + Sin[0.017453292519943295*θ4]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {1., 6., 5424.}; {componentnumber, surfacenumber, surfaceid} = {1., 6., 5424.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = rxhlp*Re[Cos[0.017453292519943295*θ4]] + Re[x4 + PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4]] - 1.*ryhlp*Re[Sin[0.017453292519943295*θ4]]; rey = ryhlp*Re[Cos[0.017453292519943295*θ4]] + rxhlp*Re[Sin[0.017453292519943295*θ4]] + Re[y4 + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]]; rez = rzhlp*Re[Cos[0.017453292519943295*θ4]^2 + Sin[0.017453292519943295*θ4]^2]; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}]; dummymatrix = ({{Re[Cos[0.017453292519943295*θ4]], -1.*Re[Sin[0.017453292519943295*θ4]], 0.}, {Re[Sin[0.017453292519943295*θ4]], Re[Cos[0.017453292519943295*θ4]], 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{Re[Cos[0.017453292519943295*θ4]], Re[Sin[0.017453292519943295*θ4]], 0.}, {-1.*Re[Sin[0.017453292519943295*θ4]], Re[Cos[0.017453292519943295*θ4]], 0.}, {0., 0., 1.}}; surfacetranslationvector = {Re[x4 + PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4]], Re[y4 + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]], 0.}; activeregion = -1.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; ZAxis = First[surfnorm]*Sign[First[surfnorm] . {r1, r2, r3}]; raytiltz = ZAxis . {r1, r2, r3}; raytiltx = 1 - raytiltz^2; If[raytiltx < 2.220446049250313*^-16, raytiltx = 0., raytiltx = Sqrt[raytiltx]]; XAxis = {r1, r2, r3} - ZAxis*raytiltz; If[Abs[raytiltx] < 1.*^-7, XAxis = surfnorm[[2]], XAxis = XAxis/raytiltx]; YAxis = {-(ZAxis[[3]]*XAxis[[2]]) + ZAxis[[2]]*XAxis[[3]], ZAxis[[3]]*XAxis[[1]] - ZAxis[[1]]*XAxis[[3]], -(ZAxis[[2]]*XAxis[[1]]) + ZAxis[[1]]*XAxis[[2]]}; YAxis = YAxis/Sqrt[YAxis . YAxis]; PAxis = ZAxis*{r1, r2, r3} . XAxis - XAxis*{r1, r2, r3} . ZAxis; PAxis = PAxis/Sqrt[PAxis . PAxis]; normalizedpolarization = {pol1, pol2, pol3}[[{1, 2}]]; normalizedpolarization = normalizedpolarization/Sqrt[normalizedpolarization . normalizedpolarization]; allcreatedamplitudes = {{I*0., I*0., I*0.}}; amplitude = Sqrt[intensity]*(normalizedpolarization[[1]]*{r4, r5, r6} + normalizedpolarization[[2]]*{r7, r8, r9}*Exp[I*pol3*0.017453292519943295]); perpendicularamplitude = amplitude . YAxis; parallelamplitude = amplitude . PAxis; If[activeregion*(surfacerotationmatrix . {r1, r2, r3})[[1]] > 0, index2 = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]], index2 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]]]; n12 = index1/index2; index = index2; If[1 - n12^2*raytiltx^2 >= 0., dummyvector = n12*{r1, r2, r3} + ZAxis*(-(n12*raytiltz) + Sqrt[1 - n12^2*raytiltx^2]); {r1, r2, r3} = dummyvector; 1., If[{r1, r2, r3} . surfnorm[[1]] > 0, phaseshift = phaseshift + 0.5, 1.]; index2 = index1; index = index1; dummyvector = {r1, r2, r3} - 2*ZAxis*ZAxis . {r1, r2, r3}; {r1, r2, r3} = dummyvector; dummyvector = {pol1, pol2, pol3} + {0, 0, -180}; {pol1, pol2, pol3} = dummyvector; 1.]; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; originalrotation = Partition[Take[originalray, {7, 15}], 3]; previoustilt = originalrotation[[1]]; transmatrix = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; rotationaxis = Cross[{1., 0., 0.}, {r1, r2, r3}]; axismagnitude = Sqrt[rotationaxis . rotationaxis]; If[Chop[axismagnitude] != 0., rotationaxis = rotationaxis/axismagnitude; axismatrix = (#1*rotationaxis & ) /@ rotationaxis; crossmatrix = {{0., -rotationaxis[[3]], rotationaxis[[2]]}, {rotationaxis[[3]], 0., -rotationaxis[[1]]}, {-rotationaxis[[2]], rotationaxis[[1]], 0.}}; cosangle = {1., 0., 0.} . {r1, r2, r3}; If[1. - cosangle < 2.220446049250313*^-16, cosangle = 1.]; sinangle = 1 - cosangle^2; If[sinangle < 2.220446049250313*^-16, sinangle = 0., sinangle = Sqrt[sinangle]]; axismatrix + ({{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}} - axismatrix)*cosangle + crossmatrix*sinangle, {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = If[Sign[{1., 0., 0.} . {r1, r2, r3}] === 1, {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}, {{-1., 0., 0.}, {0., -1., 0.}, {0., 0., 1.}}]]) & , allcreatedrays]; allcreatedrays = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = Function[mm, (mm . #1 & ) /@ {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}][transmatrix[[First[#2]]]]; tiltmagnitude = {r1, r2, r3} . {r1, r2, r3}; If[Abs[tiltmagnitude - 1.] > 1.*^-6, dummyvector = {r1, r2, r3}/Sqrt[tiltmagnitude]; {r1, r2, r3} = dummyvector; dummymatrix = (#1/Sqrt[#1 . #1] & ) /@ {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}}; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = dummymatrix; 1., 1.]; If[allcreatedamplitudes != {{I*0., I*0., I*0.}}, amplitude = allcreatedamplitudes[[First[#2]]]; hor = {r4, r5, r6} . amplitude; ver = {r7, r8, r9} . amplitude; If[Abs[hor] > 0. || Abs[ver] > 0., {pol1, pol2, pol3} = {Abs[hor], Abs[ver], 0.}; dummyvector = {pol1, pol2, pol3}/Sqrt[{pol1, pol2, pol3} . {pol1, pol2, pol3}]; {pol1, pol2, pol3} = dummyvector; dummyvector = ReplacePart[{pol1, pol2, pol3}, (If[ver == 0., 0., Arg[ver]] - If[hor == 0., 0., Arg[hor]])/Degree, 3]; {pol1, pol2, pol3} = dummyvector]; 1., 1.]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}) & , allcreatedrays]); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 7, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ5]] + r2*Re[Sin[0.017453292519943295*θ5]]; yunit = r2*Re[Cos[0.017453292519943295*θ5]] - 1.*r1*Re[Sin[0.017453292519943295*θ5]]; zunit = r3*Re[Cos[0.017453292519943295*θ5]^2 + Sin[0.017453292519943295*θ5]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = (rex - 1.*Re[x5])*Re[Cos[0.017453292519943295*θ5]] + (rey - 1.*Re[y5])*Re[Sin[0.017453292519943295*θ5]]; ry = (rey - 1.*Re[y5])*Re[Cos[0.017453292519943295*θ5]] - 1.*(rex - 1.*Re[x5])*Re[Sin[0.017453292519943295*θ5]]; rz = rez*Re[Cos[0.017453292519943295*θ5]^2 + Sin[0.017453292519943295*θ5]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {1., 7., 5488.}; {componentnumber, surfacenumber, surfaceid} = {1., 7., 5488.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = Re[x5] + rxhlp*Re[Cos[0.017453292519943295*θ5]] - 1.*ryhlp*Re[Sin[0.017453292519943295*θ5]]; rey = Re[y5] + ryhlp*Re[Cos[0.017453292519943295*θ5]] + rxhlp*Re[Sin[0.017453292519943295*θ5]]; rez = rzhlp*Re[Cos[0.017453292519943295*θ5]^2 + Sin[0.017453292519943295*θ5]^2]; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}]; dummymatrix = ({{Re[Cos[0.017453292519943295*θ5]], -1.*Re[Sin[0.017453292519943295*θ5]], 0.}, {Re[Sin[0.017453292519943295*θ5]], Re[Cos[0.017453292519943295*θ5]], 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{Re[Cos[0.017453292519943295*θ5]], Re[Sin[0.017453292519943295*θ5]], 0.}, {-1.*Re[Sin[0.017453292519943295*θ5]], Re[Cos[0.017453292519943295*θ5]], 0.}, {0., 0., 1.}}; surfacetranslationvector = {Re[x5], Re[y5], 0.}; activeregion = 1.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; ZAxis = First[surfnorm]*Sign[First[surfnorm] . {r1, r2, r3}]; raytiltz = ZAxis . {r1, r2, r3}; raytiltx = 1 - raytiltz^2; If[raytiltx < 2.220446049250313*^-16, raytiltx = 0., raytiltx = Sqrt[raytiltx]]; XAxis = {r1, r2, r3} - ZAxis*raytiltz; If[Abs[raytiltx] < 1.*^-7, XAxis = surfnorm[[2]], XAxis = XAxis/raytiltx]; YAxis = {-(ZAxis[[3]]*XAxis[[2]]) + ZAxis[[2]]*XAxis[[3]], ZAxis[[3]]*XAxis[[1]] - ZAxis[[1]]*XAxis[[3]], -(ZAxis[[2]]*XAxis[[1]]) + ZAxis[[1]]*XAxis[[2]]}; YAxis = YAxis/Sqrt[YAxis . YAxis]; PAxis = ZAxis*{r1, r2, r3} . XAxis - XAxis*{r1, r2, r3} . ZAxis; PAxis = PAxis/Sqrt[PAxis . PAxis]; normalizedpolarization = {pol1, pol2, pol3}[[{1, 2}]]; normalizedpolarization = normalizedpolarization/Sqrt[normalizedpolarization . normalizedpolarization]; allcreatedamplitudes = {{I*0., I*0., I*0.}}; amplitude = Sqrt[intensity]*(normalizedpolarization[[1]]*{r4, r5, r6} + normalizedpolarization[[2]]*{r7, r8, r9}*Exp[I*pol3*0.017453292519943295]); perpendicularamplitude = amplitude . YAxis; parallelamplitude = amplitude . PAxis; If[{r1, r2, r3} . surfnorm[[1]] > 0, phaseshift = phaseshift + 0.5, 1.]; dummyvector = {r1, r2, r3} - 2*ZAxis*ZAxis . {r1, r2, r3}; {r1, r2, r3} = dummyvector; dummyvector = {pol1, pol2, pol3} + {0, 0, -180}; {pol1, pol2, pol3} = dummyvector; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; originalrotation = Partition[Take[originalray, {7, 15}], 3]; previoustilt = originalrotation[[1]]; transmatrix = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; rotationaxis = Cross[{1., 0., 0.}, {r1, r2, r3}]; axismagnitude = Sqrt[rotationaxis . rotationaxis]; If[Chop[axismagnitude] != 0., rotationaxis = rotationaxis/axismagnitude; axismatrix = (#1*rotationaxis & ) /@ rotationaxis; crossmatrix = {{0., -rotationaxis[[3]], rotationaxis[[2]]}, {rotationaxis[[3]], 0., -rotationaxis[[1]]}, {-rotationaxis[[2]], rotationaxis[[1]], 0.}}; cosangle = {1., 0., 0.} . {r1, r2, r3}; If[1. - cosangle < 2.220446049250313*^-16, cosangle = 1.]; sinangle = 1 - cosangle^2; If[sinangle < 2.220446049250313*^-16, sinangle = 0., sinangle = Sqrt[sinangle]]; axismatrix + ({{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}} - axismatrix)*cosangle + crossmatrix*sinangle, {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = If[Sign[{1., 0., 0.} . {r1, r2, r3}] === 1, {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}, {{-1., 0., 0.}, {0., -1., 0.}, {0., 0., 1.}}]]) & , allcreatedrays]; allcreatedrays = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = Function[mm, (mm . #1 & ) /@ {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}][transmatrix[[First[#2]]]]; tiltmagnitude = {r1, r2, r3} . {r1, r2, r3}; If[Abs[tiltmagnitude - 1.] > 1.*^-6, dummyvector = {r1, r2, r3}/Sqrt[tiltmagnitude]; {r1, r2, r3} = dummyvector; dummymatrix = (#1/Sqrt[#1 . #1] & ) /@ {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}}; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = dummymatrix; 1., 1.]; If[allcreatedamplitudes != {{I*0., I*0., I*0.}}, amplitude = allcreatedamplitudes[[First[#2]]]; hor = {r4, r5, r6} . amplitude; ver = {r7, r8, r9} . amplitude; If[Abs[hor] > 0. || Abs[ver] > 0., {pol1, pol2, pol3} = {Abs[hor], Abs[ver], 0.}; dummyvector = {pol1, pol2, pol3}/Sqrt[{pol1, pol2, pol3} . {pol1, pol2, pol3}]; {pol1, pol2, pol3} = dummyvector; dummyvector = ReplacePart[{pol1, pol2, pol3}, (If[ver == 0., 0., Arg[ver]] - If[hor == 0., 0., Arg[hor]])/Degree, 3]; {pol1, pol2, pol3} = dummyvector]; 1., 1.]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}) & , allcreatedrays]); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 8, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ5]] + r2*Re[Sin[0.017453292519943295*θ5]]; yunit = r2*Re[Cos[0.017453292519943295*θ5]] - 1.*r1*Re[Sin[0.017453292519943295*θ5]]; zunit = r3*Re[Cos[0.017453292519943295*θ5]^2 + Sin[0.017453292519943295*θ5]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = Re[Cos[0.017453292519943295*θ5]]*(rex - 1.*Re[x5 + 5.*Cos[0.017453292519943295*θ5]]) + Re[Sin[0.017453292519943295*θ5]]*(rey - 1.*Re[y5 + 5.*Sin[0.017453292519943295*θ5]]); ry = -1.*(rex - 1.*Re[x5 + 5.*Cos[0.017453292519943295*θ5]])*Re[Sin[0.017453292519943295*θ5]] + Re[Cos[0.017453292519943295*θ5]]*(rey - 1.*Re[y5 + 5.*Sin[0.017453292519943295*θ5]]); rz = rez*Re[Cos[0.017453292519943295*θ5]^2 + Sin[0.017453292519943295*θ5]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {1., 8., 5489.}; {componentnumber, surfacenumber, surfaceid} = {1., 8., 5489.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = rxhlp*Re[Cos[0.017453292519943295*θ5]] + Re[x5 + 5.*Cos[0.017453292519943295*θ5]] - 1.*ryhlp*Re[Sin[0.017453292519943295*θ5]]; rey = ryhlp*Re[Cos[0.017453292519943295*θ5]] + rxhlp*Re[Sin[0.017453292519943295*θ5]] + Re[y5 + 5.*Sin[0.017453292519943295*θ5]]; rez = rzhlp*Re[Cos[0.017453292519943295*θ5]^2 + Sin[0.017453292519943295*θ5]^2]; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}]; dummymatrix = ({{Re[Cos[0.017453292519943295*θ5]], -1.*Re[Sin[0.017453292519943295*θ5]], 0.}, {Re[Sin[0.017453292519943295*θ5]], Re[Cos[0.017453292519943295*θ5]], 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{Re[Cos[0.017453292519943295*θ5]], Re[Sin[0.017453292519943295*θ5]], 0.}, {-1.*Re[Sin[0.017453292519943295*θ5]], Re[Cos[0.017453292519943295*θ5]], 0.}, {0., 0., 1.}}; surfacetranslationvector = {Re[x5 + 5.*Cos[0.017453292519943295*θ5]], Re[y5 + 5.*Sin[0.017453292519943295*θ5]], 0.}; activeregion = -1.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; ZAxis = First[surfnorm]*Sign[First[surfnorm] . {r1, r2, r3}]; raytiltz = ZAxis . {r1, r2, r3}; raytiltx = 1 - raytiltz^2; If[raytiltx < 2.220446049250313*^-16, raytiltx = 0., raytiltx = Sqrt[raytiltx]]; XAxis = {r1, r2, r3} - ZAxis*raytiltz; If[Abs[raytiltx] < 1.*^-7, XAxis = surfnorm[[2]], XAxis = XAxis/raytiltx]; YAxis = {-(ZAxis[[3]]*XAxis[[2]]) + ZAxis[[2]]*XAxis[[3]], ZAxis[[3]]*XAxis[[1]] - ZAxis[[1]]*XAxis[[3]], -(ZAxis[[2]]*XAxis[[1]]) + ZAxis[[1]]*XAxis[[2]]}; YAxis = YAxis/Sqrt[YAxis . YAxis]; PAxis = ZAxis*{r1, r2, r3} . XAxis - XAxis*{r1, r2, r3} . ZAxis; PAxis = PAxis/Sqrt[PAxis . PAxis]; normalizedpolarization = {pol1, pol2, pol3}[[{1, 2}]]; normalizedpolarization = normalizedpolarization/Sqrt[normalizedpolarization . normalizedpolarization]; allcreatedamplitudes = {{I*0., I*0., I*0.}}; amplitude = Sqrt[intensity]*(normalizedpolarization[[1]]*{r4, r5, r6} + normalizedpolarization[[2]]*{r7, r8, r9}*Exp[I*pol3*0.017453292519943295]); perpendicularamplitude = amplitude . YAxis; parallelamplitude = amplitude . PAxis; If[activeregion*(surfacerotationmatrix . {r1, r2, r3})[[1]] > 0, index2 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]], index2 = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]]]; n12 = index1/index2; index = index2; If[1 - n12^2*raytiltx^2 >= 0., dummyvector = n12*{r1, r2, r3} + ZAxis*(-(n12*raytiltz) + Sqrt[1 - n12^2*raytiltx^2]); {r1, r2, r3} = dummyvector; 1., If[{r1, r2, r3} . surfnorm[[1]] > 0, phaseshift = phaseshift + 0.5, 1.]; index2 = index1; index = index1; dummyvector = {r1, r2, r3} - 2*ZAxis*ZAxis . {r1, r2, r3}; {r1, r2, r3} = dummyvector; dummyvector = {pol1, pol2, pol3} + {0, 0, -180}; {pol1, pol2, pol3} = dummyvector; 1.]; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; originalrotation = Partition[Take[originalray, {7, 15}], 3]; previoustilt = originalrotation[[1]]; transmatrix = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; rotationaxis = Cross[{1., 0., 0.}, {r1, r2, r3}]; axismagnitude = Sqrt[rotationaxis . rotationaxis]; If[Chop[axismagnitude] != 0., rotationaxis = rotationaxis/axismagnitude; axismatrix = (#1*rotationaxis & ) /@ rotationaxis; crossmatrix = {{0., -rotationaxis[[3]], rotationaxis[[2]]}, {rotationaxis[[3]], 0., -rotationaxis[[1]]}, {-rotationaxis[[2]], rotationaxis[[1]], 0.}}; cosangle = {1., 0., 0.} . {r1, r2, r3}; If[1. - cosangle < 2.220446049250313*^-16, cosangle = 1.]; sinangle = 1 - cosangle^2; If[sinangle < 2.220446049250313*^-16, sinangle = 0., sinangle = Sqrt[sinangle]]; axismatrix + ({{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}} - axismatrix)*cosangle + crossmatrix*sinangle, {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = If[Sign[{1., 0., 0.} . {r1, r2, r3}] === 1, {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}, {{-1., 0., 0.}, {0., -1., 0.}, {0., 0., 1.}}]]) & , allcreatedrays]; allcreatedrays = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = Function[mm, (mm . #1 & ) /@ {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}][transmatrix[[First[#2]]]]; tiltmagnitude = {r1, r2, r3} . {r1, r2, r3}; If[Abs[tiltmagnitude - 1.] > 1.*^-6, dummyvector = {r1, r2, r3}/Sqrt[tiltmagnitude]; {r1, r2, r3} = dummyvector; dummymatrix = (#1/Sqrt[#1 . #1] & ) /@ {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}}; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = dummymatrix; 1., 1.]; If[allcreatedamplitudes != {{I*0., I*0., I*0.}}, amplitude = allcreatedamplitudes[[First[#2]]]; hor = {r4, r5, r6} . amplitude; ver = {r7, r8, r9} . amplitude; If[Abs[hor] > 0. || Abs[ver] > 0., {pol1, pol2, pol3} = {Abs[hor], Abs[ver], 0.}; dummyvector = {pol1, pol2, pol3}/Sqrt[{pol1, pol2, pol3} . {pol1, pol2, pol3}]; {pol1, pol2, pol3} = dummyvector; dummyvector = ReplacePart[{pol1, pol2, pol3}, (If[ver == 0., 0., Arg[ver]] - If[hor == 0., 0., Arg[hor]])/Degree, 3]; {pol1, pol2, pol3} = dummyvector]; 1., 1.]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}) & , allcreatedrays]); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 9, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ6]] + r2*Re[Sin[0.017453292519943295*θ6]]; yunit = r2*Re[Cos[0.017453292519943295*θ6]] - 1.*r1*Re[Sin[0.017453292519943295*θ6]]; zunit = r3*Re[Cos[0.017453292519943295*θ6]^2 + Sin[0.017453292519943295*θ6]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = (rex - 1.*Re[x6])*Re[Cos[0.017453292519943295*θ6]] + (rey - 1.*Re[y6])*Re[Sin[0.017453292519943295*θ6]]; ry = (rey - 1.*Re[y6])*Re[Cos[0.017453292519943295*θ6]] - 1.*(rex - 1.*Re[x6])*Re[Sin[0.017453292519943295*θ6]]; rz = rez*Re[Cos[0.017453292519943295*θ6]^2 + Sin[0.017453292519943295*θ6]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {1., 9., 5553.}; {componentnumber, surfacenumber, surfaceid} = {1., 9., 5553.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = Re[x6] + rxhlp*Re[Cos[0.017453292519943295*θ6]] - 1.*ryhlp*Re[Sin[0.017453292519943295*θ6]]; rey = Re[y6] + ryhlp*Re[Cos[0.017453292519943295*θ6]] + rxhlp*Re[Sin[0.017453292519943295*θ6]]; rez = rzhlp*Re[Cos[0.017453292519943295*θ6]^2 + Sin[0.017453292519943295*θ6]^2]; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}]; dummymatrix = ({{Re[Cos[0.017453292519943295*θ6]], -1.*Re[Sin[0.017453292519943295*θ6]], 0.}, {Re[Sin[0.017453292519943295*θ6]], Re[Cos[0.017453292519943295*θ6]], 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{Re[Cos[0.017453292519943295*θ6]], Re[Sin[0.017453292519943295*θ6]], 0.}, {-1.*Re[Sin[0.017453292519943295*θ6]], Re[Cos[0.017453292519943295*θ6]], 0.}, {0., 0., 1.}}; surfacetranslationvector = {Re[x6], Re[y6], 0.}; activeregion = 1.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; ZAxis = First[surfnorm]*Sign[First[surfnorm] . {r1, r2, r3}]; raytiltz = ZAxis . {r1, r2, r3}; raytiltx = 1 - raytiltz^2; If[raytiltx < 2.220446049250313*^-16, raytiltx = 0., raytiltx = Sqrt[raytiltx]]; XAxis = {r1, r2, r3} - ZAxis*raytiltz; If[Abs[raytiltx] < 1.*^-7, XAxis = surfnorm[[2]], XAxis = XAxis/raytiltx]; YAxis = {-(ZAxis[[3]]*XAxis[[2]]) + ZAxis[[2]]*XAxis[[3]], ZAxis[[3]]*XAxis[[1]] - ZAxis[[1]]*XAxis[[3]], -(ZAxis[[2]]*XAxis[[1]]) + ZAxis[[1]]*XAxis[[2]]}; YAxis = YAxis/Sqrt[YAxis . YAxis]; PAxis = ZAxis*{r1, r2, r3} . XAxis - XAxis*{r1, r2, r3} . ZAxis; PAxis = PAxis/Sqrt[PAxis . PAxis]; normalizedpolarization = {pol1, pol2, pol3}[[{1, 2}]]; normalizedpolarization = normalizedpolarization/Sqrt[normalizedpolarization . normalizedpolarization]; allcreatedamplitudes = {{I*0., I*0., I*0.}}; amplitude = Sqrt[intensity]*(normalizedpolarization[[1]]*{r4, r5, r6} + normalizedpolarization[[2]]*{r7, r8, r9}*Exp[I*pol3*0.017453292519943295]); perpendicularamplitude = amplitude . YAxis; parallelamplitude = amplitude . PAxis; If[{r1, r2, r3} . surfnorm[[1]] > 0, phaseshift = phaseshift + 0.5, 1.]; dummyvector = {r1, r2, r3} - 2*ZAxis*ZAxis . {r1, r2, r3}; {r1, r2, r3} = dummyvector; dummyvector = {pol1, pol2, pol3} + {0, 0, -180}; {pol1, pol2, pol3} = dummyvector; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; originalrotation = Partition[Take[originalray, {7, 15}], 3]; previoustilt = originalrotation[[1]]; transmatrix = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; rotationaxis = Cross[{1., 0., 0.}, {r1, r2, r3}]; axismagnitude = Sqrt[rotationaxis . rotationaxis]; If[Chop[axismagnitude] != 0., rotationaxis = rotationaxis/axismagnitude; axismatrix = (#1*rotationaxis & ) /@ rotationaxis; crossmatrix = {{0., -rotationaxis[[3]], rotationaxis[[2]]}, {rotationaxis[[3]], 0., -rotationaxis[[1]]}, {-rotationaxis[[2]], rotationaxis[[1]], 0.}}; cosangle = {1., 0., 0.} . {r1, r2, r3}; If[1. - cosangle < 2.220446049250313*^-16, cosangle = 1.]; sinangle = 1 - cosangle^2; If[sinangle < 2.220446049250313*^-16, sinangle = 0., sinangle = Sqrt[sinangle]]; axismatrix + ({{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}} - axismatrix)*cosangle + crossmatrix*sinangle, {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = If[Sign[{1., 0., 0.} . {r1, r2, r3}] === 1, {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}, {{-1., 0., 0.}, {0., -1., 0.}, {0., 0., 1.}}]]) & , allcreatedrays]; allcreatedrays = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = Function[mm, (mm . #1 & ) /@ {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}][transmatrix[[First[#2]]]]; tiltmagnitude = {r1, r2, r3} . {r1, r2, r3}; If[Abs[tiltmagnitude - 1.] > 1.*^-6, dummyvector = {r1, r2, r3}/Sqrt[tiltmagnitude]; {r1, r2, r3} = dummyvector; dummymatrix = (#1/Sqrt[#1 . #1] & ) /@ {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}}; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = dummymatrix; 1., 1.]; If[allcreatedamplitudes != {{I*0., I*0., I*0.}}, amplitude = allcreatedamplitudes[[First[#2]]]; hor = {r4, r5, r6} . amplitude; ver = {r7, r8, r9} . amplitude; If[Abs[hor] > 0. || Abs[ver] > 0., {pol1, pol2, pol3} = {Abs[hor], Abs[ver], 0.}; dummyvector = {pol1, pol2, pol3}/Sqrt[{pol1, pol2, pol3} . {pol1, pol2, pol3}]; {pol1, pol2, pol3} = dummyvector; dummyvector = ReplacePart[{pol1, pol2, pol3}, (If[ver == 0., 0., Arg[ver]] - If[hor == 0., 0., Arg[hor]])/Degree, 3]; {pol1, pol2, pol3} = dummyvector]; 1., 1.]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}) & , allcreatedrays]); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 10, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ6]] + r2*Re[Sin[0.017453292519943295*θ6]]; yunit = r2*Re[Cos[0.017453292519943295*θ6]] - 1.*r1*Re[Sin[0.017453292519943295*θ6]]; zunit = r3*Re[Cos[0.017453292519943295*θ6]^2 + Sin[0.017453292519943295*θ6]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = Re[Cos[0.017453292519943295*θ6]]*(rex - 1.*Re[x6 + 5.*Cos[0.017453292519943295*θ6]]) + Re[Sin[0.017453292519943295*θ6]]*(rey - 1.*Re[y6 + 5.*Sin[0.017453292519943295*θ6]]); ry = -1.*(rex - 1.*Re[x6 + 5.*Cos[0.017453292519943295*θ6]])*Re[Sin[0.017453292519943295*θ6]] + Re[Cos[0.017453292519943295*θ6]]*(rey - 1.*Re[y6 + 5.*Sin[0.017453292519943295*θ6]]); rz = rez*Re[Cos[0.017453292519943295*θ6]^2 + Sin[0.017453292519943295*θ6]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {1., 10., 5554.}; {componentnumber, surfacenumber, surfaceid} = {1., 10., 5554.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = rxhlp*Re[Cos[0.017453292519943295*θ6]] + Re[x6 + 5.*Cos[0.017453292519943295*θ6]] - 1.*ryhlp*Re[Sin[0.017453292519943295*θ6]]; rey = ryhlp*Re[Cos[0.017453292519943295*θ6]] + rxhlp*Re[Sin[0.017453292519943295*θ6]] + Re[y6 + 5.*Sin[0.017453292519943295*θ6]]; rez = rzhlp*Re[Cos[0.017453292519943295*θ6]^2 + Sin[0.017453292519943295*θ6]^2]; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}]; dummymatrix = ({{Re[Cos[0.017453292519943295*θ6]], -1.*Re[Sin[0.017453292519943295*θ6]], 0.}, {Re[Sin[0.017453292519943295*θ6]], Re[Cos[0.017453292519943295*θ6]], 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{Re[Cos[0.017453292519943295*θ6]], Re[Sin[0.017453292519943295*θ6]], 0.}, {-1.*Re[Sin[0.017453292519943295*θ6]], Re[Cos[0.017453292519943295*θ6]], 0.}, {0., 0., 1.}}; surfacetranslationvector = {Re[x6 + 5.*Cos[0.017453292519943295*θ6]], Re[y6 + 5.*Sin[0.017453292519943295*θ6]], 0.}; activeregion = -1.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; ZAxis = First[surfnorm]*Sign[First[surfnorm] . {r1, r2, r3}]; raytiltz = ZAxis . {r1, r2, r3}; raytiltx = 1 - raytiltz^2; If[raytiltx < 2.220446049250313*^-16, raytiltx = 0., raytiltx = Sqrt[raytiltx]]; XAxis = {r1, r2, r3} - ZAxis*raytiltz; If[Abs[raytiltx] < 1.*^-7, XAxis = surfnorm[[2]], XAxis = XAxis/raytiltx]; YAxis = {-(ZAxis[[3]]*XAxis[[2]]) + ZAxis[[2]]*XAxis[[3]], ZAxis[[3]]*XAxis[[1]] - ZAxis[[1]]*XAxis[[3]], -(ZAxis[[2]]*XAxis[[1]]) + ZAxis[[1]]*XAxis[[2]]}; YAxis = YAxis/Sqrt[YAxis . YAxis]; PAxis = ZAxis*{r1, r2, r3} . XAxis - XAxis*{r1, r2, r3} . ZAxis; PAxis = PAxis/Sqrt[PAxis . PAxis]; normalizedpolarization = {pol1, pol2, pol3}[[{1, 2}]]; normalizedpolarization = normalizedpolarization/Sqrt[normalizedpolarization . normalizedpolarization]; allcreatedamplitudes = {{I*0., I*0., I*0.}}; amplitude = Sqrt[intensity]*(normalizedpolarization[[1]]*{r4, r5, r6} + normalizedpolarization[[2]]*{r7, r8, r9}*Exp[I*pol3*0.017453292519943295]); perpendicularamplitude = amplitude . YAxis; parallelamplitude = amplitude . PAxis; If[activeregion*(surfacerotationmatrix . {r1, r2, r3})[[1]] > 0, index2 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]], index2 = Sqrt[2.2718929 - 0.010108077*wavelength^2 + 0.010592509/wavelength^2 + 0.00020816965/wavelength^4 - 7.6472538*^-6/wavelength^6 + 4.9240991*^-7/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]]]; n12 = index1/index2; index = index2; If[1 - n12^2*raytiltx^2 >= 0., dummyvector = n12*{r1, r2, r3} + ZAxis*(-(n12*raytiltz) + Sqrt[1 - n12^2*raytiltx^2]); {r1, r2, r3} = dummyvector; 1., If[{r1, r2, r3} . surfnorm[[1]] > 0, phaseshift = phaseshift + 0.5, 1.]; index2 = index1; index = index1; dummyvector = {r1, r2, r3} - 2*ZAxis*ZAxis . {r1, r2, r3}; {r1, r2, r3} = dummyvector; dummyvector = {pol1, pol2, pol3} + {0, 0, -180}; {pol1, pol2, pol3} = dummyvector; 1.]; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; originalrotation = Partition[Take[originalray, {7, 15}], 3]; previoustilt = originalrotation[[1]]; transmatrix = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; rotationaxis = Cross[{1., 0., 0.}, {r1, r2, r3}]; axismagnitude = Sqrt[rotationaxis . rotationaxis]; If[Chop[axismagnitude] != 0., rotationaxis = rotationaxis/axismagnitude; axismatrix = (#1*rotationaxis & ) /@ rotationaxis; crossmatrix = {{0., -rotationaxis[[3]], rotationaxis[[2]]}, {rotationaxis[[3]], 0., -rotationaxis[[1]]}, {-rotationaxis[[2]], rotationaxis[[1]], 0.}}; cosangle = {1., 0., 0.} . {r1, r2, r3}; If[1. - cosangle < 2.220446049250313*^-16, cosangle = 1.]; sinangle = 1 - cosangle^2; If[sinangle < 2.220446049250313*^-16, sinangle = 0., sinangle = Sqrt[sinangle]]; axismatrix + ({{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}} - axismatrix)*cosangle + crossmatrix*sinangle, {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = If[Sign[{1., 0., 0.} . {r1, r2, r3}] === 1, {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}, {{-1., 0., 0.}, {0., -1., 0.}, {0., 0., 1.}}]]) & , allcreatedrays]; allcreatedrays = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = Function[mm, (mm . #1 & ) /@ {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}][transmatrix[[First[#2]]]]; tiltmagnitude = {r1, r2, r3} . {r1, r2, r3}; If[Abs[tiltmagnitude - 1.] > 1.*^-6, dummyvector = {r1, r2, r3}/Sqrt[tiltmagnitude]; {r1, r2, r3} = dummyvector; dummymatrix = (#1/Sqrt[#1 . #1] & ) /@ {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}}; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = dummymatrix; 1., 1.]; If[allcreatedamplitudes != {{I*0., I*0., I*0.}}, amplitude = allcreatedamplitudes[[First[#2]]]; hor = {r4, r5, r6} . amplitude; ver = {r7, r8, r9} . amplitude; If[Abs[hor] > 0. || Abs[ver] > 0., {pol1, pol2, pol3} = {Abs[hor], Abs[ver], 0.}; dummyvector = {pol1, pol2, pol3}/Sqrt[{pol1, pol2, pol3} . {pol1, pol2, pol3}]; {pol1, pol2, pol3} = dummyvector; dummyvector = ReplacePart[{pol1, pol2, pol3}, (If[ver == 0., 0., Arg[ver]] - If[hor == 0., 0., Arg[hor]])/Degree, 3]; {pol1, pol2, pol3} = dummyvector]; 1., 1.]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}) & , allcreatedrays]); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 11, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ10]] + r2*Re[Sin[0.017453292519943295*θ10]]; yunit = r2*Re[Cos[0.017453292519943295*θ10]] - 1.*r1*Re[Sin[0.017453292519943295*θ10]]; zunit = r3*Re[Cos[0.017453292519943295*θ10]^2 + Sin[0.017453292519943295*θ10]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = (rex - 1.*Re[x10])*Re[Cos[0.017453292519943295*θ10]] + (rey - 1.*Re[y10])*Re[Sin[0.017453292519943295*θ10]]; ry = (rey - 1.*Re[y10])*Re[Cos[0.017453292519943295*θ10]] - 1.*(rex - 1.*Re[x10])*Re[Sin[0.017453292519943295*θ10]]; rz = rez*Re[Cos[0.017453292519943295*θ10]^2 + Sin[0.017453292519943295*θ10]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {1., 11., 5617.}; {componentnumber, surfacenumber, surfaceid} = {1., 11., 5617.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = Re[x10] + rxhlp*Re[Cos[0.017453292519943295*θ10]] - 1.*ryhlp*Re[Sin[0.017453292519943295*θ10]]; rey = Re[y10] + ryhlp*Re[Cos[0.017453292519943295*θ10]] + rxhlp*Re[Sin[0.017453292519943295*θ10]]; rez = rzhlp*Re[Cos[0.017453292519943295*θ10]^2 + Sin[0.017453292519943295*θ10]^2]; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., -(-(ray2/(8428.081563392561 - ray2^2 - ray3^2)^2^(-1))), -(-(ray3/(8428.081563392561 - ray2^2 - ray3^2)^2^(-1)))}, {-(ray2/(8428.081563392561 - ray2^2 - ray3^2)^2^(-1)), 1., 0.}, {-(ray3/(8428.081563392561 - ray2^2 - ray3^2)^2^(-1)), 0., 1.}}]; dummymatrix = ({{Re[Cos[0.017453292519943295*θ10]], -1.*Re[Sin[0.017453292519943295*θ10]], 0.}, {Re[Sin[0.017453292519943295*θ10]], Re[Cos[0.017453292519943295*θ10]], 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{Re[Cos[0.017453292519943295*θ10]], Re[Sin[0.017453292519943295*θ10]], 0.}, {-1.*Re[Sin[0.017453292519943295*θ10]], Re[Cos[0.017453292519943295*θ10]], 0.}, {0., 0., 1.}}; surfacetranslationvector = {Re[x10], Re[y10], 0.}; activeregion = 1.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; ZAxis = First[surfnorm]*Sign[First[surfnorm] . {r1, r2, r3}]; raytiltz = ZAxis . {r1, r2, r3}; raytiltx = 1 - raytiltz^2; If[raytiltx < 2.220446049250313*^-16, raytiltx = 0., raytiltx = Sqrt[raytiltx]]; XAxis = {r1, r2, r3} - ZAxis*raytiltz; If[Abs[raytiltx] < 1.*^-7, XAxis = surfnorm[[2]], XAxis = XAxis/raytiltx]; YAxis = {-(ZAxis[[3]]*XAxis[[2]]) + ZAxis[[2]]*XAxis[[3]], ZAxis[[3]]*XAxis[[1]] - ZAxis[[1]]*XAxis[[3]], -(ZAxis[[2]]*XAxis[[1]]) + ZAxis[[1]]*XAxis[[2]]}; YAxis = YAxis/Sqrt[YAxis . YAxis]; PAxis = ZAxis*{r1, r2, r3} . XAxis - XAxis*{r1, r2, r3} . ZAxis; PAxis = PAxis/Sqrt[PAxis . PAxis]; normalizedpolarization = {pol1, pol2, pol3}[[{1, 2}]]; normalizedpolarization = normalizedpolarization/Sqrt[normalizedpolarization . normalizedpolarization]; allcreatedamplitudes = {{I*0., I*0., I*0.}}; amplitude = Sqrt[intensity]*(normalizedpolarization[[1]]*{r4, r5, r6} + normalizedpolarization[[2]]*{r7, r8, r9}*Exp[I*pol3*0.017453292519943295]); perpendicularamplitude = amplitude . YAxis; parallelamplitude = amplitude . PAxis; If[activeregion*(surfacerotationmatrix . {r1, r2, r3})[[1]] > 0, index2 = Sqrt[2.104776438756983 - 0.0096874169418655*wavelength^2 + 0.0085190066553111/wavelength^2 + 0.0001250023747871254/wavelength^4 - 9.75184541025562*^-7/wavelength^6 + 6.099025456439798*^-8/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]], index2 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[2.104776438756983 - 0.0096874169418655*wavelength^2 + 0.0085190066553111/wavelength^2 + 0.0001250023747871254/wavelength^4 - 9.75184541025562*^-7/wavelength^6 + 6.099025456439798*^-8/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[2.104776438756983 - 0.0096874169418655*wavelength^2 + 0.0085190066553111/wavelength^2 + 0.0001250023747871254/wavelength^4 - 9.75184541025562*^-7/wavelength^6 + 6.099025456439798*^-8/wavelength^8]]]; n12 = index1/index2; index = index2; If[1 - n12^2*raytiltx^2 >= 0., dummyvector = n12*{r1, r2, r3} + ZAxis*(-(n12*raytiltz) + Sqrt[1 - n12^2*raytiltx^2]); {r1, r2, r3} = dummyvector; 1., If[{r1, r2, r3} . surfnorm[[1]] > 0, phaseshift = phaseshift + 0.5, 1.]; index2 = index1; index = index1; dummyvector = {r1, r2, r3} - 2*ZAxis*ZAxis . {r1, r2, r3}; {r1, r2, r3} = dummyvector; dummyvector = {pol1, pol2, pol3} + {0, 0, -180}; {pol1, pol2, pol3} = dummyvector; 1.]; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; originalrotation = Partition[Take[originalray, {7, 15}], 3]; previoustilt = originalrotation[[1]]; transmatrix = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; rotationaxis = Cross[{1., 0., 0.}, {r1, r2, r3}]; axismagnitude = Sqrt[rotationaxis . rotationaxis]; If[Chop[axismagnitude] != 0., rotationaxis = rotationaxis/axismagnitude; axismatrix = (#1*rotationaxis & ) /@ rotationaxis; crossmatrix = {{0., -rotationaxis[[3]], rotationaxis[[2]]}, {rotationaxis[[3]], 0., -rotationaxis[[1]]}, {-rotationaxis[[2]], rotationaxis[[1]], 0.}}; cosangle = {1., 0., 0.} . {r1, r2, r3}; If[1. - cosangle < 2.220446049250313*^-16, cosangle = 1.]; sinangle = 1 - cosangle^2; If[sinangle < 2.220446049250313*^-16, sinangle = 0., sinangle = Sqrt[sinangle]]; axismatrix + ({{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}} - axismatrix)*cosangle + crossmatrix*sinangle, {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = If[Sign[{1., 0., 0.} . {r1, r2, r3}] === 1, {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}, {{-1., 0., 0.}, {0., -1., 0.}, {0., 0., 1.}}]]) & , allcreatedrays]; allcreatedrays = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = Function[mm, (mm . #1 & ) /@ {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}][transmatrix[[First[#2]]]]; tiltmagnitude = {r1, r2, r3} . {r1, r2, r3}; If[Abs[tiltmagnitude - 1.] > 1.*^-6, dummyvector = {r1, r2, r3}/Sqrt[tiltmagnitude]; {r1, r2, r3} = dummyvector; dummymatrix = (#1/Sqrt[#1 . #1] & ) /@ {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}}; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = dummymatrix; 1., 1.]; If[allcreatedamplitudes != {{I*0., I*0., I*0.}}, amplitude = allcreatedamplitudes[[First[#2]]]; hor = {r4, r5, r6} . amplitude; ver = {r7, r8, r9} . amplitude; If[Abs[hor] > 0. || Abs[ver] > 0., {pol1, pol2, pol3} = {Abs[hor], Abs[ver], 0.}; dummyvector = {pol1, pol2, pol3}/Sqrt[{pol1, pol2, pol3} . {pol1, pol2, pol3}]; {pol1, pol2, pol3} = dummyvector; dummyvector = ReplacePart[{pol1, pol2, pol3}, (If[ver == 0., 0., Arg[ver]] - If[hor == 0., 0., Arg[hor]])/Degree, 3]; {pol1, pol2, pol3} = dummyvector]; 1., 1.]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}) & , allcreatedrays]); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 12, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1*Re[Cos[0.017453292519943295*θ10]] + r2*Re[Sin[0.017453292519943295*θ10]]; yunit = r2*Re[Cos[0.017453292519943295*θ10]] - 1.*r1*Re[Sin[0.017453292519943295*θ10]]; zunit = r3*Re[Cos[0.017453292519943295*θ10]^2 + Sin[0.017453292519943295*θ10]^2]; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = Re[Cos[0.017453292519943295*θ10]]*(rex - 1.*Re[x10 + 3.*Cos[0.017453292519943295*θ10]]) + Re[Sin[0.017453292519943295*θ10]]*(rey - 1.*Re[y10 + 3.*Sin[0.017453292519943295*θ10]]); ry = -1.*(rex - 1.*Re[x10 + 3.*Cos[0.017453292519943295*θ10]])*Re[Sin[0.017453292519943295*θ10]] + Re[Cos[0.017453292519943295*θ10]]*(rey - 1.*Re[y10 + 3.*Sin[0.017453292519943295*θ10]]); rz = rez*Re[Cos[0.017453292519943295*θ10]^2 + Sin[0.017453292519943295*θ10]^2]; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {1., 12., 5618.}; {componentnumber, surfacenumber, surfaceid} = {1., 12., 5618.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = rxhlp*Re[Cos[0.017453292519943295*θ10]] + Re[x10 + 3.*Cos[0.017453292519943295*θ10]] - 1.*ryhlp*Re[Sin[0.017453292519943295*θ10]]; rey = ryhlp*Re[Cos[0.017453292519943295*θ10]] + rxhlp*Re[Sin[0.017453292519943295*θ10]] + Re[y10 + 3.*Sin[0.017453292519943295*θ10]]; rez = rzhlp*Re[Cos[0.017453292519943295*θ10]^2 + Sin[0.017453292519943295*θ10]^2]; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., -(ray2/(8428.081563392561 - ray2^2 - ray3^2)^2^(-1)), -(ray3/(8428.081563392561 - ray2^2 - ray3^2)^2^(-1))}, {ray2/(8428.081563392561 - ray2^2 - ray3^2)^2^(-1), 1., 0.}, {ray3/(8428.081563392561 - ray2^2 - ray3^2)^2^(-1), 0., 1.}}]; dummymatrix = ({{Re[Cos[0.017453292519943295*θ10]], -1.*Re[Sin[0.017453292519943295*θ10]], 0.}, {Re[Sin[0.017453292519943295*θ10]], Re[Cos[0.017453292519943295*θ10]], 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{Re[Cos[0.017453292519943295*θ10]], Re[Sin[0.017453292519943295*θ10]], 0.}, {-1.*Re[Sin[0.017453292519943295*θ10]], Re[Cos[0.017453292519943295*θ10]], 0.}, {0., 0., 1.}}; surfacetranslationvector = {Re[x10 + 3.*Cos[0.017453292519943295*θ10]], Re[y10 + 3.*Sin[0.017453292519943295*θ10]], 0.}; activeregion = -1.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; ZAxis = First[surfnorm]*Sign[First[surfnorm] . {r1, r2, r3}]; raytiltz = ZAxis . {r1, r2, r3}; raytiltx = 1 - raytiltz^2; If[raytiltx < 2.220446049250313*^-16, raytiltx = 0., raytiltx = Sqrt[raytiltx]]; XAxis = {r1, r2, r3} - ZAxis*raytiltz; If[Abs[raytiltx] < 1.*^-7, XAxis = surfnorm[[2]], XAxis = XAxis/raytiltx]; YAxis = {-(ZAxis[[3]]*XAxis[[2]]) + ZAxis[[2]]*XAxis[[3]], ZAxis[[3]]*XAxis[[1]] - ZAxis[[1]]*XAxis[[3]], -(ZAxis[[2]]*XAxis[[1]]) + ZAxis[[1]]*XAxis[[2]]}; YAxis = YAxis/Sqrt[YAxis . YAxis]; PAxis = ZAxis*{r1, r2, r3} . XAxis - XAxis*{r1, r2, r3} . ZAxis; PAxis = PAxis/Sqrt[PAxis . PAxis]; normalizedpolarization = {pol1, pol2, pol3}[[{1, 2}]]; normalizedpolarization = normalizedpolarization/Sqrt[normalizedpolarization . normalizedpolarization]; allcreatedamplitudes = {{I*0., I*0., I*0.}}; amplitude = Sqrt[intensity]*(normalizedpolarization[[1]]*{r4, r5, r6} + normalizedpolarization[[2]]*{r7, r8, r9}*Exp[I*pol3*0.017453292519943295]); perpendicularamplitude = amplitude . YAxis; parallelamplitude = amplitude . PAxis; If[activeregion*(surfacerotationmatrix . {r1, r2, r3})[[1]] > 0, index2 = Sqrt[2.104776438756983 - 0.0096874169418655*wavelength^2 + 0.0085190066553111/wavelength^2 + 0.0001250023747871254/wavelength^4 - 9.75184541025562*^-7/wavelength^6 + 6.099025456439798*^-8/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]], index2 = Sqrt[1.0005281111748805 - 2.364805676582992*^-10*wavelength^2 + 2.9781670902982902*^-6/wavelength^2 + 2.6004099469477187*^-8/wavelength^4 + 3.7787839314048715*^-10/wavelength^6 + 2.830549017940716*^-12/wavelength^8]; index1 = index; If[Abs[index2 - index1] < 0.01, alternateindex = Sqrt[2.104776438756983 - 0.0096874169418655*wavelength^2 + 0.0085190066553111/wavelength^2 + 0.0001250023747871254/wavelength^4 - 9.75184541025562*^-7/wavelength^6 + 6.099025456439798*^-8/wavelength^8]; If[Abs[alternateindex - index1] > Abs[index2 - index1], index1 = index2; index2 = alternateindex, index1 = alternateindex], index1 = Sqrt[2.104776438756983 - 0.0096874169418655*wavelength^2 + 0.0085190066553111/wavelength^2 + 0.0001250023747871254/wavelength^4 - 9.75184541025562*^-7/wavelength^6 + 6.099025456439798*^-8/wavelength^8]]]; n12 = index1/index2; index = index2; If[1 - n12^2*raytiltx^2 >= 0., dummyvector = n12*{r1, r2, r3} + ZAxis*(-(n12*raytiltz) + Sqrt[1 - n12^2*raytiltx^2]); {r1, r2, r3} = dummyvector; 1., If[{r1, r2, r3} . surfnorm[[1]] > 0, phaseshift = phaseshift + 0.5, 1.]; index2 = index1; index = index1; dummyvector = {r1, r2, r3} - 2*ZAxis*ZAxis . {r1, r2, r3}; {r1, r2, r3} = dummyvector; dummyvector = {pol1, pol2, pol3} + {0, 0, -180}; {pol1, pol2, pol3} = dummyvector; 1.]; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; originalrotation = Partition[Take[originalray, {7, 15}], 3]; previoustilt = originalrotation[[1]]; transmatrix = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; rotationaxis = Cross[{1., 0., 0.}, {r1, r2, r3}]; axismagnitude = Sqrt[rotationaxis . rotationaxis]; If[Chop[axismagnitude] != 0., rotationaxis = rotationaxis/axismagnitude; axismatrix = (#1*rotationaxis & ) /@ rotationaxis; crossmatrix = {{0., -rotationaxis[[3]], rotationaxis[[2]]}, {rotationaxis[[3]], 0., -rotationaxis[[1]]}, {-rotationaxis[[2]], rotationaxis[[1]], 0.}}; cosangle = {1., 0., 0.} . {r1, r2, r3}; If[1. - cosangle < 2.220446049250313*^-16, cosangle = 1.]; sinangle = 1 - cosangle^2; If[sinangle < 2.220446049250313*^-16, sinangle = 0., sinangle = Sqrt[sinangle]]; axismatrix + ({{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}} - axismatrix)*cosangle + crossmatrix*sinangle, {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = If[Sign[{1., 0., 0.} . {r1, r2, r3}] === 1, {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}, {{-1., 0., 0.}, {0., -1., 0.}, {0., 0., 1.}}]]) & , allcreatedrays]; allcreatedrays = MapIndexed[({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = Function[mm, (mm . #1 & ) /@ {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}][transmatrix[[First[#2]]]]; tiltmagnitude = {r1, r2, r3} . {r1, r2, r3}; If[Abs[tiltmagnitude - 1.] > 1.*^-6, dummyvector = {r1, r2, r3}/Sqrt[tiltmagnitude]; {r1, r2, r3} = dummyvector; dummymatrix = (#1/Sqrt[#1 . #1] & ) /@ {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}}; {{r1, r2, r3}, {r4, r5, r6}, {r7, r8, r9}} = dummymatrix; 1., 1.]; If[allcreatedamplitudes != {{I*0., I*0., I*0.}}, amplitude = allcreatedamplitudes[[First[#2]]]; hor = {r4, r5, r6} . amplitude; ver = {r7, r8, r9} . amplitude; If[Abs[hor] > 0. || Abs[ver] > 0., {pol1, pol2, pol3} = {Abs[hor], Abs[ver], 0.}; dummyvector = {pol1, pol2, pol3}/Sqrt[{pol1, pol2, pol3} . {pol1, pol2, pol3}]; {pol1, pol2, pol3} = dummyvector; dummyvector = ReplacePart[{pol1, pol2, pol3}, (If[ver == 0., 0., Arg[ver]] - If[hor == 0., 0., Arg[hor]])/Degree, 3]; {pol1, pol2, pol3} = dummyvector]; 1., 1.]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}) & , allcreatedrays]); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, True, deflecteddummyrayspresent = True; reporteddummyrayspresent = True; localoutrayspresent = True; {{{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}}], deflecteddummyrayspresent = True; reporteddummyrayspresent = True; localdummyoutrayspresent = True; {{{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}}]) & ) /@ inrays]; If[deflectedrayspresent && deflecteddummyrayspresent, deflectedlocalrays = Select[deflectedlocalrays, #1[[23]] > 0. & ]*1., 1.]; If[localoutrayspresent, If[localdummyoutrayspresent, localoutrays = Select[localoutrays, #1[[23]] > 0. & ]; 1., 1.]; outrays = Join[outrays, localoutrays]; 1., 1.]; If[reportedrayspresent && reporteddummyrayspresent, reportedlocalrays = Select[reportedlocalrays, #1[[23]] > 0. & ]; 1., 1.]); If[reportedrayspresent, raysreported = True; reportedrays = Join[reportedrays, {{-9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8}}, reportedlocalrays]; 1., 1.]; inrays = deflectedlocalrays; propagate = generationnumber < generationlimit]; propagatedrays = If[Length[outrays] > 1, Drop[outrays, 1], outrays]; If[generationnumber >= generationlimit && deflectedrayspresent, propagatedrays = Join[propagatedrays, deflectedlocalrays]; 1., 1.]); (generationnumber += 1.; reportedlocalrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, 0, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; deflectedlocalrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}; (deflectedrayspresent = False; reportedrayspresent = False; deflecteddummyrayspresent = False; reporteddummyrayspresent = False; {deflectedlocalrays, reportedlocalrays} = Transpose[((({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1; yunit = r2; zunit = r3; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = rex - 1.*Re[x8]; ry = rey; rz = rez; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}); If[intensity > thresholdintensity, deflectedrayspresent = True; (intersections = If[Chop[xunit] != 0, {(If[N[Chop[#1[[1]]]] >= 0. && #1[[2]]^2 + #1[[3]]^2 <= 2500., {#1[[1]], #1[[2]], #1[[3]]}, {-1., 0., 0.}] & )[{-(rx/xunit), ry - (rx*yunit)/xunit, rz - (rx*zunit)/xunit}]}, {{-1., 0., 0.}}]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5699.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]); If[intersections != {{-1., 0., 0.}}, intersectionspresent = True; ({newcomponentnumber, newsurfacenumber, newsurfaceid} = {2., 1., 5699.}; {componentnumber, surfacenumber, surfaceid} = {2., 1., 5699.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = rxhlp + Re[x8]; rey = ryhlp; rez = rzhlp; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}); (reportedrayspresent = True; (surfnorm = 1.*Re[{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}]; dummymatrix = (#1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{1., 0, 0}, {0, 1., 0}, {0, 0, 1.}}; surfacetranslationvector = {Re[x8], 0., 0.}; activeregion = 0.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}})); {First[allcreatedrays], completedray}, reporteddummyrayspresent = True; {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}, {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}], reporteddummyrayspresent = True; deflecteddummyrayspresent = True; {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}, {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}]) & ) /@ propagatedrays]; If[deflectedrayspresent && deflecteddummyrayspresent, deflectedlocalrays = Select[deflectedlocalrays, #1[[23]] > 0. & ]; 1., 1.]; If[reportedrayspresent && reporteddummyrayspresent, reportedlocalrays = Select[reportedlocalrays, #1[[23]] > 0. & ]; 1., 1.]); (If[reportedrayspresent, reportedrays = Join[reportedrays, {{-9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8}}, reportedlocalrays]; 1., 1.]; propagatedrays = deflectedlocalrays); raysreported = reportedrayspresent; 1.); (inrays = propagatedrays; outrays = {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}; deflectedrayspresent = True; reportedrayspresent = False; propagate = True; While[deflectedrayspresent && propagate, generationnumber += 1.; (deflecteddummyrayspresent = False; deflectedrayspresent = False; reportedrayspresent = False; reporteddummyrayspresent = True; localdummyoutrayspresent = False; localoutrayspresent = False; {deflectedlocalrays, localoutrays, reportedlocalrays} = (Flatten[#1, 1] & ) /@ Transpose[(({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; If[intensity > thresholdintensity && generationnumber < generationlimit, (resonatenumber = 0; resonateraylength = 9.87654321*^8; resonateintersections = {{-1., 0., 0.}}; MapIndexed[If[#1[[1,1]] > -1. && #1[[1,1]] < resonateraylength, resonateraylength = #1[[1,1]]; resonateintersections = #1; resonatenumber = First[#2], resonatenumber] & , intersectionslist = {{{-1., 0., 0.}}}; holeQlist = {0}; ({rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = -1.*r1; yunit = -1.*r2; zunit = r3; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = -1.*(-200. + rex); ry = -1.*rey; rz = rez; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = If[Chop[xunit] != 0, {(If[N[Chop[#1[[1]]]] >= 0. && (#1[[2]] <= 100. && #1[[2]] >= -100. && #1[[3]] >= -100. && #1[[3]] <= 100.), {#1[[1]], #1[[2]], #1[[3]]}, {-1., 0., 0.}] & )[{-(rx/xunit), ry - (rx*yunit)/xunit, rz - (rx*zunit)/xunit}]}, {{-1., 0., 0.}}]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5800.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r2; yunit = -1.*r1; zunit = r3; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = 100. + rey; ry = -1.*(-100. + rex); rz = rez; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = If[Chop[xunit] != 0, {(If[N[Chop[#1[[1]]]] >= 0. && (#1[[2]] <= 100. && #1[[2]] >= -100. && #1[[3]] >= -100. && #1[[3]] <= 100.), {#1[[1]], #1[[2]], #1[[3]]}, {-1., 0., 0.}] & )[{-(rx/xunit), ry - (rx*yunit)/xunit, rz - (rx*zunit)/xunit}]}, {{-1., 0., 0.}}]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5801.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1; yunit = r2; zunit = r3; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = rex; ry = rey; rz = rez; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = If[Chop[xunit] != 0, {(If[N[Chop[#1[[1]]]] >= 0. && (#1[[2]] <= 100. && #1[[2]] >= -100. && #1[[3]] >= -100. && #1[[3]] <= 100.), {#1[[1]], #1[[2]], #1[[3]]}, {-1., 0., 0.}] & )[{-(rx/xunit), ry - (rx*yunit)/xunit, rz - (rx*zunit)/xunit}]}, {{-1., 0., 0.}}]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5802.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = -1.*r2; yunit = r1; zunit = r3; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = -1.*(-100. + rey); ry = -100. + rex; rz = rez; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = If[Chop[xunit] != 0, {(If[N[Chop[#1[[1]]]] >= 0. && (#1[[2]] <= 100. && #1[[2]] >= -100. && #1[[3]] >= -100. && #1[[3]] <= 100.), {#1[[1]], #1[[2]], #1[[3]]}, {-1., 0., 0.}] & )[{-(rx/xunit), ry - (rx*yunit)/xunit, rz - (rx*zunit)/xunit}]}, {{-1., 0., 0.}}]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5803.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r3; yunit = r2; zunit = -1.*r1; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = 100. + rez; ry = rey; rz = -1.*(-100. + rex); rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = If[Chop[xunit] != 0, {(If[N[Chop[#1[[1]]]] >= 0. && (#1[[2]] <= 100. && #1[[2]] >= -100. && #1[[3]] >= -100. && #1[[3]] <= 100.), {#1[[1]], #1[[2]], #1[[3]]}, {-1., 0., 0.}] & )[{-(rx/xunit), ry - (rx*yunit)/xunit, rz - (rx*zunit)/xunit}]}, {{-1., 0., 0.}}]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5804.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]; {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = -1.*r3; yunit = -1.*r2; zunit = -1.*r1; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = -1.*(-100. + rez); ry = -1.*rey; rz = -1.*(-100. + rex); rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = If[Chop[xunit] != 0, {(If[N[Chop[#1[[1]]]] >= 0. && (#1[[2]] <= 100. && #1[[2]] >= -100. && #1[[3]] >= -100. && #1[[3]] <= 100.), {#1[[1]], #1[[2]], #1[[3]]}, {-1., 0., 0.}] & )[{-(rx/xunit), ry - (rx*yunit)/xunit, rz - (rx*zunit)/xunit}]}, {{-1., 0., 0.}}]; AppendTo[intersections, {-1., 0., 0.}]; holeQ = False; If[ !(Chop[surfaceid - 5805.] == 0. || N[Chop[ray1]] < 0.0001) || generationnumber == 1., minresonateraylength = 0., minresonateraylength = 0.0001]; Block[{RayL, SCx, SCy}, RayL = 1.; SCx = 1.; SCy = 1.; dummymatrix = Union[Select[intersections, ({RayL, SCx, SCy} = #1; {RayL, SCx, SCy} == {-1., 0., 0.} || N[Chop[RayL]] >= minresonateraylength) & ]]; intersections = dummymatrix]; unfilteredintersections = intersections; If[Length[intersections] > 1, dummymatrix = Take[intersections, {2}]; intersections = dummymatrix; 1., 1.]; AppendTo[intersectionslist, intersections]; If[holeQ, AppendTo[holeQlist, 1], AppendTo[holeQlist, 0]]); holeQlist = Drop[holeQlist, 1]; Drop[intersectionslist, 1]]); Which[resonatenumber == 1, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = -1.*r1; yunit = -1.*r2; zunit = r3; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = -1.*(-200. + rex); ry = -1.*rey; rz = rez; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {3., 1., 5800.}; {componentnumber, surfacenumber, surfaceid} = {3., 1., 5800.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = 200. - 1.*rxhlp; rey = -1.*ryhlp; rez = rzhlp; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}]; dummymatrix = ({{-1., 0., 0.}, {0., -1., 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{-1., 0, 0}, {0, -1., 0}, {0, 0, 1.}}; surfacetranslationvector = {200., 0, 0}; activeregion = 0.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; intensity = 0.; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 2, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r2; yunit = -1.*r1; zunit = r3; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = 100. + rey; ry = -1.*(-100. + rex); rz = rez; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {3., 2., 5801.}; {componentnumber, surfacenumber, surfaceid} = {3., 2., 5801.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = 100. - 1.*ryhlp; rey = -100. + rxhlp; rez = rzhlp; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}]; dummymatrix = ({{0., -1., 0.}, {1., 0., 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{0, 1., 0}, {-1., 0, 0}, {0, 0, 1.}}; surfacetranslationvector = {100., -100., 0}; activeregion = 0.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; intensity = 0.; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 3, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r1; yunit = r2; zunit = r3; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = rex; ry = rey; rz = rez; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {3., 3., 5802.}; {componentnumber, surfacenumber, surfaceid} = {3., 3., 5802.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = rxhlp; rey = ryhlp; rez = rzhlp; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}]; dummymatrix = (#1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; surfacetranslationvector = {0, 0, 0}; activeregion = 0.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; intensity = 0.; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 4, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = -1.*r2; yunit = r1; zunit = r3; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = -1.*(-100. + rey); ry = -100. + rex; rz = rez; rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {3., 4., 5803.}; {componentnumber, surfacenumber, surfaceid} = {3., 4., 5803.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = 100. + ryhlp; rey = 100. - 1.*rxhlp; rez = rzhlp; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}]; dummymatrix = ({{0., 1., 0.}, {-1., 0., 0.}, {0., 0., 1.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{0, -1., 0}, {1., 0, 0}, {0, 0, 1.}}; surfacetranslationvector = {100., 100., 0}; activeregion = 0.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; intensity = 0.; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 5, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = r3; yunit = r2; zunit = -1.*r1; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = 100. + rez; ry = rey; rz = -1.*(-100. + rex); rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {3., 5., 5804.}; {componentnumber, surfacenumber, surfaceid} = {3., 5., 5804.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = 100. - 1.*rzhlp; rey = ryhlp; rez = -100. + rxhlp; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}]; dummymatrix = ({{0., 0., -1.}, {0., 1., 0.}, {1., 0., 0.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{0, 0, 1.}, {0, 1., 0}, {-1., 0, 0}}; surfacetranslationvector = {100., 0, -100.}; activeregion = 0.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; intensity = 0.; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, resonatenumber == 6, {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, oldgenerationnumber, intersectionnumber, pol1, pol2, pol3} = #1; index1 = index; xunit = -1.*r3; yunit = -1.*r2; zunit = -1.*r1; xunit = Chop[xunit]; yunit = Chop[yunit]; zunit = Chop[zunit]; magnitude = (xunit^2 + yunit^2 + zunit^2)^2^(-1); xunit = xunit/magnitude; yunit = yunit/magnitude; zunit = zunit/magnitude; rx = -1.*(-100. + rez); ry = -1.*rey; rz = -1.*(-100. + rex); rx = Chop[rx]; ry = Chop[ry]; rz = Chop[rz]; terminatedeflection = False; intersections = {{-1., 0., 0.}}; intersections = resonateintersections; holeQ = holeQlist[[resonatenumber]] == 1; {newcomponentnumber, newsurfacenumber, newsurfaceid} = {3., 6., 5805.}; {componentnumber, surfacenumber, surfaceid} = {3., 6., 5805.}; {ray1, ray2, ray3} = intersections[[1]]; rsx = rex; rsy = rey; rsz = rez; rxhlp = rx + ray1*xunit; ryhlp = ry + ray1*yunit; rzhlp = rz + ray1*zunit; rex = 100. - 1.*rzhlp; rey = -1.*ryhlp; rez = 100. - 1.*rxhlp; rex = Chop[rex]; rey = Chop[rey]; rez = Chop[rez]; intersectionnumber = intersectionnumber + 1.; opticallength = opticallength + ray1*index1; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; reportedrayspresent = True; intersectionspresent = True; deflectedrayspresent = True; localdummyoutrayspresent = True; (surfnorm = 1.*Re[{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}]; dummymatrix = ({{0., 0., -1.}, {0., -1., 0.}, {-1., 0., 0.}} . #1 & ) /@ surfnorm; surfnorm = (#1/Sqrt[#1 . #1] & ) /@ dummymatrix; surfacerotationmatrix = {{0, 0, -1.}, {0, -1., 0}, {-1., 0, 0}}; surfacetranslationvector = {100., 0, 100.}; activeregion = 0.; completedray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; componentnumber = newcomponentnumber; surfacenumber = newsurfacenumber; surfaceid = newsurfaceid; originalray = {rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}; intensity = 0.; allcreatedrays = {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}); {allcreatedrays, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {completedray}}, True, deflecteddummyrayspresent = True; reporteddummyrayspresent = True; localoutrayspresent = True; {{{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {{rsx, rsy, rsz, rex, rey, rez, r1, r2, r3, r4, r5, r6, r7, r8, r9, wavelength, intensity, intensityscale, ray1, index, opticallength, phaseshift, componentnumber, surfacenumber, surfaceid, ray2, ray3, sid, frontid, sno1, sno2, sno3, sno4, rayslot, generationnumber, intersectionnumber, pol1, pol2, pol3}}, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}}], deflecteddummyrayspresent = True; reporteddummyrayspresent = True; localdummyoutrayspresent = True; {{{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}, {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., -9.87654321*^8, 1., 1., 1., 1., 0., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}}]) & ) /@ inrays]; If[deflectedrayspresent && deflecteddummyrayspresent, deflectedlocalrays = Select[deflectedlocalrays, #1[[23]] > 0. & ]*1., 1.]; If[localoutrayspresent, If[localdummyoutrayspresent, localoutrays = Select[localoutrays, #1[[23]] > 0. & ]; 1., 1.]; outrays = Join[outrays, localoutrays]; 1., 1.]; If[reportedrayspresent && reporteddummyrayspresent, reportedlocalrays = Select[reportedlocalrays, #1[[23]] > 0. & ]; 1., 1.]); If[reportedrayspresent, raysreported = True; reportedrays = Join[reportedrays, {{-9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8, -9.87654321*^8}}, reportedlocalrays]; 1., 1.]; inrays = deflectedlocalrays; propagate = generationnumber < generationlimit]; propagatedrays = If[Length[outrays] > 1, Drop[outrays, 1], outrays]; If[generationnumber >= generationlimit && deflectedrayspresent, propagatedrays = Join[propagatedrays, deflectedlocalrays]; 1., 1.]); If[Length[reportedrays] > 2, reportedrays = Drop[reportedrays, 2], reportedrays]; ({#1[[1]], #1[[2]], #1[[3]], #1[[4]], #1[[5]], #1[[6]]} & ) /@ reportedrays]]; polygons113200200710102030024133 = Compile[{θ3, PlanoConvexLensFocalLength, PlanoConvexLensThickness}, {{0.5187203321344371*PlanoConvexLensFocalLength*Cos[0.017453292519943295*θ3] - 1.*Sqrt[-625. + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Cos[0.017453292519943295*θ3]*Sign[PlanoConvexLensFocalLength] + 25.*Sin[0.017453292519943295*θ3], -25.*Cos[0.017453292519943295*θ3] + 0.5187203321344371*PlanoConvexLensFocalLength*Sin[0.017453292519943295*θ3] - 1.*Sqrt[-625. + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Sign[PlanoConvexLensFocalLength]*Sin[0.017453292519943295*θ3]}, {0.5187203321344371*PlanoConvexLensFocalLength*Cos[0.017453292519943295*θ3] - 1.*Sqrt[-434.0277777777779 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Cos[0.017453292519943295*θ3]*Sign[PlanoConvexLensFocalLength] + 20.833333333333336*Sin[0.017453292519943295*θ3], -20.833333333333336*Cos[0.017453292519943295*θ3] + 0.5187203321344371*PlanoConvexLensFocalLength*Sin[0.017453292519943295*θ3] - 1.*Sqrt[-434.0277777777779 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Sign[PlanoConvexLensFocalLength]*Sin[0.017453292519943295*θ3]}, {0.5187203321344371*PlanoConvexLensFocalLength*Cos[0.017453292519943295*θ3] - 1.*Sqrt[-277.7777777777778 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Cos[0.017453292519943295*θ3]*Sign[PlanoConvexLensFocalLength] + 16.666666666666668*Sin[0.017453292519943295*θ3], -16.666666666666668*Cos[0.017453292519943295*θ3] + 0.5187203321344371*PlanoConvexLensFocalLength*Sin[0.017453292519943295*θ3] - 1.*Sqrt[-277.7777777777778 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Sign[PlanoConvexLensFocalLength]*Sin[0.017453292519943295*θ3]}, {0.5187203321344371*PlanoConvexLensFocalLength*Cos[0.017453292519943295*θ3] - 1.*Sqrt[-156.25000000000006 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Cos[0.017453292519943295*θ3]*Sign[PlanoConvexLensFocalLength] + 12.500000000000002*Sin[0.017453292519943295*θ3], -12.500000000000002*Cos[0.017453292519943295*θ3] + 0.5187203321344371*PlanoConvexLensFocalLength*Sin[0.017453292519943295*θ3] - 1.*Sqrt[-156.25000000000006 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Sign[PlanoConvexLensFocalLength]*Sin[0.017453292519943295*θ3]}, {0.5187203321344371*PlanoConvexLensFocalLength*Cos[0.017453292519943295*θ3] - 1.*Sqrt[-69.44444444444449 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Cos[0.017453292519943295*θ3]*Sign[PlanoConvexLensFocalLength] + 8.333333333333336*Sin[0.017453292519943295*θ3], -8.333333333333336*Cos[0.017453292519943295*θ3] + 0.5187203321344371*PlanoConvexLensFocalLength*Sin[0.017453292519943295*θ3] - 1.*Sqrt[-69.44444444444449 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Sign[PlanoConvexLensFocalLength]*Sin[0.017453292519943295*θ3]}, {0.5187203321344371*PlanoConvexLensFocalLength*Cos[0.017453292519943295*θ3] - 1.*Sqrt[-17.36111111111115 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Cos[0.017453292519943295*θ3]*Sign[PlanoConvexLensFocalLength] + 4.166666666666671*Sin[0.017453292519943295*θ3], -4.166666666666671*Cos[0.017453292519943295*θ3] + 0.5187203321344371*PlanoConvexLensFocalLength*Sin[0.017453292519943295*θ3] - 1.*Sqrt[-17.36111111111115 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Sign[PlanoConvexLensFocalLength]*Sin[0.017453292519943295*θ3]}, {0.5187203321344371*PlanoConvexLensFocalLength*Cos[0.017453292519943295*θ3] - 1.*Sqrt[-1.262177448353619*^-29 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Cos[0.017453292519943295*θ3]*Sign[PlanoConvexLensFocalLength] + 3.552713678800501*^-15*Sin[0.017453292519943295*θ3], -3.552713678800501*^-15*Cos[0.017453292519943295*θ3] + 0.5187203321344371*PlanoConvexLensFocalLength*Sin[0.017453292519943295*θ3] - 1.*Sqrt[-1.262177448353619*^-29 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Sign[PlanoConvexLensFocalLength]*Sin[0.017453292519943295*θ3]}, {0.5187203321344371*PlanoConvexLensFocalLength*Cos[0.017453292519943295*θ3] - 1.*Sqrt[-17.361111111111093 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Cos[0.017453292519943295*θ3]*Sign[PlanoConvexLensFocalLength] - 4.166666666666664*Sin[0.017453292519943295*θ3], 4.166666666666664*Cos[0.017453292519943295*θ3] + 0.5187203321344371*PlanoConvexLensFocalLength*Sin[0.017453292519943295*θ3] - 1.*Sqrt[-17.361111111111093 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Sign[PlanoConvexLensFocalLength]*Sin[0.017453292519943295*θ3]}, {0.5187203321344371*PlanoConvexLensFocalLength*Cos[0.017453292519943295*θ3] - 1.*Sqrt[-69.44444444444437 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Cos[0.017453292519943295*θ3]*Sign[PlanoConvexLensFocalLength] - 8.333333333333329*Sin[0.017453292519943295*θ3], 8.333333333333329*Cos[0.017453292519943295*θ3] + 0.5187203321344371*PlanoConvexLensFocalLength*Sin[0.017453292519943295*θ3] - 1.*Sqrt[-69.44444444444437 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Sign[PlanoConvexLensFocalLength]*Sin[0.017453292519943295*θ3]}, {0.5187203321344371*PlanoConvexLensFocalLength*Cos[0.017453292519943295*θ3] - 1.*Sqrt[-156.24999999999983 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Cos[0.017453292519943295*θ3]*Sign[PlanoConvexLensFocalLength] - 12.499999999999993*Sin[0.017453292519943295*θ3], 12.499999999999993*Cos[0.017453292519943295*θ3] + 0.5187203321344371*PlanoConvexLensFocalLength*Sin[0.017453292519943295*θ3] - 1.*Sqrt[-156.24999999999983 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Sign[PlanoConvexLensFocalLength]*Sin[0.017453292519943295*θ3]}, {0.5187203321344371*PlanoConvexLensFocalLength*Cos[0.017453292519943295*θ3] - 1.*Sqrt[-277.7777777777775 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Cos[0.017453292519943295*θ3]*Sign[PlanoConvexLensFocalLength] - 16.666666666666657*Sin[0.017453292519943295*θ3], 16.666666666666657*Cos[0.017453292519943295*θ3] + 0.5187203321344371*PlanoConvexLensFocalLength*Sin[0.017453292519943295*θ3] - 1.*Sqrt[-277.7777777777775 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Sign[PlanoConvexLensFocalLength]*Sin[0.017453292519943295*θ3]}, {0.5187203321344371*PlanoConvexLensFocalLength*Cos[0.017453292519943295*θ3] - 1.*Sqrt[-434.0277777777776 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Cos[0.017453292519943295*θ3]*Sign[PlanoConvexLensFocalLength] - 20.83333333333333*Sin[0.017453292519943295*θ3], 20.83333333333333*Cos[0.017453292519943295*θ3] + 0.5187203321344371*PlanoConvexLensFocalLength*Sin[0.017453292519943295*θ3] - 1.*Sqrt[-434.0277777777776 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Sign[PlanoConvexLensFocalLength]*Sin[0.017453292519943295*θ3]}, {0.5187203321344371*PlanoConvexLensFocalLength*Cos[0.017453292519943295*θ3] - 1.*Sqrt[-624.9999999999997 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Cos[0.017453292519943295*θ3]*Sign[PlanoConvexLensFocalLength] - 24.999999999999993*Sin[0.017453292519943295*θ3], 24.999999999999993*Cos[0.017453292519943295*θ3] + 0.5187203321344371*PlanoConvexLensFocalLength*Sin[0.017453292519943295*θ3] - 1.*Sqrt[-624.9999999999997 + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Sign[PlanoConvexLensFocalLength]*Sin[0.017453292519943295*θ3]}, {PlanoConvexLensThickness*Cos[0.017453292519943295*θ3] - 25.*Sin[0.017453292519943295*θ3], 25.*Cos[0.017453292519943295*θ3] + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]}, {PlanoConvexLensThickness*Cos[0.017453292519943295*θ3] - 20.833333333333336*Sin[0.017453292519943295*θ3], 20.833333333333336*Cos[0.017453292519943295*θ3] + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]}, {PlanoConvexLensThickness*Cos[0.017453292519943295*θ3] - 16.666666666666668*Sin[0.017453292519943295*θ3], 16.666666666666668*Cos[0.017453292519943295*θ3] + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]}, {PlanoConvexLensThickness*Cos[0.017453292519943295*θ3] - 12.500000000000002*Sin[0.017453292519943295*θ3], 12.500000000000002*Cos[0.017453292519943295*θ3] + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]}, {PlanoConvexLensThickness*Cos[0.017453292519943295*θ3] - 8.333333333333336*Sin[0.017453292519943295*θ3], 8.333333333333336*Cos[0.017453292519943295*θ3] + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]}, {PlanoConvexLensThickness*Cos[0.017453292519943295*θ3] - 4.166666666666671*Sin[0.017453292519943295*θ3], 4.166666666666671*Cos[0.017453292519943295*θ3] + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]}, {PlanoConvexLensThickness*Cos[0.017453292519943295*θ3] - 3.552713678800501*^-15*Sin[0.017453292519943295*θ3], 3.552713678800501*^-15*Cos[0.017453292519943295*θ3] + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]}, {PlanoConvexLensThickness*Cos[0.017453292519943295*θ3] + 4.166666666666664*Sin[0.017453292519943295*θ3], -4.166666666666664*Cos[0.017453292519943295*θ3] + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]}, {PlanoConvexLensThickness*Cos[0.017453292519943295*θ3] + 8.333333333333329*Sin[0.017453292519943295*θ3], -8.333333333333329*Cos[0.017453292519943295*θ3] + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]}, {PlanoConvexLensThickness*Cos[0.017453292519943295*θ3] + 12.499999999999993*Sin[0.017453292519943295*θ3], -12.499999999999993*Cos[0.017453292519943295*θ3] + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]}, {PlanoConvexLensThickness*Cos[0.017453292519943295*θ3] + 16.666666666666657*Sin[0.017453292519943295*θ3], -16.666666666666657*Cos[0.017453292519943295*θ3] + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]}, {PlanoConvexLensThickness*Cos[0.017453292519943295*θ3] + 20.83333333333333*Sin[0.017453292519943295*θ3], -20.83333333333333*Cos[0.017453292519943295*θ3] + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]}, {PlanoConvexLensThickness*Cos[0.017453292519943295*θ3] + 24.999999999999993*Sin[0.017453292519943295*θ3], -24.999999999999993*Cos[0.017453292519943295*θ3] + PlanoConvexLensThickness*Sin[0.017453292519943295*θ3]}, {0.5187203321344371*PlanoConvexLensFocalLength*Cos[0.017453292519943295*θ3] - 1.*Sqrt[-625. + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Cos[0.017453292519943295*θ3]*Sign[PlanoConvexLensFocalLength] + 25.*Sin[0.017453292519943295*θ3], -25.*Cos[0.017453292519943295*θ3] + 0.5187203321344371*PlanoConvexLensFocalLength*Sin[0.017453292519943295*θ3] - 1.*Sqrt[-625. + 0.2690707829696608*PlanoConvexLensFocalLength^2]*Sign[PlanoConvexLensFocalLength]*Sin[0.017453292519943295*θ3]}}]; polygons123200200710102030043537 = Compile[{θ9}, {{13.523633236268505*Cos[0.017453292519943295*θ9] + 25.4*Sin[0.017453292519943295*θ9], -25.4*Cos[0.017453292519943295*θ9] + 13.523633236268505*Sin[0.017453292519943295*θ9]}, {8.49604191587564*Cos[0.017453292519943295*θ9] + 21.166666666666664*Sin[0.017453292519943295*θ9], -21.166666666666664*Cos[0.017453292519943295*θ9] + 8.49604191587564*Sin[0.017453292519943295*θ9]}, {5.109330826733682*Cos[0.017453292519943295*θ9] + 16.933333333333334*Sin[0.017453292519943295*θ9], -16.933333333333334*Cos[0.017453292519943295*θ9] + 5.109330826733682*Sin[0.017453292519943295*θ9]}, {2.758447269339122*Cos[0.017453292519943295*θ9] + 12.700000000000001*Sin[0.017453292519943295*θ9], -12.700000000000001*Cos[0.017453292519943295*θ9] + 2.758447269339122*Sin[0.017453292519943295*θ9]}, {1.1940299321835859*Cos[0.017453292519943295*θ9] + 8.466666666666669*Sin[0.017453292519943295*θ9], -8.466666666666669*Cos[0.017453292519943295*θ9] + 1.1940299321835859*Sin[0.017453292519943295*θ9]}, {0.2940989613843854*Cos[0.017453292519943295*θ9] + 4.233333333333334*Sin[0.017453292519943295*θ9], -4.233333333333334*Cos[0.017453292519943295*θ9] + 0.2940989613843854*Sin[0.017453292519943295*θ9]}, {-3.552713678800501*^-15*Cos[0.017453292519943295*θ9] + 3.552713678800501*^-15*Sin[0.017453292519943295*θ9], -3.552713678800501*^-15*Cos[0.017453292519943295*θ9] - 3.552713678800501*^-15*Sin[0.017453292519943295*θ9]}, {0.29409896138438185*Cos[0.017453292519943295*θ9] - 4.233333333333327*Sin[0.017453292519943295*θ9], 4.233333333333327*Cos[0.017453292519943295*θ9] + 0.29409896138438185*Sin[0.017453292519943295*θ9]}, {1.1940299321835859*Cos[0.017453292519943295*θ9] - 8.466666666666661*Sin[0.017453292519943295*θ9], 8.466666666666661*Cos[0.017453292519943295*θ9] + 1.1940299321835859*Sin[0.017453292519943295*θ9]}, {2.758447269339122*Cos[0.017453292519943295*θ9] - 12.699999999999996*Sin[0.017453292519943295*θ9], 12.699999999999996*Cos[0.017453292519943295*θ9] + 2.758447269339122*Sin[0.017453292519943295*θ9]}, {5.109330826733679*Cos[0.017453292519943295*θ9] - 16.93333333333333*Sin[0.017453292519943295*θ9], 16.93333333333333*Cos[0.017453292519943295*θ9] + 5.109330826733679*Sin[0.017453292519943295*θ9]}, {8.496041915875633*Cos[0.017453292519943295*θ9] - 21.166666666666657*Sin[0.017453292519943295*θ9], 21.166666666666657*Cos[0.017453292519943295*θ9] + 8.496041915875633*Sin[0.017453292519943295*θ9]}, {13.523633236268491*Cos[0.017453292519943295*θ9] - 25.39999999999999*Sin[0.017453292519943295*θ9], 25.39999999999999*Cos[0.017453292519943295*θ9] + 13.523633236268491*Sin[0.017453292519943295*θ9]}, {14.476366763731493*Cos[0.017453292519943295*θ9] - 25.4*Sin[0.017453292519943295*θ9], 25.4*Cos[0.017453292519943295*θ9] + 14.476366763731493*Sin[0.017453292519943295*θ9]}, {19.50395808412436*Cos[0.017453292519943295*θ9] - 21.166666666666664*Sin[0.017453292519943295*θ9], 21.166666666666664*Cos[0.017453292519943295*θ9] + 19.50395808412436*Sin[0.017453292519943295*θ9]}, {22.890669173266318*Cos[0.017453292519943295*θ9] - 16.933333333333334*Sin[0.017453292519943295*θ9], 16.933333333333334*Cos[0.017453292519943295*θ9] + 22.890669173266318*Sin[0.017453292519943295*θ9]}, {25.241552730660878*Cos[0.017453292519943295*θ9] - 12.700000000000001*Sin[0.017453292519943295*θ9], 12.700000000000001*Cos[0.017453292519943295*θ9] + 25.241552730660878*Sin[0.017453292519943295*θ9]}, {26.805970067816414*Cos[0.017453292519943295*θ9] - 8.466666666666669*Sin[0.017453292519943295*θ9], 8.466666666666669*Cos[0.017453292519943295*θ9] + 26.805970067816414*Sin[0.017453292519943295*θ9]}, {27.705901038615615*Cos[0.017453292519943295*θ9] - 4.233333333333334*Sin[0.017453292519943295*θ9], 4.233333333333334*Cos[0.017453292519943295*θ9] + 27.705901038615615*Sin[0.017453292519943295*θ9]}, {28.000000000000004*Cos[0.017453292519943295*θ9] - 3.552713678800501*^-15*Sin[0.017453292519943295*θ9], 3.552713678800501*^-15*Cos[0.017453292519943295*θ9] + 28.000000000000004*Sin[0.017453292519943295*θ9]}, {27.705901038615618*Cos[0.017453292519943295*θ9] + 4.233333333333327*Sin[0.017453292519943295*θ9], -4.233333333333327*Cos[0.017453292519943295*θ9] + 27.705901038615618*Sin[0.017453292519943295*θ9]}, {26.805970067816414*Cos[0.017453292519943295*θ9] + 8.466666666666661*Sin[0.017453292519943295*θ9], -8.466666666666661*Cos[0.017453292519943295*θ9] + 26.805970067816414*Sin[0.017453292519943295*θ9]}, {25.241552730660878*Cos[0.017453292519943295*θ9] + 12.699999999999996*Sin[0.017453292519943295*θ9], -12.699999999999996*Cos[0.017453292519943295*θ9] + 25.241552730660878*Sin[0.017453292519943295*θ9]}, {22.89066917326632*Cos[0.017453292519943295*θ9] + 16.93333333333333*Sin[0.017453292519943295*θ9], -16.93333333333333*Cos[0.017453292519943295*θ9] + 22.89066917326632*Sin[0.017453292519943295*θ9]}, {19.503958084124367*Cos[0.017453292519943295*θ9] + 21.166666666666657*Sin[0.017453292519943295*θ9], -21.166666666666657*Cos[0.017453292519943295*θ9] + 19.503958084124367*Sin[0.017453292519943295*θ9]}, {14.476366763731507*Cos[0.017453292519943295*θ9] + 25.39999999999999*Sin[0.017453292519943295*θ9], -25.39999999999999*Cos[0.017453292519943295*θ9] + 14.476366763731507*Sin[0.017453292519943295*θ9]}, {13.523633236268505*Cos[0.017453292519943295*θ9] + 25.4*Sin[0.017453292519943295*θ9], -25.4*Cos[0.017453292519943295*θ9] + 13.523633236268505*Sin[0.017453292519943295*θ9]}}]; polygons133200200710102030079069 = Compile[{θ4, PlanoConcaveLensFocalLength, PlanoConcaveLensThickness}, {{0.5187203321344371*PlanoConcaveLensFocalLength*Cos[0.017453292519943295*θ4] - 1.*Sqrt[-362.90250000000003 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Cos[0.017453292519943295*θ4]*Sign[PlanoConcaveLensFocalLength] + 19.05*Sin[0.017453292519943295*θ4], -19.05*Cos[0.017453292519943295*θ4] + 0.5187203321344371*PlanoConcaveLensFocalLength*Sin[0.017453292519943295*θ4] - 1.*Sqrt[-362.90250000000003 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Sign[PlanoConcaveLensFocalLength]*Sin[0.017453292519943295*θ4]}, {0.5187203321344371*PlanoConcaveLensFocalLength*Cos[0.017453292519943295*θ4] - 1.*Sqrt[-252.015625 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Cos[0.017453292519943295*θ4]*Sign[PlanoConcaveLensFocalLength] + 15.875*Sin[0.017453292519943295*θ4], -15.875*Cos[0.017453292519943295*θ4] + 0.5187203321344371*PlanoConcaveLensFocalLength*Sin[0.017453292519943295*θ4] - 1.*Sqrt[-252.015625 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Sign[PlanoConcaveLensFocalLength]*Sin[0.017453292519943295*θ4]}, {0.5187203321344371*PlanoConcaveLensFocalLength*Cos[0.017453292519943295*θ4] - 1.*Sqrt[-161.29000000000002 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Cos[0.017453292519943295*θ4]*Sign[PlanoConcaveLensFocalLength] + 12.700000000000001*Sin[0.017453292519943295*θ4], -12.700000000000001*Cos[0.017453292519943295*θ4] + 0.5187203321344371*PlanoConcaveLensFocalLength*Sin[0.017453292519943295*θ4] - 1.*Sqrt[-161.29000000000002 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Sign[PlanoConcaveLensFocalLength]*Sin[0.017453292519943295*θ4]}, {0.5187203321344371*PlanoConcaveLensFocalLength*Cos[0.017453292519943295*θ4] - 1.*Sqrt[-90.72562500000004 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Cos[0.017453292519943295*θ4]*Sign[PlanoConcaveLensFocalLength] + 9.525000000000002*Sin[0.017453292519943295*θ4], -9.525000000000002*Cos[0.017453292519943295*θ4] + 0.5187203321344371*PlanoConcaveLensFocalLength*Sin[0.017453292519943295*θ4] - 1.*Sqrt[-90.72562500000004 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Sign[PlanoConcaveLensFocalLength]*Sin[0.017453292519943295*θ4]}, {0.5187203321344371*PlanoConcaveLensFocalLength*Cos[0.017453292519943295*θ4] - 1.*Sqrt[-40.32250000000002 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Cos[0.017453292519943295*θ4]*Sign[PlanoConcaveLensFocalLength] + 6.350000000000001*Sin[0.017453292519943295*θ4], -6.350000000000001*Cos[0.017453292519943295*θ4] + 0.5187203321344371*PlanoConcaveLensFocalLength*Sin[0.017453292519943295*θ4] - 1.*Sqrt[-40.32250000000002 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Sign[PlanoConcaveLensFocalLength]*Sin[0.017453292519943295*θ4]}, {0.5187203321344371*PlanoConcaveLensFocalLength*Cos[0.017453292519943295*θ4] - 1.*Sqrt[-10.080625000000005 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Cos[0.017453292519943295*θ4]*Sign[PlanoConcaveLensFocalLength] + 3.1750000000000007*Sin[0.017453292519943295*θ4], -3.1750000000000007*Cos[0.017453292519943295*θ4] + 0.5187203321344371*PlanoConcaveLensFocalLength*Sin[0.017453292519943295*θ4] - 1.*Sqrt[-10.080625000000005 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Sign[PlanoConcaveLensFocalLength]*Sin[0.017453292519943295*θ4]}, {0.5187203321344371*PlanoConcaveLensFocalLength*Cos[0.017453292519943295*θ4] - 1.*Sqrt[-1.262177448353619*^-29 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Cos[0.017453292519943295*θ4]*Sign[PlanoConcaveLensFocalLength] + 3.552713678800501*^-15*Sin[0.017453292519943295*θ4], -3.552713678800501*^-15*Cos[0.017453292519943295*θ4] + 0.5187203321344371*PlanoConcaveLensFocalLength*Sin[0.017453292519943295*θ4] - 1.*Sqrt[-1.262177448353619*^-29 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Sign[PlanoConcaveLensFocalLength]*Sin[0.017453292519943295*θ4]}, {0.5187203321344371*PlanoConcaveLensFocalLength*Cos[0.017453292519943295*θ4] - 1.*Sqrt[-10.080624999999982 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Cos[0.017453292519943295*θ4]*Sign[PlanoConcaveLensFocalLength] - 3.174999999999997*Sin[0.017453292519943295*θ4], 3.174999999999997*Cos[0.017453292519943295*θ4] + 0.5187203321344371*PlanoConcaveLensFocalLength*Sin[0.017453292519943295*θ4] - 1.*Sqrt[-10.080624999999982 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Sign[PlanoConcaveLensFocalLength]*Sin[0.017453292519943295*θ4]}, {0.5187203321344371*PlanoConcaveLensFocalLength*Cos[0.017453292519943295*θ4] - 1.*Sqrt[-40.32249999999997 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Cos[0.017453292519943295*θ4]*Sign[PlanoConcaveLensFocalLength] - 6.349999999999998*Sin[0.017453292519943295*θ4], 6.349999999999998*Cos[0.017453292519943295*θ4] + 0.5187203321344371*PlanoConcaveLensFocalLength*Sin[0.017453292519943295*θ4] - 1.*Sqrt[-40.32249999999997 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Sign[PlanoConcaveLensFocalLength]*Sin[0.017453292519943295*θ4]}, {0.5187203321344371*PlanoConcaveLensFocalLength*Cos[0.017453292519943295*θ4] - 1.*Sqrt[-90.72562499999998 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Cos[0.017453292519943295*θ4]*Sign[PlanoConcaveLensFocalLength] - 9.524999999999999*Sin[0.017453292519943295*θ4], 9.524999999999999*Cos[0.017453292519943295*θ4] + 0.5187203321344371*PlanoConcaveLensFocalLength*Sin[0.017453292519943295*θ4] - 1.*Sqrt[-90.72562499999998 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Sign[PlanoConcaveLensFocalLength]*Sin[0.017453292519943295*θ4]}, {0.5187203321344371*PlanoConcaveLensFocalLength*Cos[0.017453292519943295*θ4] - 1.*Sqrt[-161.29 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Cos[0.017453292519943295*θ4]*Sign[PlanoConcaveLensFocalLength] - 12.7*Sin[0.017453292519943295*θ4], 12.7*Cos[0.017453292519943295*θ4] + 0.5187203321344371*PlanoConcaveLensFocalLength*Sin[0.017453292519943295*θ4] - 1.*Sqrt[-161.29 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Sign[PlanoConcaveLensFocalLength]*Sin[0.017453292519943295*θ4]}, {0.5187203321344371*PlanoConcaveLensFocalLength*Cos[0.017453292519943295*θ4] - 1.*Sqrt[-252.0156249999999 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Cos[0.017453292519943295*θ4]*Sign[PlanoConcaveLensFocalLength] - 15.874999999999996*Sin[0.017453292519943295*θ4], 15.874999999999996*Cos[0.017453292519943295*θ4] + 0.5187203321344371*PlanoConcaveLensFocalLength*Sin[0.017453292519943295*θ4] - 1.*Sqrt[-252.0156249999999 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Sign[PlanoConcaveLensFocalLength]*Sin[0.017453292519943295*θ4]}, {0.5187203321344371*PlanoConcaveLensFocalLength*Cos[0.017453292519943295*θ4] - 1.*Sqrt[-362.90249999999975 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Cos[0.017453292519943295*θ4]*Sign[PlanoConcaveLensFocalLength] - 19.049999999999994*Sin[0.017453292519943295*θ4], 19.049999999999994*Cos[0.017453292519943295*θ4] + 0.5187203321344371*PlanoConcaveLensFocalLength*Sin[0.017453292519943295*θ4] - 1.*Sqrt[-362.90249999999975 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Sign[PlanoConcaveLensFocalLength]*Sin[0.017453292519943295*θ4]}, {PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4] - 19.05*Sin[0.017453292519943295*θ4], 19.05*Cos[0.017453292519943295*θ4] + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]}, {PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4] - 15.875*Sin[0.017453292519943295*θ4], 15.875*Cos[0.017453292519943295*θ4] + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]}, {PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4] - 12.700000000000001*Sin[0.017453292519943295*θ4], 12.700000000000001*Cos[0.017453292519943295*θ4] + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]}, {PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4] - 9.525000000000002*Sin[0.017453292519943295*θ4], 9.525000000000002*Cos[0.017453292519943295*θ4] + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]}, {PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4] - 6.350000000000001*Sin[0.017453292519943295*θ4], 6.350000000000001*Cos[0.017453292519943295*θ4] + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]}, {PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4] - 3.1750000000000007*Sin[0.017453292519943295*θ4], 3.1750000000000007*Cos[0.017453292519943295*θ4] + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]}, {PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4] - 3.552713678800501*^-15*Sin[0.017453292519943295*θ4], 3.552713678800501*^-15*Cos[0.017453292519943295*θ4] + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]}, {PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4] + 3.174999999999997*Sin[0.017453292519943295*θ4], -3.174999999999997*Cos[0.017453292519943295*θ4] + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]}, {PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4] + 6.349999999999998*Sin[0.017453292519943295*θ4], -6.349999999999998*Cos[0.017453292519943295*θ4] + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]}, {PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4] + 9.524999999999999*Sin[0.017453292519943295*θ4], -9.524999999999999*Cos[0.017453292519943295*θ4] + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]}, {PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4] + 12.7*Sin[0.017453292519943295*θ4], -12.7*Cos[0.017453292519943295*θ4] + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]}, {PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4] + 15.874999999999996*Sin[0.017453292519943295*θ4], -15.874999999999996*Cos[0.017453292519943295*θ4] + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]}, {PlanoConcaveLensThickness*Cos[0.017453292519943295*θ4] + 19.049999999999994*Sin[0.017453292519943295*θ4], -19.049999999999994*Cos[0.017453292519943295*θ4] + PlanoConcaveLensThickness*Sin[0.017453292519943295*θ4]}, {0.5187203321344371*PlanoConcaveLensFocalLength*Cos[0.017453292519943295*θ4] - 1.*Sqrt[-362.90250000000003 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Cos[0.017453292519943295*θ4]*Sign[PlanoConcaveLensFocalLength] + 19.05*Sin[0.017453292519943295*θ4], -19.05*Cos[0.017453292519943295*θ4] + 0.5187203321344371*PlanoConcaveLensFocalLength*Sin[0.017453292519943295*θ4] - 1.*Sqrt[-362.90250000000003 + 0.2690707829696608*PlanoConcaveLensFocalLength^2]*Sign[PlanoConcaveLensFocalLength]*Sin[0.017453292519943295*θ4]}}]; polygons143200200710102030099685 = Compile[{θ5}, {{25.*Sin[0.017453292519943295*θ5], -25.*Cos[0.017453292519943295*θ5]}, {20.833333333333336*Sin[0.017453292519943295*θ5], -20.833333333333336*Cos[0.017453292519943295*θ5]}, {16.666666666666668*Sin[0.017453292519943295*θ5], -16.666666666666668*Cos[0.017453292519943295*θ5]}, {12.500000000000002*Sin[0.017453292519943295*θ5], -12.500000000000002*Cos[0.017453292519943295*θ5]}, {8.333333333333336*Sin[0.017453292519943295*θ5], -8.333333333333336*Cos[0.017453292519943295*θ5]}, {4.166666666666671*Sin[0.017453292519943295*θ5], -4.166666666666671*Cos[0.017453292519943295*θ5]}, {3.552713678800501*^-15*Sin[0.017453292519943295*θ5], -3.552713678800501*^-15*Cos[0.017453292519943295*θ5]}, {-4.166666666666664*Sin[0.017453292519943295*θ5], 4.166666666666664*Cos[0.017453292519943295*θ5]}, {-8.333333333333329*Sin[0.017453292519943295*θ5], 8.333333333333329*Cos[0.017453292519943295*θ5]}, {-12.499999999999993*Sin[0.017453292519943295*θ5], 12.499999999999993*Cos[0.017453292519943295*θ5]}, {-16.666666666666657*Sin[0.017453292519943295*θ5], 16.666666666666657*Cos[0.017453292519943295*θ5]}, {-20.83333333333333*Sin[0.017453292519943295*θ5], 20.83333333333333*Cos[0.017453292519943295*θ5]}, {-24.999999999999993*Sin[0.017453292519943295*θ5], 24.999999999999993*Cos[0.017453292519943295*θ5]}, {5.*Cos[0.017453292519943295*θ5] - 25.*Sin[0.017453292519943295*θ5], 25.*Cos[0.017453292519943295*θ5] + 5.*Sin[0.017453292519943295*θ5]}, {5.*Cos[0.017453292519943295*θ5] - 20.833333333333336*Sin[0.017453292519943295*θ5], 20.833333333333336*Cos[0.017453292519943295*θ5] + 5.*Sin[0.017453292519943295*θ5]}, {5.*Cos[0.017453292519943295*θ5] - 16.666666666666668*Sin[0.017453292519943295*θ5], 16.666666666666668*Cos[0.017453292519943295*θ5] + 5.*Sin[0.017453292519943295*θ5]}, {5.*Cos[0.017453292519943295*θ5] - 12.500000000000002*Sin[0.017453292519943295*θ5], 12.500000000000002*Cos[0.017453292519943295*θ5] + 5.*Sin[0.017453292519943295*θ5]}, {5.*Cos[0.017453292519943295*θ5] - 8.333333333333336*Sin[0.017453292519943295*θ5], 8.333333333333336*Cos[0.017453292519943295*θ5] + 5.*Sin[0.017453292519943295*θ5]}, {5.*Cos[0.017453292519943295*θ5] - 4.166666666666671*Sin[0.017453292519943295*θ5], 4.166666666666671*Cos[0.017453292519943295*θ5] + 5.*Sin[0.017453292519943295*θ5]}, {5.*Cos[0.017453292519943295*θ5] - 3.552713678800501*^-15*Sin[0.017453292519943295*θ5], 3.552713678800501*^-15*Cos[0.017453292519943295*θ5] + 5.*Sin[0.017453292519943295*θ5]}, {5.*Cos[0.017453292519943295*θ5] + 4.166666666666664*Sin[0.017453292519943295*θ5], -4.166666666666664*Cos[0.017453292519943295*θ5] + 5.*Sin[0.017453292519943295*θ5]}, {5.*Cos[0.017453292519943295*θ5] + 8.333333333333329*Sin[0.017453292519943295*θ5], -8.333333333333329*Cos[0.017453292519943295*θ5] + 5.*Sin[0.017453292519943295*θ5]}, {5.*Cos[0.017453292519943295*θ5] + 12.499999999999993*Sin[0.017453292519943295*θ5], -12.499999999999993*Cos[0.017453292519943295*θ5] + 5.*Sin[0.017453292519943295*θ5]}, {5.*Cos[0.017453292519943295*θ5] + 16.666666666666657*Sin[0.017453292519943295*θ5], -16.666666666666657*Cos[0.017453292519943295*θ5] + 5.*Sin[0.017453292519943295*θ5]}, {5.*Cos[0.017453292519943295*θ5] + 20.83333333333333*Sin[0.017453292519943295*θ5], -20.83333333333333*Cos[0.017453292519943295*θ5] + 5.*Sin[0.017453292519943295*θ5]}, {5.*Cos[0.017453292519943295*θ5] + 24.999999999999993*Sin[0.017453292519943295*θ5], -24.999999999999993*Cos[0.017453292519943295*θ5] + 5.*Sin[0.017453292519943295*θ5]}, {25.*Sin[0.017453292519943295*θ5], -25.*Cos[0.017453292519943295*θ5]}}]; polygons153200200710102030120567 = Compile[{θ6}, {{25.*Sin[0.017453292519943295*θ6], -25.*Cos[0.017453292519943295*θ6]}, {20.833333333333336*Sin[0.017453292519943295*θ6], -20.833333333333336*Cos[0.017453292519943295*θ6]}, {16.666666666666668*Sin[0.017453292519943295*θ6], -16.666666666666668*Cos[0.017453292519943295*θ6]}, {12.500000000000002*Sin[0.017453292519943295*θ6], -12.500000000000002*Cos[0.017453292519943295*θ6]}, {8.333333333333336*Sin[0.017453292519943295*θ6], -8.333333333333336*Cos[0.017453292519943295*θ6]}, {4.166666666666671*Sin[0.017453292519943295*θ6], -4.166666666666671*Cos[0.017453292519943295*θ6]}, {3.552713678800501*^-15*Sin[0.017453292519943295*θ6], -3.552713678800501*^-15*Cos[0.017453292519943295*θ6]}, {-4.166666666666664*Sin[0.017453292519943295*θ6], 4.166666666666664*Cos[0.017453292519943295*θ6]}, {-8.333333333333329*Sin[0.017453292519943295*θ6], 8.333333333333329*Cos[0.017453292519943295*θ6]}, {-12.499999999999993*Sin[0.017453292519943295*θ6], 12.499999999999993*Cos[0.017453292519943295*θ6]}, {-16.666666666666657*Sin[0.017453292519943295*θ6], 16.666666666666657*Cos[0.017453292519943295*θ6]}, {-20.83333333333333*Sin[0.017453292519943295*θ6], 20.83333333333333*Cos[0.017453292519943295*θ6]}, {-24.999999999999993*Sin[0.017453292519943295*θ6], 24.999999999999993*Cos[0.017453292519943295*θ6]}, {5.*Cos[0.017453292519943295*θ6] - 25.*Sin[0.017453292519943295*θ6], 25.*Cos[0.017453292519943295*θ6] + 5.*Sin[0.017453292519943295*θ6]}, {5.*Cos[0.017453292519943295*θ6] - 20.833333333333336*Sin[0.017453292519943295*θ6], 20.833333333333336*Cos[0.017453292519943295*θ6] + 5.*Sin[0.017453292519943295*θ6]}, {5.*Cos[0.017453292519943295*θ6] - 16.666666666666668*Sin[0.017453292519943295*θ6], 16.666666666666668*Cos[0.017453292519943295*θ6] + 5.*Sin[0.017453292519943295*θ6]}, {5.*Cos[0.017453292519943295*θ6] - 12.500000000000002*Sin[0.017453292519943295*θ6], 12.500000000000002*Cos[0.017453292519943295*θ6] + 5.*Sin[0.017453292519943295*θ6]}, {5.*Cos[0.017453292519943295*θ6] - 8.333333333333336*Sin[0.017453292519943295*θ6], 8.333333333333336*Cos[0.017453292519943295*θ6] + 5.*Sin[0.017453292519943295*θ6]}, {5.*Cos[0.017453292519943295*θ6] - 4.166666666666671*Sin[0.017453292519943295*θ6], 4.166666666666671*Cos[0.017453292519943295*θ6] + 5.*Sin[0.017453292519943295*θ6]}, {5.*Cos[0.017453292519943295*θ6] - 3.552713678800501*^-15*Sin[0.017453292519943295*θ6], 3.552713678800501*^-15*Cos[0.017453292519943295*θ6] + 5.*Sin[0.017453292519943295*θ6]}, {5.*Cos[0.017453292519943295*θ6] + 4.166666666666664*Sin[0.017453292519943295*θ6], -4.166666666666664*Cos[0.017453292519943295*θ6] + 5.*Sin[0.017453292519943295*θ6]}, {5.*Cos[0.017453292519943295*θ6] + 8.333333333333329*Sin[0.017453292519943295*θ6], -8.333333333333329*Cos[0.017453292519943295*θ6] + 5.*Sin[0.017453292519943295*θ6]}, {5.*Cos[0.017453292519943295*θ6] + 12.499999999999993*Sin[0.017453292519943295*θ6], -12.499999999999993*Cos[0.017453292519943295*θ6] + 5.*Sin[0.017453292519943295*θ6]}, {5.*Cos[0.017453292519943295*θ6] + 16.666666666666657*Sin[0.017453292519943295*θ6], -16.666666666666657*Cos[0.017453292519943295*θ6] + 5.*Sin[0.017453292519943295*θ6]}, {5.*Cos[0.017453292519943295*θ6] + 20.83333333333333*Sin[0.017453292519943295*θ6], -20.83333333333333*Cos[0.017453292519943295*θ6] + 5.*Sin[0.017453292519943295*θ6]}, {5.*Cos[0.017453292519943295*θ6] + 24.999999999999993*Sin[0.017453292519943295*θ6], -24.999999999999993*Cos[0.017453292519943295*θ6] + 5.*Sin[0.017453292519943295*θ6]}, {25.*Sin[0.017453292519943295*θ6], -25.*Cos[0.017453292519943295*θ6]}}]; polygons163200200710102030139107 = Compile[{θ10}, {{-3.4695307063675926*Cos[0.017453292519943295*θ10] + 25.*Sin[0.017453292519943295*θ10], -25.*Cos[0.017453292519943295*θ10] - 3.4695307063675926*Sin[0.017453292519943295*θ10]}, {-2.395110992115619*Cos[0.017453292519943295*θ10] + 20.833333333333336*Sin[0.017453292519943295*θ10], -20.833333333333336*Cos[0.017453292519943295*θ10] - 2.395110992115619*Sin[0.017453292519943295*θ10]}, {-1.5255506406116837*Cos[0.017453292519943295*θ10] + 16.666666666666668*Sin[0.017453292519943295*θ10], -16.666666666666668*Cos[0.017453292519943295*θ10] - 1.5255506406116837*Sin[0.017453292519943295*θ10]}, {-0.85497354086813*Cos[0.017453292519943295*θ10] + 12.500000000000002*Sin[0.017453292519943295*θ10], -12.500000000000002*Cos[0.017453292519943295*θ10] - 0.85497354086813*Sin[0.017453292519943295*θ10]}, {-0.379001154506156*Cos[0.017453292519943295*θ10] + 8.333333333333336*Sin[0.017453292519943295*θ10], -8.333333333333336*Cos[0.017453292519943295*θ10] - 0.379001154506156*Sin[0.017453292519943295*θ10]}, {-0.09460345142782955*Cos[0.017453292519943295*θ10] + 4.166666666666671*Sin[0.017453292519943295*θ10], -4.166666666666671*Cos[0.017453292519943295*θ10] - 0.09460345142782955*Sin[0.017453292519943295*θ10]}, {0.*Cos[0.017453292519943295*θ10] + 3.552713678800501*^-15*Sin[0.017453292519943295*θ10], -3.552713678800501*^-15*Cos[0.017453292519943295*θ10] + 0.*Sin[0.017453292519943295*θ10]}, {-0.09460345142782955*Cos[0.017453292519943295*θ10] - 4.166666666666664*Sin[0.017453292519943295*θ10], 4.166666666666664*Cos[0.017453292519943295*θ10] - 0.09460345142782955*Sin[0.017453292519943295*θ10]}, {-0.379001154506156*Cos[0.017453292519943295*θ10] - 8.333333333333329*Sin[0.017453292519943295*θ10], 8.333333333333329*Cos[0.017453292519943295*θ10] - 0.379001154506156*Sin[0.017453292519943295*θ10]}, {-0.85497354086813*Cos[0.017453292519943295*θ10] - 12.499999999999993*Sin[0.017453292519943295*θ10], 12.499999999999993*Cos[0.017453292519943295*θ10] - 0.85497354086813*Sin[0.017453292519943295*θ10]}, {-1.5255506406116837*Cos[0.017453292519943295*θ10] - 16.666666666666657*Sin[0.017453292519943295*θ10], 16.666666666666657*Cos[0.017453292519943295*θ10] - 1.5255506406116837*Sin[0.017453292519943295*θ10]}, {-2.395110992115619*Cos[0.017453292519943295*θ10] - 20.83333333333333*Sin[0.017453292519943295*θ10], 20.83333333333333*Cos[0.017453292519943295*θ10] - 2.395110992115619*Sin[0.017453292519943295*θ10]}, {-3.4695307063675926*Cos[0.017453292519943295*θ10] - 24.999999999999993*Sin[0.017453292519943295*θ10], 24.999999999999993*Cos[0.017453292519943295*θ10] - 3.4695307063675926*Sin[0.017453292519943295*θ10]}, {6.469530706367593*Cos[0.017453292519943295*θ10] - 25.*Sin[0.017453292519943295*θ10], 25.*Cos[0.017453292519943295*θ10] + 6.469530706367593*Sin[0.017453292519943295*θ10]}, {5.395110992115619*Cos[0.017453292519943295*θ10] - 20.833333333333336*Sin[0.017453292519943295*θ10], 20.833333333333336*Cos[0.017453292519943295*θ10] + 5.395110992115619*Sin[0.017453292519943295*θ10]}, {4.525550640611684*Cos[0.017453292519943295*θ10] - 16.666666666666668*Sin[0.017453292519943295*θ10], 16.666666666666668*Cos[0.017453292519943295*θ10] + 4.525550640611684*Sin[0.017453292519943295*θ10]}, {3.85497354086813*Cos[0.017453292519943295*θ10] - 12.500000000000002*Sin[0.017453292519943295*θ10], 12.500000000000002*Cos[0.017453292519943295*θ10] + 3.85497354086813*Sin[0.017453292519943295*θ10]}, {3.379001154506156*Cos[0.017453292519943295*θ10] - 8.333333333333336*Sin[0.017453292519943295*θ10], 8.333333333333336*Cos[0.017453292519943295*θ10] + 3.379001154506156*Sin[0.017453292519943295*θ10]}, {3.0946034514278296*Cos[0.017453292519943295*θ10] - 4.166666666666671*Sin[0.017453292519943295*θ10], 4.166666666666671*Cos[0.017453292519943295*θ10] + 3.0946034514278296*Sin[0.017453292519943295*θ10]}, {3.*Cos[0.017453292519943295*θ10] - 3.552713678800501*^-15*Sin[0.017453292519943295*θ10], 3.552713678800501*^-15*Cos[0.017453292519943295*θ10] + 3.*Sin[0.017453292519943295*θ10]}, {3.0946034514278296*Cos[0.017453292519943295*θ10] + 4.166666666666664*Sin[0.017453292519943295*θ10], -4.166666666666664*Cos[0.017453292519943295*θ10] + 3.0946034514278296*Sin[0.017453292519943295*θ10]}, {3.379001154506156*Cos[0.017453292519943295*θ10] + 8.333333333333329*Sin[0.017453292519943295*θ10], -8.333333333333329*Cos[0.017453292519943295*θ10] + 3.379001154506156*Sin[0.017453292519943295*θ10]}, {3.85497354086813*Cos[0.017453292519943295*θ10] + 12.499999999999993*Sin[0.017453292519943295*θ10], -12.499999999999993*Cos[0.017453292519943295*θ10] + 3.85497354086813*Sin[0.017453292519943295*θ10]}, {4.525550640611684*Cos[0.017453292519943295*θ10] + 16.666666666666657*Sin[0.017453292519943295*θ10], -16.666666666666657*Cos[0.017453292519943295*θ10] + 4.525550640611684*Sin[0.017453292519943295*θ10]}, {5.395110992115619*Cos[0.017453292519943295*θ10] + 20.83333333333333*Sin[0.017453292519943295*θ10], -20.83333333333333*Cos[0.017453292519943295*θ10] + 5.395110992115619*Sin[0.017453292519943295*θ10]}, {6.469530706367593*Cos[0.017453292519943295*θ10] + 24.999999999999993*Sin[0.017453292519943295*θ10], -24.999999999999993*Cos[0.017453292519943295*θ10] + 6.469530706367593*Sin[0.017453292519943295*θ10]}, {-3.4695307063675926*Cos[0.017453292519943295*θ10] + 25.*Sin[0.017453292519943295*θ10], -25.*Cos[0.017453292519943295*θ10] - 3.4695307063675926*Sin[0.017453292519943295*θ10]}}])]

CAPTION

The planoconvex and planoconcave lenses assume a component medium of BK7 glass. Users may change the focal length and thickness with the sliders. Press the "+" next to the sliders for more details. The biconvex lens has a fixed focal length of 39 mm, an aperture of 50.8 mm with thickness of 28 mm, a design wavelength of 0.589 microns, and assumes a quartz medium. The biconcave lens has a focal length of -100.515 mm, an aperture of  50 mm, a thickness of 5 mm, and a fused silica medium. Move the lens components directly using the red and blue locators. The red locator moves the components in the x-y plane. The blue locator rotates the elements. Pull out the blue locator arrow for finer rotation. Try moving optical elements in and out of the path of light. The optical assembly that is shown consists of lines of rays, a light source, a planoconvex lens, a planoconcave lens, a biconvex lens, a biconcave lens,  two mirrors, and a screen. Users can also change the wavelength of the light source using the slider. This particular Demonstration assumes a visible light range of .4 to .7 microns.

DETAILS

This sample optics Demonstration was created using Optica 3, an application package available for Mathematica. It was created by selecting component elements and setting symbolic variables from the GUI popup menus. The variables that users select as symbolic become controllable with sliders and locators.

See http://www.opticasoftware.com for details about additional ray-tracing products.

THIS NOTEBOOK IS THE SOURCE CODE FROM

"Constructing A Simple Optical System" from the Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/ConstructingASimpleOpticalSystem/

Contributed by: Ann Williamson and Donald Barnhart (Optica Software, a division of iCyt™ Mission Technology)

A full-function Wolfram Mathematica system (Version 6 or higher) is required to edit this notebook.
GET WOLFRAM MATHEMATICA »

© Wolfram Demonstrations Project & Contributors   |   Terms of Use   |   Make a new version of this Demonstration »