Example #1
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 #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());
            }
        }