public Intersection(bool intersects, Scientrace.Object3d object3d) { this.intersects = intersects; this.object3d = object3d; this.checkObject();//<- DEBUGGING: }
public Intersection(bool intersects, Scientrace.Object3d object3d) { this.intersects = intersects; this.object3d = object3d; this.checkObject(); //<- DEBUGGING: }
// return type changed from single Scientrace.Trace instance to List<Scientrace.Trace> newTraces in order to better facilitate the splitting of traces. public List <Scientrace.Trace> redirect_without_polarisation(Scientrace.Object3d toObject, Scientrace.Intersection intersection) { List <Scientrace.Trace> newTraces = new List <Trace>(); //what objects are acting here? Scientrace.Object3d fromObject = this.currentObject; /* The "normal" vector should always point towards the incoming beam when * using the Snellius-approach as described by figure 15 in * "Optical simulation of the SunCycle concentrator using Scientrace" * by Joep Bos-Coenraad (2013) */ Scientrace.UnitVector normal = intersection.enter.flatshape.plane.getNorm() .orientedAgainst(this.traceline.direction) .tryToUnitVector(); //Does full internal reflection occur? if (this.fullInternalReflects(normal, fromObject, toObject)) { //construct reflectedTrace Trace internalReflectedTrace = this.createFullInternalReflectedTraceFork(intersection); newTraces.Add(internalReflectedTrace); // in case of full internal reflection, no other "effects" occur, so return the newTraces collection here. return(newTraces); } newTraces.AddRange(this.partialReflectRefract(fromObject, toObject, intersection, normal)); // HERE USED TO BE CODE THAT CHECKED WHETHER (based on alphadirection) the direction of the incoming beam was altered at all. return(newTraces); } // end func. redirect
public double absorpByObject(Scientrace.Object3d anObject3d, Scientrace.UnitVector norm, Object3d previousObject) { double oldintensity = this.intensity; double oldintensityfraction = this.intensityFraction(); //EXTENDED 20150706 double absorption_fraction = anObject3d.materialproperties.absorption(this, norm, previousObject.materialproperties); double absorption = absorption_fraction * oldintensity; double absorptionIntensityFraction = absorption_fraction * oldintensityfraction; this.intensity = oldintensity - absorption; if (absorption > MainClass.SIGNIFICANTLY_SMALL) //don't write a spot at ~0 absorption. { TraceJournal.Instance.recordSpot(new Scientrace.Spot(this.traceline.startingpoint, anObject3d, absorption, absorptionIntensityFraction, this)); } if (this.intensityFraction() <= this.lightsource.minimum_intensity_fraction) { //Console.WriteLine("INTENSITY TOO LOW"+anObject3d.ToString()+"/"+anObject3d.materialproperties.absorption(this)); this.perish(this.traceline.startingpoint); } return(absorption_fraction); }
public static Scientrace.SurfaceProperties NewSurfaceModifiedObject(Scientrace.Object3d anObject, List <Scientrace.UniformTraceModifier> surface_normal_modifiers) { Scientrace.SurfaceProperties retSurf = new Scientrace.SurfaceProperties(); retSurf.materialproperties = anObject.materialproperties; retSurf.addSurfaceModifiers(surface_normal_modifiers); return(retSurf); }
public List <Scientrace.UniformTraceModifier> getSurfaceNormalModifiers() { Scientrace.Object3d o3d = this.object3d; Scientrace.SurfaceProperties surfaceprops = this.getSurfaceProperties(); // fill the list with modifiers. A surface may have specific (dominant) properties set, but not necessarily. // If not, use the properties for the interacting object. return((surfaceprops == null) ? o3d.surface_normal_modifiers : surfaceprops.surface_normal_modifiers); }
//copy constructor public Intersection(Intersection copyIntersection) { this.intersects = copyIntersection.intersects; this.object3d = copyIntersection.object3d; this.leaving = copyIntersection.leaving; if (copyIntersection.enter != null) this.enter = new Scientrace.IntersectionPoint(copyIntersection.enter); if (copyIntersection.exit != null) this.exit = new Scientrace.IntersectionPoint(copyIntersection.exit); }
/// <summary> /// Prolong the trace to the specified Object3d instance (toObject3d) at location as specified in intersection. /// Prolonging does NOT increase the nodecounter. Attached objects count as 1 node alltogether. /// </summary> /// <param name='toObject3d'> /// The Object3d instance of interaction with the current Object3d at the surface. /// </param> /// <param name='intersection'> /// The intersection instance that describes the intersection that is calculated to occur. /// </param> public List <Scientrace.Trace> prolong(Scientrace.Object3d toObject3d, Scientrace.Intersection intersection) { Scientrace.Trace newtrace = this.clone(); List <Scientrace.Trace> newTraces = new List <Scientrace.Trace>(); newtrace.currentObject = toObject3d; newtrace.traceline.startingpoint = intersection.enter.loc; newtrace.traceline.direction = this.traceline.direction; newTraces.Add(newtrace); return(newTraces); }
//copy constructor public Intersection(Intersection copyIntersection) { this.intersects = copyIntersection.intersects; this.object3d = copyIntersection.object3d; this.leaving = copyIntersection.leaving; if (copyIntersection.enter != null) { this.enter = new Scientrace.IntersectionPoint(copyIntersection.enter); } if (copyIntersection.exit != null) { this.exit = new Scientrace.IntersectionPoint(copyIntersection.exit); } }
/// <summary> /// Reduces the "object3d" element from the intersection to its parent when leaving the current object. /// </summary> /// <param name='anIntersection'> /// The intersection that could be leaving the object. /// </param> public void resetObjectToParentWhenLeaving() { if (this.leaving) //Leaving current object, returning to parent... { if (this.object3d.hasParent()) { this.object3d = this.object3d.getFirstNonVirtualParent(); } else //before the "virtual" collection improvement default behaviour. { this.object3d = this.object3d.getParentOrRoot(); } } }
public Intersection(bool intersects, Scientrace.Object3d object3d, Scientrace.Location enterloc, Scientrace.FlatShape2d enterplane, Scientrace.Location exitloc, bool leaving) { this.intersects = intersects; this.object3d = object3d; this.enter = new IntersectionPoint(enterloc, enterplane); //plane of exitloc irrelevant if (exitloc == null) { this.exit = null; } else { this.exit = new IntersectionPoint(exitloc, null); } this.leaving = leaving; this.checkObject();//<- DEBUGGING: }
public Intersection(bool intersects, Scientrace.Object3d object3d, Scientrace.Location enterloc, Scientrace.FlatShape2d enterplane, Scientrace.Location exitloc) { //same as constructor above but with leaving = false. this.intersects = intersects; this.object3d = object3d; this.enter = new IntersectionPoint(enterloc, enterplane); if (exitloc == null) { this.exit = null; } else { this.exit = new IntersectionPoint(exitloc, null); } this.leaving = false; this.checkObject();//<- DEBUGGING: }
public StringBuilder drawSphereSlice(Scientrace.Object3d drawnObject3d, double lateral_circles, double meridians, Scientrace.Sphere sphere, double from_radians, double to_radians, Scientrace.UnitVector sliceAlongDirection) { System.Text.StringBuilder retx3d = new System.Text.StringBuilder(1024); //"<!-- DOUBLECONVEXLENS GRID start -->"); double pi2 = Math.PI * 2; NonzeroVector orthoBaseVec1 = null; NonzeroVector orthoBaseVec2 = null; sliceAlongDirection.fillOrtogonalVectors(ref orthoBaseVec1, ref orthoBaseVec2); for (double iSphereCircle = 2 * lateral_circles; iSphereCircle > 0; iSphereCircle--) // the rings/parallels along the sliceAlongDirection axis { double lateral_radians = (to_radians * (iSphereCircle / (2 * lateral_circles))); double circle2DRadius = sphere.radius * Math.Sin(lateral_radians); double circle2DDistance = sphere.radius * Math.Cos(lateral_radians); retx3d.Append(this.drawCircle(sphere.loc + (sliceAlongDirection * circle2DDistance).toLocation(), circle2DRadius, sliceAlongDirection)); for (double iSphereMerid = 0.5; iSphereMerid < 2 * meridians; iSphereMerid++) // meridians connect the rings/circles on the spherical surface { Scientrace.Location tNodeLoc = sphere.getSphericalLoc( orthoBaseVec1, orthoBaseVec2, sliceAlongDirection, to_radians * (iSphereCircle / (2 * lateral_circles)), // lat_angle = theta pi2 * (iSphereMerid / (2 * meridians)) // mer_angle = phi ); if (!tNodeLoc.isValid()) { throw new NullReferenceException("Cannot calculate base gridpoint at @ " + drawnObject3d.tag); } Scientrace.Location tLatConnectLoc = sphere.getSphericalLoc( orthoBaseVec1, orthoBaseVec2, sliceAlongDirection, to_radians * ((iSphereCircle - 1) / (2 * lateral_circles)), // lat_angle = theta pi2 * ((iSphereMerid) / (2 * meridians)) // mer_angle = phi ); if (!tLatConnectLoc.isValid()) { throw new NullReferenceException("Cannot calculate lateral gridpoint at @ " + drawnObject3d.tag); } Scientrace.X3DGridPoint tGridPoint = new Scientrace.X3DGridPoint(0, tNodeLoc, null, tLatConnectLoc); retx3d.AppendLine(tGridPoint.exportX3DnosphereRGB(this.primaryRGB)); } } // end for iSphereCircle / iSphereMerid return(retx3d); }
} // end func. redirect public List <Scientrace.Trace> partialReflectRefract(Scientrace.Object3d fromObject3d, Scientrace.Object3d toObject3d, Scientrace.Intersection intersection, UnitVector surfaceNormal) { /*double oldrefindex = fromObject3d.materialproperties.refractiveindex(this); * double newrefindex = toObject3d.materialproperties.refractiveindex(this);*/ List <Scientrace.Trace> newTraces = new List <Trace>(); Scientrace.Trace refractTrace = this.fork("_pr"); refractTrace.currentObject = toObject3d; refractTrace.traceline.startingpoint = intersection.enter.loc; Scientrace.UnitVector normal = intersection.enter.flatshape.plane.getNorm() .orientedAgainst(this.traceline.direction) .tryToUnitVector(); // Evaluate absorption by toObject3d refractTrace.absorpByObject(toObject3d, normal, fromObject3d); if (refractTrace.isEmpty()) { newTraces.Add(refractTrace); return(newTraces); } // CHECK whether (partial) reflection occurs... if ((toObject3d.materialproperties.reflects) || ((intersection.leaving) && (fromObject3d.materialproperties.reflects))) { //double refcoef = toObject3d.materialproperties.reflection(refractTrace, surfaceNormal, this.currentObject); double refcoef = toObject3d.materialproperties.reflection(refractTrace, surfaceNormal, fromObject3d.materialproperties); Scientrace.Trace reflectTrace = refractTrace.fork("_R"); //.clone(); reflectrace.nodecount++; reflectTrace.intensity = refractTrace.intensity * refcoef; //intensity shouldn't spawn nor disappear here refractTrace.intensity = refractTrace.intensity - reflectTrace.intensity; //Scientrace.Spot normspot = new Scientrace.Spot(norm.toLocation()+intersection.enter.loc, null, 1); //CHANGED 20131030 //reflectrace.traceline = newtrace.reflectAt(intersection.enter.flatshape.plane); reflectTrace.traceline = refractTrace.reflectLineAbout(reflectTrace.traceline, surfaceNormal); //ADDED @ 20130122: the parial internal reflected trace should have the current object as oldobject. reflectTrace.currentObject = this.currentObject; //CURRENT OBJECT DOES NOT CHANGE FOR (partial)INTERNAL REFLECTION! newTraces.Add(reflectTrace); } this.initCreatedRefractTrace(refractTrace, surfaceNormal, fromObject3d, toObject3d); newTraces.Add(refractTrace); return(newTraces); } // end func partialReflectRefract
public Intersection(bool intersects, Scientrace.Object3d object3d, Scientrace.Location enterloc, Scientrace.FlatShape2d enterplane, Scientrace.Location exitloc, bool leaving) { this.intersects = intersects; this.object3d = object3d; this.enter = new IntersectionPoint(enterloc, enterplane); //plane of exitloc irrelevant if (exitloc == null) { this.exit = null; } else { this.exit = new IntersectionPoint(exitloc, null); } this.leaving = leaving; this.checkObject(); //<- DEBUGGING: }
public Intersection(bool intersects, Scientrace.Object3d object3d, Scientrace.Location enterloc, Scientrace.FlatShape2d enterplane, Scientrace.Location exitloc) { //same as constructor above but with leaving = false. this.intersects = intersects; this.object3d = object3d; this.enter = new IntersectionPoint(enterloc, enterplane); if (exitloc == null) { this.exit = null; } else { this.exit = new IntersectionPoint(exitloc, null); } this.leaving = false; this.checkObject(); //<- DEBUGGING: }
// return type changed from single Scientrace.Trace instance to List<Scientrace.Trace> newTraces in order to better facilitate the splitting of traces. public List<Scientrace.Trace> redirect_with_polarisation(Scientrace.Object3d toObject, Scientrace.Intersection intersection) { List<Scientrace.Trace> newTraces = new List<Trace>(); //what objects are acting here? Scientrace.Object3d fromObject = this.currentObject; /* The "normal" vector should always point towards the incoming beam when * using the Snellius-approach as described by figure 15 in * "Optical simulation of the SunCycle concentrator using Scientrace" * by Joep Bos-Coenraad (2013) */ Scientrace.UnitVector normal = intersection.enter.flatshape.plane.getNorm() .orientedAgainst(this.traceline.direction) .tryToUnitVector(); DielectricSurfaceInteraction fsi = new DielectricSurfaceInteraction(this, intersection.enter.loc, normal, fromObject.materialproperties.refractiveindex(this), toObject.materialproperties.refractiveindex(this), toObject); newTraces.AddIfNotNull(fsi.getReflectTrace(this.getMinDistinctionLength())); newTraces.AddIfNotNull(fsi.getRefractTrace(this.getMinDistinctionLength())); return newTraces; }
public new Scientrace.Object3d factory() { if (this.parent == null) { throw new ArgumentNullException("A ShadowObject3d cannot be factorized when parent==null for Shadowtype " + this.typeString()); } if (this.materialprops == null) { throw new ArgumentNullException("A ShadowObject3d cannot be factorized when materialprops==null for Shadowtype " + this.typeString()); } Scientrace.Object3d a = (Scientrace.Object3d)base.factory(); if (this.register_performance) { Scientrace.TraceJournal.Instance.registerObjectPerformance(a); } //20151021: The DistributionSquare functionality has been removed as it was no longer considered useful. /* if (this.register_distribution) * Scientrace.TraceJournal.Instance.registerDistributionObject(a); */ return(a); }
/* * !!!!!!!!!!!!!!THIS METHOD IS DEPRECATED AS THE FORK METHOD SHOULD BE USED TO PREVENT INFINITE LOOPS!!!!!!!!!!! * /// <summary> * /// This constructor method clones the original trace parameters to a new trace instance but changes the traceline * /// value to the newLine values. * /// </summary> * /// <param name="aTrace"> * /// A <see cref="Scientrace.Trace"/> * /// </param> * /// <param name="newLine"> * /// A <see cref="Scientrace.Line"/> * /// </param> * public Trace(Scientrace.Trace aTrace, Scientrace.Line newLine) { * this.init(aTrace.wavelenght, aTrace.lightsource, newLine, aTrace.currentObject, aTrace.intensity, aTrace.original_intensity); * } */ /* public Trace(double wlength, LightSource lsource, Scientrace.Line line, Scientrace.Object3d currentObject) { * //default start-intensity of 1 * this.init(wlength, lsource, line, currentObject, 1); * } */ public void init(double wlength, LightSource lsource, Scientrace.Line line, Scientrace.Object3d currentObject, double intensity, double original_intensity) { this.intensity = intensity; this.original_intensity = original_intensity; if (original_intensity == 0) { throw new ArgumentOutOfRangeException("original_intensity", "wl: " + wlength.ToString() + ", currentobj:" + currentObject.tag); } this.wavelenght = wlength; this.interactionoffset = this.getMinDistinctionLength(); //CHANGED OFFSET FROM WL*100 TO WL TODO CHECK this.traceline = line; this.currentObject = currentObject; this.lightsource = lsource; if (lsource != null) { if (this.isEmpty()) { throw new Exception("An invisible beam (I=" + this.intensity + ") has been constructed"); } } }
/// <summary> /// Fulls the internal reflects. /// </summary> /// <returns> /// True if full internal reflection occurs. Returns false in case of refraction and partial reflection /// </returns> /// <param name='incoming_trace_direction'> /// incoming_trace_direction is the vector of the trace passing the surface /// </param> public bool fullInternalReflects(UnitVector surfaceNormal, Scientrace.Object3d fromObject3d, Scientrace.Object3d toObject3d) { double oldrefindex = fromObject3d.materialproperties.refractiveindex(this); double newrefindex = toObject3d.materialproperties.refractiveindex(this); UnitVector incoming_trace_direction = this.traceline.direction; // make sure the surfaceNormal is directed towards the incoming beam (so in the opposite direction) if (incoming_trace_direction.dotProduct(surfaceNormal) > 0) { surfaceNormal = surfaceNormal.negative(); } // nnorm is surface normale directed into the *new* surface, so *along* the incoming beam Scientrace.UnitVector nnorm = surfaceNormal.negative(); // incoming_normal_projection is the projection of incoming_trace_direction at the (n)norm Scientrace.Vector incoming_normal_projection = nnorm * (incoming_trace_direction.dotProduct(nnorm)); // L1 and L2 are defined as on figure 15 / page 20 from the "Optical simulation of the SunCycle concentrator using Scientrace (J. Bos-Coenraad 2013) Vector L1 = incoming_trace_direction - incoming_normal_projection; double L2 = (oldrefindex / newrefindex) * L1.length; // If L2 is larger than 1, full internal reflection takes place. return(L2 > 1); }
} // end func partialReflectRefract public void initCreatedRefractTrace(Trace refractTrace, UnitVector surfaceNormal, Scientrace.Object3d fromObject3d, Scientrace.Object3d toObject3d) { double oldrefindex = fromObject3d.materialproperties.refractiveindex(this); double newrefindex = toObject3d.materialproperties.refractiveindex(this); //for definitions on the parameters below, check fullInternalReflects function. UnitVector incoming_trace_direction = this.traceline.direction; if (incoming_trace_direction.dotProduct(surfaceNormal) > 0) { surfaceNormal = surfaceNormal.negative(); } Scientrace.UnitVector nnorm = surfaceNormal.negative(); Scientrace.Vector incoming_normal_projection = nnorm * (incoming_trace_direction.dotProduct(nnorm)); Vector L1 = incoming_trace_direction - incoming_normal_projection; double L2 = (oldrefindex / newrefindex) * L1.length; if (incoming_trace_direction == incoming_normal_projection) { //in case of normal incident light: do not refract. refractTrace.traceline.direction = incoming_trace_direction; return; } try { refractTrace.traceline.direction = ((nnorm * Math.Sqrt(1 - Math.Pow(L2, 2))) + (L1.tryToUnitVector() * L2)).tryToUnitVector(); } catch (ZeroNonzeroVectorException) { Console.WriteLine("WARNING: cannot define direction for refraction trace. Using surface normal instead. (L1: " + incoming_trace_direction.trico() + ", L2:" + incoming_normal_projection.trico() + ")."); refractTrace.traceline.direction = nnorm; } //end try/catch }
public List <Scientrace.Trace> redirect(Scientrace.Object3d toObject, Scientrace.Intersection intersection) { return((toObject.materialproperties.dielectric && Trace.support_polarisation) ? this.redirect_with_polarisation(toObject, intersection) // the new implementation : this.redirect_without_polarisation(toObject, intersection)); // the old implementation }
public Scientrace.Intersection intersectplanesforobject(Scientrace.Object3d anObject, List <Scientrace.FlatShape2d> pgrams) { Scientrace.Trace trace = this; Scientrace.Location firstloc = null; Scientrace.FlatShape2d enterplane = null; Scientrace.Location lastloc = null; double?firstdistance = null; double?lastdistance = null; Scientrace.Location tloc; double tdistance; foreach (Scientrace.FlatShape2d pgram in pgrams) { tloc = pgram.atPath(trace.traceline); if (tloc == null) { continue; } if (((tloc - trace.traceline.startingpoint).dotProduct(trace.traceline.direction)) < trace.getMinDistinctionLength()) { continue; //the location (even if increased with one wavelength) is "behind" the trace } tdistance = tloc.distanceTo(trace.traceline.startingpoint); if (firstdistance == null) { //assign first and last to first item in collection firstdistance = tdistance; firstloc = tloc; enterplane = pgram; lastdistance = tdistance; lastloc = tloc; } if (tdistance < firstdistance) { //Console.WriteLine(tdistance.ToString()+"<"+firstdistance.ToString()); firstdistance = tdistance; firstloc = tloc; enterplane = pgram; } if (tdistance > lastdistance) { //Console.WriteLine("We have a large distance gentlemen"); lastdistance = tdistance; lastloc = tloc; } } //end of pgrams-for-loop if (firstdistance == null) { //when no side of the paralellogram has been intersected return(new Scientrace.Intersection(false, anObject)); } if (firstdistance == lastdistance) { lastdistance = null; lastloc = null; } if (lastdistance == null) { //Console.WriteLine("I have no ending"); } else { //Console.WriteLine("I from "+trace.currentObject.GetType()+" @ "+trace.traceline.startingpoint.trico()+" pass through an object"); } Scientrace.Intersection intrs = new Scientrace.Intersection(true, anObject, firstloc, enterplane, lastloc); intrs.leaving = (lastloc == null); return(intrs); }
public Trace(double wlengthmeters, LightSource lsource, Scientrace.Line traceline, Scientrace.Object3d currentObject, double intensity, double original_intensity) { this.init(wlengthmeters, lsource, traceline, currentObject, intensity, original_intensity); }
public void initNewIntersection(Scientrace.Line traceline, Scientrace.IntersectionPoint[] ips, Scientrace.Object3d object3d, bool bothdirections) { this.object3d = object3d; //Console.WriteLine("New Intersection with "+ips.Length+" IP's - "+object3d.hasParent()); this.intersects = false; //Console.WriteLine("FALSE"); foreach (Scientrace.IntersectionPoint ip in ips) { if (ip == null) { //Console.WriteLine("<NULL>"); continue; } //if bothdirections == true the Intersection does not nessicarily have to be away (in direction "direction") // from the startingpoint. if (!bothdirections) { //check if ip is in the line of the trace from its startingpoint if (traceline.direction.dotProduct(ip.loc - traceline.startingpoint) <= 1E-9) { //Console.WriteLine("WARNING: Intersectionpoint "+ip.loc.ToString()+" lies in the past @ "+traceline.startingpoint); continue; } } if (this.intersects == false) { //Console.WriteLine("TRUE"); this.intersects = true; this.enter = ip; this.exit = null; // new IntersectionPoint(null, null); CHANGED (BUGFIX?) BY JBC @ 20131205 continue; } if (this.enter.loc.distanceTo(traceline.startingpoint) > ip.loc.distanceTo(traceline.startingpoint)) { //this intersectionpoint is closer than the "enterpoint so far" // this condition is wrong right? if (this.exit==null) { this.exit = this.enter; // this is wrong right? } this.enter = ip; continue; } else { if (this.exit == null) { this.exit = ip; continue; } else { //this intersectionpoint is further from beam than enterpoint. New exitpoint defined. if (this.exit.loc.distanceTo(traceline.startingpoint) > ip.loc.distanceTo(traceline.startingpoint)) { //intersectionpoint is closer than old exitpoint this.exit = ip; continue; } } continue; // <-- existing exitpoint is closer than new IP: do nothing. } } }
// Factory method for false intersections... public static Scientrace.Intersection notIntersect(Scientrace.Object3d aNotIntersectedObject) { return(new Scientrace.Intersection(false, aNotIntersectedObject)); }
public void initNewIntersection(Scientrace.Line traceline, Scientrace.IntersectionPoint[] ips, Scientrace.Object3d object3d, bool bothdirections) { this.object3d = object3d; //Console.WriteLine("New Intersection with "+ips.Length+" IP's - "+object3d.hasParent()); this.intersects = false; //Console.WriteLine("FALSE"); foreach (Scientrace.IntersectionPoint ip in ips) { if (ip == null) { //Console.WriteLine("<NULL>"); continue; } //if bothdirections == true the Intersection does not nessicarily have to be away (in direction "direction") // from the startingpoint. if (!bothdirections) { //check if ip is in the line of the trace from its startingpoint if (traceline.direction.dotProduct(ip.loc-traceline.startingpoint) <= 1E-9) { //Console.WriteLine("WARNING: Intersectionpoint "+ip.loc.ToString()+" lies in the past @ "+traceline.startingpoint); continue; } } if (this.intersects == false) { //Console.WriteLine("TRUE"); this.intersects = true; this.enter = ip; this.exit = null; // new IntersectionPoint(null, null); CHANGED (BUGFIX?) BY JBC @ 20131205 continue; } if (this.enter.loc.distanceTo(traceline.startingpoint) > ip.loc.distanceTo(traceline.startingpoint)) { //this intersectionpoint is closer than the "enterpoint so far" // this condition is wrong right? if (this.exit==null) { this.exit = this.enter; // this is wrong right? } this.enter = ip; continue; } else { if (this.exit == null) { this.exit = ip; continue; } else { //this intersectionpoint is further from beam than enterpoint. New exitpoint defined. if (this.exit.loc.distanceTo(traceline.startingpoint) > ip.loc.distanceTo(traceline.startingpoint)) { //intersectionpoint is closer than old exitpoint this.exit = ip; continue; }} continue; // <-- existing exitpoint is closer than new IP: do nothing. } } }
public void parseXObject3d(XElement xel, Scientrace.Object3dCollection col, XMLObject3dParser o3dp, ShadowClassConstruct shadowConstructor) { Scientrace.Object3d createdObject3d = null; switch (xel.Name.ToString()) { case "CircularFresnelPrism": createdObject3d = o3dp.parseXFresnelPrism(xel); break; case "ParabolicMirror": createdObject3d = o3dp.parseXParabolicMirror(xel); //PARSE PARAB MIRROR break; case "Prism": //fall through case "TriangularPrism": createdObject3d = shadowConstructor.constructTriangularPrism(xel); //createdObject3d = o3dp.parseXTriangularPrism(xel); break; case "RectangularPrism": createdObject3d = o3dp.parseXRectangularPrism(xel); break; case "SquareCell": case "Rectangle": //square cell can be used for any square or rectangular surface-object //createdObject3d = o3dp.parseXRectangle(xel); createdObject3d = shadowConstructor.constructRectangle(xel); break; case "Sphere": createdObject3d = o3dp.parseXSphere(xel); break; case "FresnelLens": createdObject3d = shadowConstructor.constructFresnelLens(xel); break; case "FresnelLensRing": createdObject3d = shadowConstructor.constructFresnelLensRing(xel); break; case "PlanoConvexLens": createdObject3d = o3dp.parseXPlanoConvexLens(xel); break; case "DoubleConvexLens": //createdObject3d = o3dp.parseXDoubleConvexLens(xel); createdObject3d = shadowConstructor.constructDoubleConvexLens(xel); break; case "BorderedVolume": createdObject3d = o3dp.parsXBorderedVolume(xel); break; case "ToppedPyramid": case "TruncatedPyramid": createdObject3d = o3dp.parseXTruncatedPyramid(xel); break; case "CameraViewpoint": //fallthrough case "CameraFrom": //fallthrough case "CameraRotation": //Cam settings set at environment. break; case "LightSource": //do nothing, already parsed previously break; case "Ignore": case "IGNORE": //do nothing, IGNORE! break; default: if (!(xel.Name.ToString().Substring(0, 3) == "REM")) { Console.WriteLine("WARNING: UNKNOWN OBJECT: " + xel.Name + " \n[XML code]\n" + xel.ToString() + "\n[/XML code]\n"); } break; } if (createdObject3d != null) { XMLTraceModifierParser xtmp = new XMLTraceModifierParser(); List <Scientrace.UniformTraceModifier> utms = xtmp.getModifiers(xel); createdObject3d.addSurfaceModifiers(utms); } } // end parseXObject3d
public Intersection(Scientrace.Line traceline, Scientrace.IntersectionPoint[] ips, Scientrace.Object3d object3d, bool bothdirections) { this.initNewIntersection(traceline, ips, object3d, bothdirections); this.checkObject(); //<- DEBUGGING: }
public static Scientrace.SurfaceProperties NoModifierSurfaceForObject(Scientrace.Object3d anObject) { Scientrace.SurfaceProperties retSurf = new Scientrace.SurfaceProperties(); retSurf.materialproperties = anObject.materialproperties; return(retSurf); }
public Intersection(Scientrace.Trace trace, Scientrace.IntersectionPoint[] ips, Scientrace.Object3d object3d) { this.initNewIntersection(trace.traceline, ips, object3d, false); this.checkObject(); //<- DEBUGGING: }
/// <summary> /// Reduces the "object3d" element from the intersection to its parent when leaving the current object. /// </summary> /// <param name='anIntersection'> /// The intersection that could be leaving the object. /// </param> public void resetObjectToParentWhenLeaving() { if (this.leaving) { //Leaving current object, returning to parent... if (this.object3d.hasParent()) { this.object3d = this.object3d.getFirstNonVirtualParent(); } else { //before the "virtual" collection improvement default behaviour. this.object3d = this.object3d.getParentOrRoot(); } } }
public void registerObjectPerformance(Scientrace.Object3d aCell) { this.registeredPerformanceObjects.Add(aCell); }
public void registerDistributionObject(Scientrace.Object3d anObject) { this.registeredDistributionObjects.Add(anObject); }