Пример #1
0
        private void PaintLinearBench(Graphics g)
        {
            int radius = (int) circleRadius;
            DrawCircle(g, Pens.Blue, new Point(), radius);

            // draw the optical border
            g.DrawLine(new Pen(Color.Black, 4.0f), new Point(-radius, 0), new Point(radius, 0));

            double eta = Bench.RefractiveIndexAir / Bench.RefractiveIndexGlass;
            double criticalAngle = (eta > 1.0) ? Math.PI + Math.Asin(1 / eta) : Math.Asin(eta);
            SphericLens.Vector criticalAngleVector = new SphericLens.Vector() { Phi = criticalAngle, Radius = radius };
            Point criticalAnglePoint = SphericPointToFormsPoint(SphericLens.Point.FromVector(-criticalAngleVector));
            g.DrawLine(Pens.Red, new Point(), criticalAnglePoint);
            criticalAnglePoint.X *= -1;
            g.DrawLine(Pens.Red, new Point(), criticalAnglePoint);

            // draw the normal
            g.DrawLine(Pens.Brown, new Point(), new Point(0, (int)Bench.Normal.Radius));

            // draw the incomint ray
            g.DrawLine(Pens.Green, new Point(), SphericPointToFormsPoint(SphericLens.Point.FromVector(Bench.Direction)));

            // draw the refracted ray
            g.DrawLine(Pens.Blue, new Point(), SphericPointToFormsPoint(SphericLens.Point.FromVector(Bench.RefractedDirection)));
        }
Пример #2
0
        private void PaintLinearBench(Graphics g)
        {
            int radius = (int)circleRadius;

            DrawCircle(g, Pens.Blue, new Point(), radius);

            // draw the optical border
            g.DrawLine(new Pen(Color.Black, 4.0f), new Point(-radius, 0), new Point(radius, 0));


            double eta           = Bench.RefractiveIndexAir / Bench.RefractiveIndexGlass;
            double criticalAngle = (eta > 1.0) ? Math.PI + Math.Asin(1 / eta) : Math.Asin(eta);

            SphericLens.Vector criticalAngleVector = new SphericLens.Vector()
            {
                Phi = criticalAngle, Radius = radius
            };
            Point criticalAnglePoint = SphericPointToFormsPoint(SphericLens.Point.FromVector(-criticalAngleVector));

            g.DrawLine(Pens.Red, new Point(), criticalAnglePoint);
            criticalAnglePoint.X *= -1;
            g.DrawLine(Pens.Red, new Point(), criticalAnglePoint);

            // draw the normal
            g.DrawLine(Pens.Brown, new Point(), new Point(0, (int)Bench.Normal.Radius));

            // draw the incomint ray
            g.DrawLine(Pens.Green, new Point(), SphericPointToFormsPoint(SphericLens.Point.FromVector(Bench.Direction)));

            // draw the refracted ray
            g.DrawLine(Pens.Blue, new Point(), SphericPointToFormsPoint(SphericLens.Point.FromVector(Bench.RefractedDirection)));
        }
Пример #3
0
 private void rayOriginPhiNumericUpDown_ValueChanged(object sender, EventArgs e)
 {
     SphericLens.Vector originAsVector = SphericLens.Vector.FromPoint(Bench.IncidentRay.Origin);
     originAsVector.Phi         = (double)rayOriginPhiNumericUpDown.Value;
     Bench.IncidentRay.Origin.X = originAsVector.X;
     Bench.IncidentRay.Origin.Y = originAsVector.Y;
     updateBench();
 }
Пример #4
0
 public Form1()
 {
     InitializeComponent();
     Bench = MakeDoubleGaussLens();
     //Bench.Elements.Convex = false;
     Bench.IncidentRay = new SphericLens.Ray(new SphericLens.Point(200, 20), new SphericLens.Vector(-20, 5));
     //this.KeyDown += new KeyEventHandler(pictureResult.KeyPressed);
     rayDirectionPhiNumericUpDown.Value = (decimal)(Bench.IncidentRay.Direction.Phi % (2 * Math.PI));
     SphericLens.Vector originAsVector = SphericLens.Vector.FromPoint(Bench.IncidentRay.Origin);
     rayOriginPhiNumericUpDown.Value    = (decimal)originAsVector.Phi;
     rayOriginRadiusNumericUpDown.Value = (decimal)originAsVector.Radius;
 }
Пример #5
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)));
        }