Beispiel #1
0
        /// <summary>
        /// Required parameters:
        /// (Location) lens_plano_center,
        /// (double) lens_radius
        /// (double) var_rings_count   double value instead of int, so the ring may end in a ring-fraction
        /// (NonzeroVector) focal_vector
        /// (double) refractive_index derived from SO3D at a given wavelength (600E-9 by default)
        /// </summary>
        /// <param name='shadowObject'>
        /// Shadow object containing parameters from summary.
        /// </param>
        protected void shadowFac_VariusRadii_and_EqualWidthRings(ShadowScientrace.ShadowObject3d ringTemplateSO3D)
        {
            //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");

            //NOT USED: Scientrace.UnitVector orientation_from_sphere_center = (Scientrace.UnitVector)shadowObject.getObject("orientation_from_sphere_center");

            double radius = ringTemplateSO3D.getDouble("lens_radius");

            double ring_count = ringTemplateSO3D.getDouble("var_rings_count");
            //construct by creating FresnelLensRing Object3D instances and adding them to collection

            double ring_width = radius / ring_count;

            double focal_length = ringTemplateSO3D.getDouble("focal_length");

            double focus_wavelength = ringTemplateSO3D.getDouble("focus_wavelength", 600E-9);
            double refindex         = ringTemplateSO3D.materialprops.refractiveindex(focus_wavelength);

            for (double iring = 0; iring <= ring_count - 1; iring += 1)
            {
                double rmin = iring * ring_width;
                double rmax = Math.Min(iring + 1, ring_count) * ring_width;
                double ravg = (rmin + rmax) / 2;

                double ring_sphere_radius = FresnelLens.GetOptimalRingSphereRadius(focal_length, ravg, refindex, rmax);
                //Console.WriteLine("Radius "+iring+ ": {"+ring_sphere_radius+"}, rmin: {"+rmin+"}, rmax: {"+rmax+"}, xy_ratio: {"+xy_ratio+"}");

                ShadowScientrace.ShadowObject3d so3d = new ShadowScientrace.ShadowObject3d(ringTemplateSO3D);
                so3d.factory_id = "PlanoCenterAndRadians";
                so3d.arguments["lens_sphere_radians_min"] = FresnelLensRing.RadiansForRadii(ring_sphere_radius, rmin);
                so3d.arguments["lens_sphere_radians_max"] = FresnelLensRing.RadiansForRadii(ring_sphere_radius, rmax);
                so3d.arguments["lens_sphere_radius"]      = ring_sphere_radius;
                so3d.parent = this;
                new FresnelLensRing(so3d);
            }
        }
Beispiel #2
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());
            }
        }