/// <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); }
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()); } }
/// <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); }
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()); } }