public ParallelRandomSquareLightSource(ShadowScientrace.ShadowLightSource shadowObject) : base(shadowObject) { int? random_seed = shadowObject.getNInt("random_seed"); Scientrace.Location location = shadowObject.getLocation("location"); //corner Scientrace.UnitVector direction = shadowObject.getUnitVector("direction"); int ray_count = shadowObject.getInt("ray_count"); //linecount, this.distance = shadowObject.getDouble("distance", 0);//distance, //This line has been moved to the LightSource parent shadowconstructor //Scientrace.LightSpectrum spectrum = (Scientrace.LightSpectrum)shadowObject.getObject("spectrum"); //spectrum Scientrace.Vector width = shadowObject.getVector("width");//urange, Scientrace.Vector height = shadowObject.getVector("height");//vrange, Random randNum; if (random_seed == null || random_seed== -1) randNum = new Random(); else randNum = new Random((int)random_seed); for (int iline = 0; iline < ray_count; iline++) { Scientrace.Line line = new Scientrace.Line(location+(width*randNum.NextDouble()+(height*randNum.NextDouble())).toLocation(), direction); // THIS IS BEING DONE BY THE PARENT LIGHTSOURCE CLASS ALREADY: line.startingpoint = line.startingpoint - (direction.toLocation()*distance); Scientrace.Trace newtrace = new Scientrace.Trace(spectrum.wl(iline), this, line, env, spectrum.it(iline), spectrum.it(iline)); newtrace.traceid = "RS"+(random_seed==null?"r":random_seed.ToString())+"-"+iline; this.addTrace(newtrace); } //end for }
public CustomTracesLightSource(ShadowScientrace.ShadowLightSource shadowObject) : base(shadowObject) { foreach (Scientrace.Trace aTrace in (List<Scientrace.Trace>)shadowObject.getObject("traces_list")) { aTrace.lightsource = this; this.addTrace(aTrace); } }
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()); } }
/* 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()); } }
/* 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); }
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()); } }
/* 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); }
public LightSource(ShadowScientrace.ShadowLightSource aShadowLightSource) { this.setObjectEnvironment(aShadowLightSource.env); this.minimum_intensity_fraction = aShadowLightSource.getDouble("minimum_intensity_fraction", this.minimum_intensity_fraction); this.addTraceModifiers((IEnumerable<Scientrace.UniformTraceModifier>)aShadowLightSource.getObject("trace_modifiers", true)); //AND it was put back like a normal ShadowClass object... //this.spectrum = aShadowLightSource.spectrum; this.spectrum = (Scientrace.LightSpectrum)aShadowLightSource.getObject("spectrum", !this.mandatory_spectrum); if (spectrum == null) Console.WriteLine("WARNING: No spectrum given."); this.efficiency_characteristics = (Scientrace.OpticalEfficiencyCharacteristics)aShadowLightSource.getObject("efficiency_characteristics"); this.weighted_intensity = (double)(aShadowLightSource.getNDouble("weighted_intensity") ?? this.spectrum.total_intensity); }
public RandomCircleLightSource(ShadowScientrace.ShadowLightSource shadowObject) : base(shadowObject) { int? random_seed = shadowObject.getNInt("random_seed"); Scientrace.Location location = shadowObject.getLocation("location"); //corner Scientrace.UnitVector direction = shadowObject.getUnitVector("direction"); Scientrace.UnitVector normal = shadowObject.getUnitVector("normal"); // if normal is not defined, use the beam direction as the surface normal. if (normal == null) normal = direction; int ray_count = shadowObject.getInt("ray_count"); //linecount, this.distance = shadowObject.getDouble("distance", 0);//distance, //This line has been moved to the LightSource parent shadowconstructor //Scientrace.LightSpectrum spectrum = (Scientrace.LightSpectrum)shadowObject.getObject("spectrum"); //spectrum double radius = shadowObject.getDouble("radius");//urange, Random randNum; if (random_seed == null || random_seed== -1) randNum = new Random(); else randNum = new Random((int)random_seed); Scientrace.Plane plane = Scientrace.Plane.newPlaneOrthogonalTo(location, normal); Scientrace.UnitVector urange, vrange; double r1, r2; urange = plane.u.toUnitVector(); vrange = plane.v.toUnitVector(); Scientrace.Line line; for (int iline = 0; iline < ray_count; iline++) { r1 = 1-randNum.NextDouble()*2; r2 = 1-randNum.NextDouble()*2; if (Math.Pow(r1,2)+Math.Pow(r2,2)<1) { line = new Scientrace.Line(location+((urange*r1*radius)+(vrange*r2*radius)).toLocation(),direction); // THIS IS BEING DONE BY THE PARENT LIGHTSOURCE CLASS ALREADY: line.startingpoint = line.startingpoint - (direction.toLocation()*distance); } else { iline--; continue; } double wavelength = spectrum.wl(iline); double intensity = spectrum.it(iline); Scientrace.Trace newtrace = new Scientrace.Trace(wavelength, this, line, env, intensity, intensity); newtrace.traceid = "RS"+(random_seed==null?"r":random_seed.ToString())+"-"+iline; this.addTrace(newtrace); } }
public SpiralLightSource(ShadowScientrace.ShadowLightSource shadowObject) : base(shadowObject) { int ray_count = (int)shadowObject.getObject("ray_count"); double loops = shadowObject.getDouble("loops", -1); if (loops == -1) { loops = 1.0154 * Math.Pow(Math.PI*2*(1-Math.Sqrt(((double)ray_count - 1) / (double)ray_count)), -0.5); Console.WriteLine("Number of loops for "+ray_count+" beams set to: {"+loops.ToString("#,0.000")+"}."); } this.paramInit( (Scientrace.Location)shadowObject.getObject("location"), //center (Scientrace.UnitVector)shadowObject.getObject("direction"),//direction, (Scientrace.Plane)shadowObject.getObject("spiral_plane"),//plane, ray_count,//linecount, (double)shadowObject.getObject("radius"),//radius, loops,//loops, (double)shadowObject.getObject("distance")//distance, //(Scientrace.LightSpectrum)shadowObject.getObject("spectrum")//spectrum ); }
public ParallelLightSource(ShadowScientrace.ShadowLightSource shadowObject) : base(shadowObject) { }
/// <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); } }
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; }
public void setLightSourceSettings(ShadowScientrace.ShadowLightSource shadowLS, XElement xel) { XMLTraceModifierParser xtmp = new XMLTraceModifierParser(); List<Scientrace.UniformTraceModifier> utms = xtmp.getModifiers(xel); shadowLS.arguments.Add("trace_modifiers", utms); double minintensity = this.X.getXDouble(xel, "MinIntensity", 0.2); //default minimum intensity for tracing set to 1% shadowLS.arguments.Add("minimum_intensity_fraction", minintensity); }
public void setLightSourceConstructorParams(ShadowScientrace.ShadowLightSource shadowLS, XElement xel) { // STRUCTURE /* "dictionary name of the parameter" * Description of this parameters * used at: list of light source classes that use this parameter * nullable: yes if this field may be empty */ /* "location" * The location of the light source * used at: all * nullable: no */ Scientrace.Location location = this.X.getXLocation(xel, "Location", null); shadowLS.arguments.Add("location", location); /* "width" and "height" * The width of the light source * used at: random square light source * nullable: yes */ Scientrace.Vector width = this.X.getXLocation(xel, "Width", null); Scientrace.Vector height = this.X.getXLocation(xel, "Height", null); shadowLS.arguments.Add("width", width); shadowLS.arguments.Add("height", height); /* "ray count" * The number of traces that will be initiated by the light source, some of the rays may be split or absorbed during simulation * Previously called: BeamCount, but renamed to RayCount. * used at: SpiralLightSource * nullable: no */ int ray_count = this.X.getXInt(xel, "RayCount", this.X.getXInt(xel, "BeamCount", 256)); shadowLS.arguments.Add("ray_count", ray_count); /* "loops" * The number of loops the spiral makes * used at: SpiralLightSource * nullable: yes */ if (this.X.hasAttribute(xel, "Loops")) { double? loops = this.X.getXNullDouble(xel, "Loops"); /* MOVED TO SPIRALLIGHTSOURCE if (loops == -1) { loops = 1.0154 * Math.Pow(Math.PI*2*(1-Math.Sqrt(((double)ray_count - 1) / (double)ray_count)), -0.5); Console.WriteLine("Number of loops for "+ray_count+" beams set to: {"+loops.ToString("#,0.000")+"}."); } */ shadowLS.arguments.Add("loops", loops); } /* "radius" * The radius for any circle shaped irradiating surface * used at: SpiralLightSource * nullable: no */ double? radius = this.X.getXNullDouble(xel, "Radius"); if (radius == null) radius = this.X.getXNullDouble(xel, "Diameter")/2; if (radius != null && radius < 0) {throw new ArgumentOutOfRangeException("Radius "+radius+" out of range");} shadowLS.arguments.Add("radius", radius); /* "distance" * In some cases the user might want to describe a surface/orientation where the rays to trace pass, but should they actually start a given distance up front. The distance parameter describes the distance to start "before" the given surface. * used at: SpiralLightSource * nullable: default = 0 */ shadowLS.arguments.Add("distance", this.X.getXDouble(xel, "Distance", 0)); /* "weighted_intensity" * The intensity of the entire lightsource may be weighted/redefined by setting its intensity. * nullable: yes * used at: all */ shadowLS.arguments.Add("weighted_intensity", this.X.getXNullDouble(xel, "Intensity")); /* "random_seed" * In order to make repreducable results, a randomized may be seeded * used at: RandomSquare * nullable: default = null */ shadowLS.arguments.Add("random_seed", this.X.getXNullInt(xel, "RandomSeed")); /* "direction" * The direction in which the rays leave the (parallel) source * used at: SpiralLightSource, RandomSquare * nullable: no */ shadowLS.arguments.Add("direction", this.X.getXUnitVectorByName(xel, "Direction", null)); /* "orthogonal to plane in which the "circle of light" is created" * used at: RandomCircleLightSource * nullable: yes */ shadowLS.arguments.Add("normal", this.X.getXUnitVectorByName(xel, "Normal", null)); /* "orthogonal to plane about which spiral is created" * sued at: SpiralLightSource * nullable: yes */ Scientrace.NonzeroVector spiral_axis = this.X.getXNzVectorByName(xel, "SpiralAxis", null); if (spiral_axis != null) { Scientrace.Plane spiralplane = Scientrace.Plane.newPlaneOrthogonalTo(location, spiral_axis); shadowLS.arguments.Add("spiral_plane", spiralplane); } /* "spectrum" * The wavelengths that are irradiated by the source with their relative intensities * used at: all except CustomTraces * */ XMLSpectrumParser xsp = new XMLSpectrumParser(); Scientrace.LightSpectrum spectrum = xsp.parseLightSpectrum(xel.Element("Spectrum")); //if (spectrum==null) { throw new Exception("LightSpectrum "+xel.Element("Spectrum").ToString()+" unknown"); } shadowLS.arguments.Add("spectrum", spectrum); /* "efficiency_characteristics" * If the performance of a cell depends on the angle of incidence or the wavelength of light, it can be defined * in efficiency_characteristics. The default fractions are "1" for both. * used at: all */ XMLEfficiencyCharacteristicsParser xecp = new XMLEfficiencyCharacteristicsParser(); Scientrace.OpticalEfficiencyCharacteristics oec = xecp.parseEfficiencyForLightSource(xel); shadowLS.arguments.Add("efficiency_characteristics", oec); /* "traces_list" * A generic List<Scientrace.Trace> with traces that are manually added to a lightsource. * used at: CustomTraces */ shadowLS.arguments.Add("traces_list", this.getCustomTracesListFromXData(xel, shadowLS.env)); }
/// <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); }
/// <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; }
public Object3dCollection(ShadowScientrace.ShadowObject3d aShadowObject) : base(aShadowObject) { }
public Prism(ShadowScientrace.ShadowObject3d aShadowObject) : base(aShadowObject) { }
public EnclosedVolume(ShadowScientrace.ShadowObject3d aShadowObject) : base(aShadowObject) { this.hasVolume = true; }
/// <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); }
/// <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: /// (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); }
/// <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); } }
/// <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); } }
public void setClassInfo(XElement xel, ShadowScientrace.ShadowLightSource shadowLS) { shadowLS.class_name = this.X.getXStringByName(xel, "Class"); shadowLS.class_type = this.getClass(shadowLS.class_name); if (shadowLS.class_type == null) throw new XMLException("LightSource Class {"+shadowLS.class_name+"} is not recognized."); }
public PhysicalObject3d(ShadowScientrace.ShadowObject3d aShadowObject) : base(aShadowObject) { this.surface_sides = new HashSet<SurfaceSide>() {Scientrace.SurfaceSide.Both}; }
/// <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); }