Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
 public PhysicalObject3d(ShadowScientrace.ShadowObject3d aShadowObject) : base(aShadowObject)
 {
     this.surface_sides = new HashSet <SurfaceSide>()
     {
         Scientrace.SurfaceSide.Both
     };
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Required parameters:
        /// (Location)center_location
        /// (Location)pointing_towards
        /// (UnitVector)orthogonal_direction
        /// (double)side_length
        /// </summary>
        /// <param name='shadowObject'>
        /// Shadow object containing parameters from summary.
        /// </param>
        protected void shadowFac_Loc_width_height(ShadowScientrace.ShadowObject3d shadowObject)
        {
            //User values(s)
            Scientrace.Location      corner_location = shadowObject.getLocation("corner_location");
            Scientrace.NonzeroVector width           = shadowObject.getNzVector("width");
            Scientrace.NonzeroVector height          = shadowObject.getNzVector("height");

            //construct!
            this.init_Loc_width_height(corner_location, width, height);
        }
Ejemplo n.º 7
0
 /* CONSTRUCTORS */
 public FlatSurfaceObject3d(ShadowScientrace.ShadowObject3d aShadowObject) : base(aShadowObject)
 {
     //only front surface by default:
     //this.x3d_fill = aShadowObject.getBool("x3d_fill", this.x3d_fill);
     this.x3d_fill_emissive_color = aShadowObject.getColorFromHTML("x3d_fill_emissive_color_html", this.x3d_fill_emissive_color);
     this.x3d_fill_diffuse_color  = aShadowObject.getColorFromHTML("x3d_fill_diffuse_color_html", this.x3d_fill_diffuse_color);
     this.x3d_fill_bitmap         = aShadowObject.getString("x3d_fill_bitmap");
     this.x3d_fill_both_sides     = aShadowObject.getBool("x3d_fill_both_sides", this.x3d_fill_both_sides);
     //this.x3d_fill_diffuse = aShadowObject.getBool("x3d_fill_diffuse", this.x3d_fill_diffuse);
     this.x3d_fill_normal = aShadowObject.getVector("x3d_fill_normal", this.x3d_fill_normal);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Required parameters:
        /// (Location)center_location
        /// (Location)pointing_towards
        /// (UnitVector)orthogonal_direction
        /// (double)side_length
        /// </summary>
        /// <param name='shadowObject'>
        /// Shadow object containing parameters from summary.
        /// </param>
        protected void shadowFac_Center_and_Sidelength(ShadowScientrace.ShadowObject3d shadowObject)
        {
            //User values(s)
            Scientrace.Location   center_location      = shadowObject.getLocation("center_location");
            Scientrace.Location   pointing_towards     = shadowObject.getLocation("pointing_towards");
            Scientrace.UnitVector orthogonal_direction = shadowObject.getUnitVector("orthogonal_direction");
            double side_length = shadowObject.getDouble("side_length");

            //construct!
            this.init_Center_and_Sidelength(center_location, pointing_towards, orthogonal_direction, side_length);
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        /* ShadowClass constructor */
        public TriangularPrism(ShadowScientrace.ShadowObject3d shadowObject) : base(shadowObject)
        {
            switch (shadowObject.factory_id ?? "WidthHeightAndLength")     // ?? provides a "default method" when null
            {
            case "WidthHeightAndLength":
                this.shadowFac_Width_Height_And_Length(shadowObject);
                break;

            default:
                throw new ArgumentOutOfRangeException("Factory id {" + shadowObject.factory_id + "} not found for " + shadowObject.typeString());
            }
        }
Ejemplo n.º 12
0
        /// <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);
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        public Rectangle(ShadowScientrace.ShadowObject3d shadowObject) : base(shadowObject)
        {
            switch (shadowObject.factory_id)
            {
            case "Loc_width_height":
                this.shadowFac_Loc_width_height(shadowObject);
                break;

            case "Center_and_Sidelength":
                this.shadowFac_Center_and_Sidelength(shadowObject);
                break;

            default:
                throw new ArgumentOutOfRangeException("Factory id {" + shadowObject.factory_id + "} not found for " + shadowObject.typeString());
            }
        }
Ejemplo n.º 15
0
        public Object3d(ShadowScientrace.ShadowObject3d aShadowObject)
        {
            //Console.WriteLine("adding shadowobject to parent: "+aShadowObject.parent.tag+" and material" +aShadowObject.materialprops);
            this.setDefaults(aShadowObject.parent, aShadowObject.materialprops);

            //if tag is set for this object, pass it on to Object3D instance
            if (aShadowObject.hasTag())
            {
                this.tag = aShadowObject.tag;
            }
            //same for parseorder
            if (aShadowObject.hasParseOrder())
            {
                this.parseOrder = (double)aShadowObject.parseorder;
            }
        }
Ejemplo n.º 16
0
        public DoubleConvexLens(ShadowScientrace.ShadowObject3d shadowObject) : base(shadowObject)
        {
            switch (shadowObject.factory_id)
            {
            case "TwoRadii_and_Diameter": this.shadowFac_TwoRadii_and_Diameter(shadowObject);
                break;

            case "TwoRadii_and_Locations": this.shadowFac_TwoRadii_and_Locations(shadowObject);
                break;

            case "FocalLength_and_Diameter": this.shadowFac_FocalLength_and_Diameter(shadowObject);
                break;

            default:
                throw new ArgumentOutOfRangeException("Factory method {" + shadowObject.factory_id + "} not found for " + shadowObject.typeString());
            }
        }
Ejemplo n.º 17
0
/*
 *      public FresnelLensRing(Object3dCollection parent, MaterialProperties mprops,
 *                      Scientrace.Location lens_sphere_location, double lens_sphere_radius,
 *                      double lens_sphere_radians_min, double lens_sphere_radians_max,
 *                      Scientrace.UnitVector orientation_from_sphere_center) : base (parent, mprops) {
 *              this.paramInit(lens_sphere_location, lens_sphere_radius, lens_sphere_radians_min, lens_sphere_radians_max, orientation_from_sphere_center);
 *              }
 *
 *      /// <summary>
 *      /// Factory method that creates a new FresnelLensRing based on the properties of another FresnelLensRing
 *      /// but mirrored about the flat plane (flatBottomBorder).
 *      /// </summary>
 *      /// <returns>
 *      /// The new FresnelLensRing
 *      /// </returns>
 *      /// <param name='aFresnelLensRing'>
 *      /// A FresnelLensRing to base the (copied) properties upon.
 *      /// </param>
 *      public static FresnelLensRing newOppositeDirectionRing(FresnelLensRing aFresnelLensRing) {
 *              Object3dCollection parent = aFresnelLensRing.parent;
 *              MaterialProperties mprops = aFresnelLensRing.materialproperties;
 *              Scientrace.Location lens_sphere_location = aFresnelLensRing.sphereLoc + (aFresnelLensRing.orientation*aFresnelLensRing.getDistanceToPlanoCenter()*2);
 *              double lens_sphere_radius = aFresnelLensRing.sphereRadius;
 *              double lens_sphere_radians_min = aFresnelLensRing.radiansMin;
 *              double lens_sphere_radians_max = aFresnelLensRing.radiansMax;
 *              Scientrace.UnitVector orientation_from_sphere_center = aFresnelLensRing.orientation.negative();
 *              return new FresnelLensRing(parent, mprops, lens_sphere_location, lens_sphere_radius, lens_sphere_radians_min, lens_sphere_radians_max, orientation_from_sphere_center);
 *              } */

        public FresnelLensRing(ShadowScientrace.ShadowObject3d shadowObject) : base(shadowObject)
        {
            switch (shadowObject.factory_id)
            {
            case "SphereCenterAndRadians": this.shadowFac_SphereCenter_And_Radians(shadowObject);
                break;

            case "PlanoCenterAndRadians": this.shadowFac_PlanoCenter_And_Radians(shadowObject);
                break;

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

            //General stuff:
            this.x3dCurvedSegments = shadowObject.getInt("draw_3d_segment_linecount", this.x3dCurvedSegments);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Required parameters:
        /// (Location) corner_location,
        /// (NonzeroVector) length
        /// (NonzeroVector) width
        /// (NonzeroVector) height
        /// (boolean) perfect_front (default true)
        /// </summary>
        /// <param name='shadowObject'>
        /// Shadow object containing parameters from summary.
        /// </param>
        protected void shadowFac_Width_Height_And_Length(ShadowScientrace.ShadowObject3d shadowObject)
        {
            //User values(s)
            Scientrace.Location      corner_location = shadowObject.getLocation("corner_location");
            Scientrace.NonzeroVector length          = shadowObject.getNzVector("length");
            Scientrace.NonzeroVector width           = shadowObject.getNzVector("width");
            Scientrace.NonzeroVector height          = shadowObject.getNzVector("height");
            bool perfect_top = shadowObject.getBool("perfect_top") == true;

            //Derived value(s)
            //none

            //initialize!
            this.paramInit(corner_location, width, height, length);

            //add some additional parameters
            this.perfectTop = perfect_top;
        }
Ejemplo n.º 19
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);
            }
        }
Ejemplo n.º 20
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());
            }
        }
Ejemplo n.º 21
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);
            }
        }
Ejemplo n.º 22
0
 public EnclosedVolume(ShadowScientrace.ShadowObject3d aShadowObject) : base(aShadowObject)
 {
     this.hasVolume = true;
 }
Ejemplo n.º 23
0
	public Prism(ShadowScientrace.ShadowObject3d aShadowObject):base(aShadowObject) {
		}
Ejemplo n.º 24
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);
            }
        }
Ejemplo n.º 25
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);
            }
        }
Ejemplo n.º 26
0
 public Object3dCollection(ShadowScientrace.ShadowObject3d aShadowObject) : base(aShadowObject)
 {
 }