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