Example #1
0
        /// <summary>
        /// Required parameters:
        /// (Location) lens_plano_center,
        /// (double) lens_sphere_radius
        /// (double) lens_sphere_radians_min
        /// (double) lens_sphere_radians_max
        /// (double) angle_rings   double value instead of int, so the ring may end in a ring-fraction
        /// (UnitVector) orientation_from_sphere_center
        /// </summary>
        /// <param name='shadowObject'>
        /// Shadow object containing parameters from summary.
        /// </param>
        protected void shadowFac_SphereRadius_and_EqualAngleRings(ShadowScientrace.ShadowObject3d shadowObject)
        {
            //User values(s)
            //NOT USED: Scientrace.Location lens_plano_center = (Scientrace.Location)shadowObject.getObject("lens_plano_center");
            //NOT USED: double lens_sphere_radius = (double)shadowObject.getObject("lens_sphere_radius");
            double lens_sphere_radians_min = (double)shadowObject.getObject("lens_sphere_radians_min");
            double lens_sphere_radians_max = (double)shadowObject.getObject("lens_sphere_radians_max");
            //NOT USED: Scientrace.UnitVector orientation_from_sphere_center = (Scientrace.UnitVector)shadowObject.getObject("orientation_from_sphere_center");

            double angle_rings = (double)shadowObject.getObject("angle_rings_count");
            double ringcount   = angle_rings;


            //construct by creating FresnelLensRing Object3D instances and adding them to collection
            for (double iring = 0; iring <= ringcount - 1; iring += 1)
            {
                ShadowScientrace.ShadowObject3d so3d = new ShadowScientrace.ShadowObject3d(shadowObject);
                so3d.factory_id = "PlanoCenterAndRadians";
                double dradians = lens_sphere_radians_max - lens_sphere_radians_min;

                so3d.arguments["lens_sphere_radians_min"] = (dradians * (iring / ringcount)) + lens_sphere_radians_min;
                so3d.arguments["lens_sphere_radians_max"] = (dradians * (Math.Min((iring + 1) / ringcount, 1))) + lens_sphere_radians_min;

                so3d.parent = this;
                new FresnelLensRing(so3d);
            }
        }
        /// <summary>
        /// Required parameters:
        /// (Location) lens_plano_center,
        /// (double) lens_sphere_radius
        /// (double) lens_sphere_radians_min
        /// (double) lens_sphere_radians_max
        /// (UnitVector) orientation_from_sphere_center
        /// </summary>
        /// <param name='shadowObject'>
        /// Shadow object containing parameters from summary.
        /// </param>
        protected void shadowFac_PlanoCenter_And_Radians(ShadowScientrace.ShadowObject3d shadowObject)
        {
            //User values(s)
            Scientrace.Location lens_plano_center = (Scientrace.Location)shadowObject.getObject("lens_plano_center");
            double lens_sphere_radius             = (double)shadowObject.getObject("lens_sphere_radius");
            double lens_sphere_radians_min        = (double)shadowObject.getObject("lens_sphere_radians_min");
            double lens_sphere_radians_max        = (double)shadowObject.getObject("lens_sphere_radians_max");

            Scientrace.UnitVector orientation_from_sphere_center = (Scientrace.UnitVector)shadowObject.getObject("orientation_from_sphere_center");
            bool double_convex_ring = shadowObject.getNBool("double_convex") == true;

            //Derived value(s)
            Scientrace.Location lens_sphere_location = lens_plano_center -
                                                       (orientation_from_sphere_center * lens_sphere_radius * Math.Cos(lens_sphere_radians_max));

            /*double rmin = Math.Sin(lens_sphere_radians_min)*lens_sphere_radius;
             * double rmax = Math.Sin(lens_sphere_radians_max)*lens_sphere_radius;
             * Console.WriteLine("Ring got radius "+lens_sphere_radius+" at"+lens_sphere_location+" radmin/max:{"+lens_sphere_radians_min+"}/{"+lens_sphere_radians_max+"}.");
             * Console.WriteLine("Ring got rmin/rmax "+rmin+" / "+rmax); */


            //Console.WriteLine("Lens sphere: "+lens_sphere_location.tricon()+" Plano center: "+lens_plano_center.trico());
            //construct!
            this.paramInit(lens_sphere_location, lens_sphere_radius, lens_sphere_radians_min, lens_sphere_radians_max,
                           orientation_from_sphere_center, double_convex_ring);
        }
Example #3
0
        /// <summary>
        /// Required parameters:
        /// (Location) lens_plano_center,
        /// (double) lens_sphere_radius
        /// (double) lens_sphere_radians_min
        /// (double) lens_sphere_radians_max
        /// (double) width_rings   double value instead of int, so the ring may end in a ring-fraction
        /// (UnitVector) orientation_from_sphere_center
        /// </summary>
        /// <param name='shadowObject'>
        /// Shadow object containing parameters from summary.
        /// </param>
        protected void shadowFac_SphereRadius_and_EqualWidthRings(ShadowScientrace.ShadowObject3d shadowObject)
        {
            //Console.WriteLine("CREATING EQUAL WIDTH RINGS");
            //User values(s)
            //NOT USED: Scientrace.Location lens_plano_center = (Scientrace.Location)shadowObject.getObject("lens_plano_center");
            //NOT USED: double lens_sphere_radius = (double)shadowObject.getObject("lens_sphere_radius");
            double lens_sphere_radians_min = (double)shadowObject.getObject("lens_sphere_radians_min");
            double lens_sphere_radians_max = (double)shadowObject.getObject("lens_sphere_radians_max");
            //NOT USED: Scientrace.UnitVector orientation_from_sphere_center = (Scientrace.UnitVector)shadowObject.getObject("orientation_from_sphere_center");

            double width_rings = (double)shadowObject.getObject("width_rings_count");
            double ringcount   = width_rings;

            //construct by creating FresnelLensRing Object3D instances and adding them to collection
            for (double iring = 0; iring <= ringcount - 1; iring += 1)
            {
                ShadowScientrace.ShadowObject3d so3d = new ShadowScientrace.ShadowObject3d(shadowObject);

                //Console.WriteLine("Radius "+iring+ ": {"+so3d.arguments["lens_sphere_radius"]+"}");

                so3d.factory_id = "PlanoCenterAndRadians";
                double dsin = Math.Sin(lens_sphere_radians_max) - Math.Sin(lens_sphere_radians_min);
                so3d.arguments["lens_sphere_radians_min"] = Math.Asin((dsin * (iring / ringcount)) + Math.Sin(lens_sphere_radians_min));
                so3d.arguments["lens_sphere_radians_max"] = Math.Asin((dsin * Math.Min((iring + 1) / ringcount, 1)) + Math.Sin(lens_sphere_radians_min));
                so3d.parent = this;
                new FresnelLensRing(so3d);
            }
        }
Example #4
0
        /// <summary>
        /// Required parameters:
        /// (Location)sphere1_center_loc
        /// (Location)sphere2_center_loc
        /// (double)sphere1_radius
        /// (double)sphere2_radius
        /// </summary>
        /// <param name='shadowObject'>
        /// Shadow object containing parameters from summary.
        /// </param>
        protected void shadowFac_TwoRadii_and_Locations(ShadowScientrace.ShadowObject3d shadowObject)
        {
            //User values(s)
            Scientrace.Location sphere1CenterLoc = (Scientrace.Location)shadowObject.getObject("sphere1_center_loc");
            Scientrace.Location sphere2CenterLoc = (Scientrace.Location)shadowObject.getObject("sphere2_center_loc");
            double sphere1Radius = (double)shadowObject.getObject("sphere1_radius");
            double sphere2Radius = (double)shadowObject.getObject("sphere2_radius");

            this.paramInit(sphere1CenterLoc, sphere1Radius, sphere2CenterLoc, sphere2Radius);
        }
Example #5
0
        public FresnelLens(ShadowScientrace.ShadowObject3d lensShadowObject)
            : base(lensShadowObject)
        {
            ShadowScientrace.ShadowObject3d ringTemplateSO3D = new ShadowScientrace.ShadowObject3d(lensShadowObject);
            ringTemplateSO3D.materialprops = (Scientrace.MaterialProperties)ringTemplateSO3D.getObject("lens_material");

            if (ringTemplateSO3D.hasArgument("FocalVector")) {

            }

            //Setting Sphere Radius (if not provided) from Focal Length
            if (ringTemplateSO3D.hasArgument("focal_length") && !ringTemplateSO3D.hasArgument("lens_sphere_radius")) {
            double focal_length = (double)ringTemplateSO3D.getObject("focal_length");

            double sphere_radius = FresnelLens.getRadius(focal_length, ringTemplateSO3D.materialprops.refractiveindex(600E-9),
                                        ringTemplateSO3D.getNBool("double_convex"));
            ringTemplateSO3D.arguments["lens_sphere_radius"] = sphere_radius;
            }

            //Setting Sphere Radius (if not provided) from Focal Length
            if (ringTemplateSO3D.hasArgument("lens_radius")
                && ringTemplateSO3D.hasArgument("lens_sphere_radius")
                &&!ringTemplateSO3D.hasArgument("lens_sphere_radians_max")) {
            double lens_radius = (double)ringTemplateSO3D.getObject("lens_radius");
            double sphere_radius  = (double)ringTemplateSO3D.getObject("lens_sphere_radius");

            // VarRings can have larger radii. Will throw an error upon calculating the ring sphere radius later on if necessary.
            if ((ringTemplateSO3D.factory_id != "VarRings") && (sphere_radius < lens_radius))
                throw new ArgumentOutOfRangeException("Cannot create a lens with radius "+lens_radius+" from sphere with radius: "+sphere_radius+
                    " possibly constructed from focal length: "+ringTemplateSO3D.printArgument("focal_length")+"{"+ringTemplateSO3D.factory_id);

            double lens_sphere_radians_max = Math.Asin(lens_radius/sphere_radius);
            //Console.WriteLine("sphere radius: "+sphere_radius+"  lens radius: "+lens_radius);
            ringTemplateSO3D.arguments["lens_sphere_radians_min"] = 0.0;
            ringTemplateSO3D.arguments["lens_sphere_radians_max"] = lens_sphere_radians_max;
            }

            switch (ringTemplateSO3D.factory_id) {
            case "EqualHeightRings":
                this.shadowFac_SphereRadius_and_EqualHeightRings(ringTemplateSO3D);
                break;
            case "EqualWidthRings":
                this.shadowFac_SphereRadius_and_EqualWidthRings(ringTemplateSO3D);
                break;
            case "VarRings":
                this.shadowFac_VariusRadii_and_EqualWidthRings(ringTemplateSO3D);
                break;
            case "EqualAngleRings":
                this.shadowFac_SphereRadius_and_EqualAngleRings(ringTemplateSO3D);
                break;
            default:
                throw new ArgumentOutOfRangeException("Factory id {"+ringTemplateSO3D.factory_id+"} not found for "+ringTemplateSO3D.typeString());
            }
        }
Example #6
0
        /// <summary>
        /// Required parameters:
        /// (Location)lens_center
        /// (NonzeroVector)optical_axis
        /// (double)lens_diameter
        /// (double)sphere1_radius
        /// (double)sphere2_radius
        /// </summary>
        /// <param name='shadowObject'>
        /// Shadow object containing parameters from summary.
        /// </param>
        protected void shadowFac_TwoRadii_and_Diameter(ShadowScientrace.ShadowObject3d shadowObject)
        {
            //User values(s)
            Scientrace.Location      lensCenter  = (Scientrace.Location)shadowObject.getObject("lens_center");
            Scientrace.NonzeroVector opticalAxis = (Scientrace.NonzeroVector)shadowObject.getObject("optical_axis");

            double lensDiameter  = (double)shadowObject.getObject("lens_diameter");
            double sphere1Radius = (double)shadowObject.getObject("sphere1_radius");
            double sphere2Radius = (double)shadowObject.getObject("sphere2_radius");

            this.initWithLensDiameter(lensCenter, opticalAxis, lensDiameter, sphere1Radius, sphere2Radius);
        }
        /// <summary>
        /// Required parameters:
        /// (Location) lens_sphere_location,
        /// (double) lens_sphere_radius
        /// (double) lens_sphere_radians_min
        /// (double) lens_sphere_radians_max
        /// (UnitVector) orientation_from_sphere_center
        /// </summary>
        /// <param name='shadowObject'>
        /// Shadow object containing parameters from summary.
        /// </param>
        protected void shadowFac_SphereCenter_And_Radians(ShadowScientrace.ShadowObject3d shadowObject)
        {
            //User values(s)
            Scientrace.Location lens_sphere_location = (Scientrace.Location)shadowObject.getObject("lens_sphere_location");
            double lens_sphere_radius      = (double)shadowObject.getObject("lens_sphere_radius");
            double lens_sphere_radians_min = (double)shadowObject.getObject("lens_sphere_radians_min");
            double lens_sphere_radians_max = (double)shadowObject.getObject("lens_sphere_radians_max");

            Scientrace.UnitVector orientation_from_sphere_center = (Scientrace.UnitVector)shadowObject.getObject("orientation_from_sphere_center");
            bool double_convex_ring = shadowObject.getNBool("double_convex") == true;

            //construct!
            this.paramInit(lens_sphere_location, lens_sphere_radius, lens_sphere_radians_min,
                           lens_sphere_radians_max, orientation_from_sphere_center, double_convex_ring);
        }
Example #8
0
        /// <summary>
        /// Required parameters:
        /// (double)focal_length
        /// (Location)lens_center
        /// (NonzeroVector)optical_axis
        /// (double)lens_diameter
        /// </summary>
        /// <param name='shadowObject'>
        /// Shadow object containing parameters from summary.
        /// </param>
        protected void shadowFac_FocalLength_and_Diameter(ShadowScientrace.ShadowObject3d shadowObject)
        {
            //User values(s)
            double focalLength = (double)shadowObject.getObject("focal_length");

            Scientrace.Location      lensCenter      = (Scientrace.Location)shadowObject.getObject("lens_center");
            Scientrace.NonzeroVector lensPlaneNormal = (Scientrace.NonzeroVector)shadowObject.getObject("optical_axis");
            double lensDiameter = (double)shadowObject.getObject("lens_diameter");

            //Derived value from 1/f = (n-1)(1/r1+1/r2)
            double focus_wavelength = shadowObject.getDouble("focus_wavelength", 600E-9);
            double sphereRadii      = 2 * focalLength * (shadowObject.materialprops.refractiveindex(focus_wavelength) - 1);

            //construct!
            this.initWithLensDiameter(lensCenter, lensPlaneNormal, lensDiameter, sphereRadii, sphereRadii);
        }
Example #9
0
        public FresnelLens(ShadowScientrace.ShadowObject3d lensShadowObject) : base(lensShadowObject)
        {
            ShadowScientrace.ShadowObject3d ringTemplateSO3D = new ShadowScientrace.ShadowObject3d(lensShadowObject);
            ringTemplateSO3D.materialprops = (Scientrace.MaterialProperties)ringTemplateSO3D.getObject("lens_material");


            if (ringTemplateSO3D.hasArgument("FocalVector"))
            {
            }


            //Setting Sphere Radius (if not provided) from Focal Length
            if (ringTemplateSO3D.hasArgument("focal_length") && !ringTemplateSO3D.hasArgument("lens_sphere_radius"))
            {
                double focal_length = (double)ringTemplateSO3D.getObject("focal_length");

                double sphere_radius = FresnelLens.getRadius(focal_length, ringTemplateSO3D.materialprops.refractiveindex(600E-9),
                                                             ringTemplateSO3D.getNBool("double_convex"));
                ringTemplateSO3D.arguments["lens_sphere_radius"] = sphere_radius;
            }

            //Setting Sphere Radius (if not provided) from Focal Length
            if (ringTemplateSO3D.hasArgument("lens_radius") &&
                ringTemplateSO3D.hasArgument("lens_sphere_radius") &&
                !ringTemplateSO3D.hasArgument("lens_sphere_radians_max"))
            {
                double lens_radius   = (double)ringTemplateSO3D.getObject("lens_radius");
                double sphere_radius = (double)ringTemplateSO3D.getObject("lens_sphere_radius");

                // VarRings can have larger radii. Will throw an error upon calculating the ring sphere radius later on if necessary.
                if ((ringTemplateSO3D.factory_id != "VarRings") && (sphere_radius < lens_radius))
                {
                    throw new ArgumentOutOfRangeException("Cannot create a lens with radius " + lens_radius + " from sphere with radius: " + sphere_radius +
                                                          " possibly constructed from focal length: " + ringTemplateSO3D.printArgument("focal_length") + "{" + ringTemplateSO3D.factory_id);
                }

                double lens_sphere_radians_max = Math.Asin(lens_radius / sphere_radius);
                //Console.WriteLine("sphere radius: "+sphere_radius+"  lens radius: "+lens_radius);
                ringTemplateSO3D.arguments["lens_sphere_radians_min"] = 0.0;
                ringTemplateSO3D.arguments["lens_sphere_radians_max"] = lens_sphere_radians_max;
            }

            switch (ringTemplateSO3D.factory_id)
            {
            case "EqualHeightRings":
                this.shadowFac_SphereRadius_and_EqualHeightRings(ringTemplateSO3D);
                break;

            case "EqualWidthRings":
                this.shadowFac_SphereRadius_and_EqualWidthRings(ringTemplateSO3D);
                break;

            case "VarRings":
                this.shadowFac_VariusRadii_and_EqualWidthRings(ringTemplateSO3D);
                break;

            case "EqualAngleRings":
                this.shadowFac_SphereRadius_and_EqualAngleRings(ringTemplateSO3D);
                break;

            default:
                throw new ArgumentOutOfRangeException("Factory id {" + ringTemplateSO3D.factory_id + "} not found for " + ringTemplateSO3D.typeString());
            }
        }