public void CompareInterpolatedLrtfValueWithOriginalOnes()
        {
            ComplexLens lens = ComplexLens.CreateDoubleGaussLens(Materials.Fixed.AIR, 4.0);
            LensRayTransferFunction lrtf = new LensRayTransferFunction(lens);

            int sampleCount = 128;
            string filename = string.Format(@"data\lrtf_double_gauss_{0}.bin", sampleCount);
            var table = lrtf.SampleLrtf3DCached(sampleCount, filename);

            Random random = new Random();
            for (int i = 0; i < 1000; i++)
            {
                var incomingParams = new LensRayTransferFunction.Parameters(
                    random.NextDouble(), random.NextDouble(),
                    random.NextDouble(), random.NextDouble()
                    );
                var outgoingParamsOriginal = lrtf.ComputeLrtf(incomingParams).ToVector4d();
                var outgoingParamsInterpolated = table.EvaluateLrtf3D(incomingParams).ToVector4d();
                //AssertEqualVector4d(outgoingParamsOriginal, outgoingParamsInterpolated);
            }
        }
        public void CompareEvaluationTime()
        {
            ComplexLens lens = ComplexLens.CreateDoubleGaussLens(Materials.Fixed.AIR, 4.0);
            LensRayTransferFunction lrtf = new LensRayTransferFunction(lens);

            int sampleCount = 128;
            Console.WriteLine("LRTF table size: {0}x{0}x{0}", sampleCount);
            string filename = string.Format(@"data\lrtf_double_gauss_{0}.bin", sampleCount);
            var table = lrtf.SampleLrtf3DCached(sampleCount, filename);

            int valueCount = 1000000;
            Console.WriteLine("Number of values to evaluate: {0}", valueCount);

            Random random = new Random();
            var inParams = new List<LensRayTransferFunction.Parameters>();
            for (int i = 0; i < valueCount; i++)
            {
                inParams.Add(new LensRayTransferFunction.Parameters(
                    random.NextDouble(), random.NextDouble(),
                    random.NextDouble(), random.NextDouble()
                    ));
            }
            Stopwatch stopwatch = Stopwatch.StartNew();
            foreach (var inParam in inParams)
            {
                lrtf.ComputeLrtf(inParam);
            }
            stopwatch.Stop();
            Console.WriteLine("Ray tracing: {0} ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Reset();
            stopwatch.Start();
            foreach (var inParam in inParams)
            {
                table.EvaluateLrtf3D(inParam);
            }
            stopwatch.Stop();
            Console.WriteLine("LRTF table interpolation: {0} ms", stopwatch.ElapsedMilliseconds);
        }
 public void ComputeLrtfForRandomInput()
 {
     ComplexLens lens = ComplexLens.CreateDoubleGaussLens(Materials.Fixed.AIR, 4.0);
     LensRayTransferFunction lrtf = new LensRayTransferFunction(lens);
     Random random = new Random();
     for (int i = 0; i < 1000; i++)
     {
         var incomingParams = new LensRayTransferFunction.Parameters(
             random.NextDouble(), random.NextDouble(),
             random.NextDouble(), random.NextDouble()
             );
         LensRayTransferFunction.Parameters outgoingParams = lrtf.ComputeLrtf(incomingParams);
         if (outgoingParams != null)
         {
             if (outgoingParams.DirectionTheta < 0 || outgoingParams.DirectionTheta > 1 ||
                 outgoingParams.DirectionPhi < 0 || outgoingParams.DirectionPhi > 1 ||
                 outgoingParams.PositionTheta < 0 || outgoingParams.PositionTheta > 1 ||
                 outgoingParams.PositionPhi < 0 || outgoingParams.PositionPhi > 1)
             {
                 Console.WriteLine("Warning: parameter outside [0; 1] interval.");
                 Console.WriteLine("incoming: {0}", incomingParams);
                 Console.WriteLine("outgoing: {0}", outgoingParams);
                 Console.WriteLine();
             }
             //Assert.InRange(outgoingParams.DirectionTheta, 0.0, 1.0);
             //Assert.InRange(outgoingParams.DirectionPhi, 0.0, 1.0);
             //Assert.InRange(outgoingParams.PositionTheta, 0.0, 1.0);
             //Assert.InRange(outgoingParams.PositionPhi, 0.0, 1.0);
         }
     }
 }
 public void ComputeLrtf()
 {
     ComplexLens lens = ComplexLens.CreateDoubleGaussLens(Materials.Fixed.AIR, 4.0);
     LensRayTransferFunction lrtf = new LensRayTransferFunction(lens);
     var incomingParams = new LensRayTransferFunction.Parameters(0.5, 0.5, 0.7000000000000004, 0.0);
     LensRayTransferFunction.Parameters outgoingParams = lrtf.ComputeLrtf(incomingParams);
     Console.WriteLine("IN: {0}", incomingParams);
     Console.WriteLine("OUT: {0}", outgoingParams);
     if (outgoingParams != null)
     {
         Console.WriteLine("  {0}", lens.ConvertParametersToFrontSurfaceRay(outgoingParams));
     }
 }
 public void ComputeLrtfResultInCorrectInterval()
 {
     ComplexLens lens = ComplexLens.CreateDoubleGaussLens(Materials.Fixed.AIR, 4.0);
     LensRayTransferFunction lrtf = new LensRayTransferFunction(lens);
     var incomingParams = new LensRayTransferFunction.Parameters(0.835057026164167, 0.375245163857585, 0.854223355117358, 0.000161428470239708);
     LensRayTransferFunction.Parameters outgoingParams = lrtf.ComputeLrtf(incomingParams);
     Console.WriteLine(outgoingParams);
 }