コード例 #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();
        }
コード例 #2
0
        private void Recompute()
        {
            if (!initialized)
            {
                return;
            }

            directionPhi = (double)rayDirectionPhiNumeric.Value;
            if (inputLensPosDirectly)
            {
                incomingRay.Origin    = GetVectorFromControls(rayOriginXNumeric, rayOriginYNumeric, rayOriginZNumeric);
                incomingRay.Direction = new Vector3d(Math.Sin(directionPhi), 0, Math.Cos(directionPhi));
            }
            else
            {
                //// compute lens position from lens position parameter
                //// (with Y = 0)
                //double lensPosV = 0.5;
                //lensPosU = (double)lensPosTNumeric.Value;
                //if (lensPosU > 1.0)
                //{
                //    lensPosU = 2.0 - lensPosU;
                //    lensPosV = 0.0;
                //}
                //incomingRay = complexLens.ConvertParametersToBackSurfaceRay(
                //    new LensRayTransferFunction.Parameters(
                //        lensPosU, lensPosV, directionPhi, 0));
                ////Console.WriteLine("IN: {0}", incomingRay);
                var incomingParams = GetIncomingParams();
                incomingRay = complexLens.ConvertParametersToBackSurfaceRay(incomingParams);
            }

            intersections = new List <Vector3d>();
            outgoingRay   = complexLens.TransferDebug(incomingRay, out intersections, true);
            if (!inputLensPosDirectly)
            {
                backLensPos = incomingRay.Origin;
                //Console.WriteLine("OUT: {0}", outgoingRay);
            }
            else
            {
                if (outgoingRay != null)
                {
                    Intersection backInt = complexLens.Intersect(incomingRay);
                    backLensPos = backInt.Position;
                }
                else
                {
                    backLensPos = Vector3d.Zero;
                }
            }
            drawingYProjectionPanel.Invalidate();
            drawingXProjectionPanel.Invalidate();
            drawingZProjectionPanel.Invalidate();
        }
コード例 #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);
        }