Beispiel #1
0
        private void DrawSphericalCap(Graphics g, SphericLens.SphericalCap cap)
        {
            float angle      = (float)(cap.Angle * 180.0 / Math.PI);
            float startAngle = (cap.Convex ? 360.0f : 180.0f) - angle;
            float sweepAngle = 2.0f * angle;

            g.DrawArc(Pens.Red, (float)-cap.Radius, (float)-cap.Radius, (float)(2 * cap.Radius), (float)(2 * cap.Radius), startAngle, sweepAngle);

            //float x = (float)((cap.Convex ? cap.Radius : -cap.Radius) - (cap.Convex ? cap.Thickness : -cap.Thickness));
            //float y = (float)cap.Aperture;
            //g.DrawLine(Pens.Black, x, -y, x, y);
        }
Beispiel #2
0
        private void PaintSphericBench(Graphics g)
        {
            // draw a circlular lens
            //DrawCircle(g, Pens.Blue, new Point(), (float)Bench.Elements.Radius);

            g.TranslateTransform((float)-Bench.LensCenter, 0.0f);
            double translation = 0.0;

            foreach (SphericLens.OpticalElement element in Bench.Elements)
            {
                if (element is SphericLens.SphericalCap)
                {
                    SphericLens.SphericalCap cap = (SphericLens.SphericalCap)element;
                    double signedRadius          = (cap.Convex ? 1.0 : -1.0) * cap.Radius;
                    g.TranslateTransform((float)-(translation + signedRadius), 0.0f);
                    DrawSphericalCap(g, cap);
                    g.TranslateTransform((float)(translation + signedRadius), 0.0f);
                }
                translation += element.DistanceToNext;
            }
            g.TranslateTransform((float)Bench.LensCenter, 0.0f);

            SphericLens.Ray lastOutgoingRay = Bench.IncidentRay;

            foreach (SphericLens.OpticalBench.IntersectionResult intersectionResult in Bench.IntersectionResults)
            {
                lastOutgoingRay = intersectionResult.OutgoingRay;
                // draw a ray and its intersection
                Point intersection = SphericPointToFormsPoint(intersectionResult.Intersection);
                Point origin       = SphericPointToFormsPoint(intersectionResult.IncidentRay.Origin);
                g.DrawLine(Pens.Green, origin, intersection);

                // draw normal
                SphericLens.Vector normal = intersectionResult.Normal.Normalize() * 20.0;
                g.DrawLine(Pens.Brown, intersection, SphericPointToFormsPoint(intersectionResult.Intersection + normal));

                FillSquare(g, Brushes.Red, intersection, 3);
            }

            g.DrawLine(Pens.Orange,
                       SphericPointToFormsPoint(lastOutgoingRay.Origin),
                       SphericPointToFormsPoint(lastOutgoingRay.Evaluate(100)));
        }
Beispiel #3
0
 private SphericLens.OpticalBench MakeBiconvexLens()
 {
     SphericLens.OpticalBench bench = new SphericLens.OpticalBench();
     // bench.LensCenter = -100.0;
     SphericLens.SphericalCap element0 = new SphericLens.SphericalCap()
     {
         Convex              = true,
         Radius              = 150.0,
         Aperture            = 100.0,
         NextRefractiveIndex = SphericLens.RefractiveIndices.CROWN_GLASS,
     };
     bench.Elements.Add(element0);
     element0.DistanceToNext = 2 * element0.Thickness;
     bench.Elements.Add(
         new SphericLens.SphericalCap()
     {
         Convex              = false,
         Radius              = 150.0,
         Aperture            = 100.0,
         NextRefractiveIndex = SphericLens.RefractiveIndices.AIR,
     }
         );
     return(bench);
 }
Beispiel #4
0
        private SphericLens.OpticalBench MakeDoubleGaussLens()
        {
            SphericLens.OpticalBench bench = new SphericLens.OpticalBench();
            // bench.LensCenter = -100.0;
            bench.Elements.Add(
                new SphericLens.SphericalCap()
            {
                Convex              = true,
                Radius              = 58.950,
                DistanceToNext      = 7.520,
                NextRefractiveIndex = 1.670,
                Aperture            = 50.4,
            }
                );
            bench.Elements.Add(
                new SphericLens.SphericalCap()
            {
                Convex              = true,
                Radius              = 169.660,
                DistanceToNext      = 0.240,
                NextRefractiveIndex = SphericLens.RefractiveIndices.AIR,
                Aperture            = 50.4,
            }
                );
            bench.Elements.Add(
                new SphericLens.SphericalCap()
            {
                Convex              = true,
                Radius              = 38.550,
                DistanceToNext      = 8.050,
                NextRefractiveIndex = 1.670,
                Aperture            = 46.0,
            }
                );
            bench.Elements.Add(
                new SphericLens.SphericalCap()
            {
                Convex              = true,
                Radius              = 81.540,
                DistanceToNext      = 6.550,
                NextRefractiveIndex = 1.699,
                Aperture            = 46.0,
            }
                );
            bench.Elements.Add(
                new SphericLens.SphericalCap()
            {
                Convex              = true,
                Radius              = 25.500,
                DistanceToNext      = 11.410 + 9.0,
                NextRefractiveIndex = SphericLens.RefractiveIndices.AIR,
                Aperture            = 36.0,
            }
                );
            bench.Elements.Add(
                new SphericLens.CircularStop()
            {
                DistanceToNext      = 9.0,
                NextRefractiveIndex = SphericLens.RefractiveIndices.AIR,
                Aperture            = 34.2,
            }
                );
            bench.Elements.Add(
                new SphericLens.SphericalCap()
            {
                Convex              = false,
                Radius              = 28.990,
                DistanceToNext      = 2.360,
                NextRefractiveIndex = 1.603,
                Aperture            = 34.0,
            }
                );
            bench.Elements.Add(
                new SphericLens.SphericalCap()
            {
                Convex              = true,
                Radius              = 81.540,
                DistanceToNext      = 12.130,
                NextRefractiveIndex = 1.658,
                Aperture            = 40.0,
            }
                );
            bench.Elements.Add(
                new SphericLens.SphericalCap()
            {
                Convex              = false,
                Radius              = 40.770,
                DistanceToNext      = 0.380,
                NextRefractiveIndex = SphericLens.RefractiveIndices.AIR,
                Aperture            = 40.0,
            }
                );
            bench.Elements.Add(
                new SphericLens.SphericalCap()
            {
                Convex              = true,
                Radius              = 874.130,
                DistanceToNext      = 6.440,
                NextRefractiveIndex = 1.717,
                Aperture            = 40.0,
            }
                );
            bench.Elements.Add(
                new SphericLens.SphericalCap()
            {
                Convex = false,
                Radius = 79.460,
                NextRefractiveIndex = SphericLens.RefractiveIndices.AIR,
                Aperture            = 40.0,
            }
                );
            double scaleFactor = 3.0;
            bool   aperturesGivenAsDiameter = true;

            foreach (SphericLens.OpticalElement element in bench.Elements)
            {
                double apertureScaleFactor = scaleFactor * (aperturesGivenAsDiameter ? 0.5 : 1.0);
                // TODO: hey, this is ugly!!!
                if (element is SphericLens.SphericalCap)
                {
                    SphericLens.SphericalCap cap = element as SphericLens.SphericalCap;
                    cap.Radius   *= scaleFactor;
                    cap.Aperture *= apertureScaleFactor;
                }
                else if (element is SphericLens.CircularStop)
                {
                    SphericLens.CircularStop stop = element as SphericLens.CircularStop;
                    stop.Aperture *= apertureScaleFactor;
                }
                element.DistanceToNext *= scaleFactor;
            }
            return(bench);
        }
Beispiel #5
0
 private SphericLens.OpticalBench MakeBiconvexLens()
 {
     SphericLens.OpticalBench bench = new SphericLens.OpticalBench();
     // bench.LensCenter = -100.0;
     SphericLens.SphericalCap element0 = new SphericLens.SphericalCap()
         {
             Convex = true,
             Radius = 150.0,
             Aperture = 100.0,
             NextRefractiveIndex = SphericLens.RefractiveIndices.CROWN_GLASS,
         };
     bench.Elements.Add(element0);
     element0.DistanceToNext = 2 * element0.Thickness;
     bench.Elements.Add(
         new SphericLens.SphericalCap()
         {
             Convex = false,
             Radius = 150.0,
             Aperture = 100.0,
             NextRefractiveIndex = SphericLens.RefractiveIndices.AIR,
         }
     );
     return bench;
 }