Esempio n. 1
0
        private void Recompute()
        {
            if (!initialized)
            {
                return;
            }

            incomingRay.Origin = GetVectorFromControls(rayOriginXNumeric, rayOriginYNumeric, rayOriginZNumeric);
            double directionPhi = (double)rayDirectionPhiNumeric.Value;

            incomingRay.Direction = new Vector3d(Math.Sin(directionPhi), 0, Math.Cos(directionPhi));

            Intersection backInt = biconvexLens.Intersect(incomingRay);

            if (backInt != null)
            {
                outgoingRay = biconvexLens.Transfer(incomingRay.Origin, backInt.Position);
                backLensPos = backInt.Position;
            }
            else
            {
                outgoingRay = null;
                backLensPos = Vector3d.Zero;
            }
            backInt = complexLens.Intersect(incomingRay);
            if (backInt != null)
            {
                complexOutgoingRay = complexLens.Transfer(incomingRay.Origin, backInt.Position);
            }
            else
            {
                complexOutgoingRay = null;
            }
            drawingPanel.Invalidate();
        }
Esempio n. 2
0
        public void TraceRays()
        {
            ComplexLens lens = ComplexLens.CreateBiconvexLens(4, 2, 0);

            Sampler  sampler         = new Sampler();
            int      sampleCount     = 64;
            int      sqrtSampleCount = (int)Math.Sqrt(sampleCount);
            Vector3d objectPos       = new Vector3d(10, 0, 100);

            foreach (Vector2d sample in sampler.GenerateJitteredSamples(sqrtSampleCount))
            {
                Vector3d lensPos = lens.GetBackSurfaceSample(sample);
                Ray      result  = lens.Transfer(objectPos, lensPos);
            }
        }
Esempio n. 3
0
        public void TraceSingleRay()
        {
            ComplexLens lens = ComplexLens.CreateBiconvexLens(4, 2, 0);

            Sampler      sampler         = new Sampler();
            int          sampleCount     = 64;
            int          sqrtSampleCount = (int)Math.Sqrt(sampleCount);
            Vector3d     objectPos       = new Vector3d(10, 0, 100);
            Vector3d     direction       = new Vector3d(0, 0, 0);
            Ray          ray             = new Ray(objectPos, direction);
            Intersection isec            = lens.Intersect(ray);

            if (isec == null)
            {
                return;
            }
            Ray result = lens.Transfer(objectPos, isec.Position);
        }