本文整理汇总了C#中Scientrace.getSurfaceNormal方法的典型用法代码示例。如果您正苦于以下问题:C# Scientrace.getSurfaceNormal方法的具体用法?C# Scientrace.getSurfaceNormal怎么用?C# Scientrace.getSurfaceNormal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scientrace
的用法示例。
在下文中一共展示了Scientrace.getSurfaceNormal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: write
public override void write(Scientrace.PhysicalObject3d anObject)
{
Scientrace.UnitVector normvec = anObject.getSurfaceNormal();
this.fillPlaneVectors(normvec);
this.write2dHistogramForPlane(anObject, "A = ref x norm", this.plane_a_vecs[normvec]);
this.write2dHistogramForPlane(anObject, "B = norm x A", this.plane_b_vecs[normvec]);
this.write2dHistogramForPlane(anObject, "1D histogram", null);
}
示例2: write2dHistogramForPlane
public void write2dHistogramForPlane(Scientrace.PhysicalObject3d anObject, string plane_descr, Scientrace.UnitVector plane_vector)
{
Scientrace.UnitVector normvec = anObject.getSurfaceNormal();
Dictionary<string, double> angle_histogram = this.getHistogramTemplate();
foreach(Scientrace.Spot casualty in this.tj.spots) {
//only count casualties for current object.
if (casualty.object3d != anObject) continue;
if (casualty == null) {
Console.WriteLine("Error: Casualty is null when writing angle histogram2d for {"+anObject.ToString()+"} plane {"+plane_descr+"}...");
continue;
}
double angle_rad;
if (plane_vector == null) {
angle_rad = anObject.getSurfaceNormal().negative().angleWith(casualty.trace.traceline.direction);
}
else {
//2d unraveling
Scientrace.Vector vecOnPlane = casualty.trace.traceline.direction.projectOnPlaneWithNormal(plane_vector);
//The angle on which the histogram bin is based.
angle_rad = normvec.negative().angleWith(vecOnPlane);
}
string bin = this.radiansToRoundedDegString(angle_rad);
double reweigh_factor = (this.lightsource_weigh_intensity)
? (casualty.trace.lightsource.weighted_intensity/casualty.trace.lightsource.total_lightsource_intensity)
: 1;
//Console.WriteLine("Line: "+casualty.trace.traceline.direction.trico()+" becomes: "+vecOnPlane.trico()+" angle:"+angle_rad+" / "+bin);
this.addToBin(angle_histogram, bin, casualty.intensity*reweigh_factor, true);
}
string angle_histogram_csv_filename = this.tj.exportpath+this.angle_histogram_csv_filename.Replace("%o",anObject.tag).Replace("%t",this.tag).Replace("%s",plane_descr.Replace(" ", "_"));
this.addHist2dConfigVars(normvec, plane_descr);
//this.extra_exportable_config_vars.Add(plane_description, plane_vector);
this.appendWriteWithConfigVariables(angle_histogram_csv_filename, angle_histogram);
}
示例3: write
public override void write(Scientrace.PhysicalObject3d anObject)
{
Dictionary<string, double> angle_histogram = this.getHistogramTemplate();
foreach(Scientrace.Spot casualty in this.tj.spots) {
//only count casualties for current object.
if (casualty.object3d != anObject) continue;
if (casualty == null) {
Console.WriteLine("Error: Casualty is null when writing angle histogram for {"+anObject.ToString()+"}...");
continue;
}
//The angle on which the histogram bin is based.
double angle_rad = anObject.getSurfaceNormal().negative().angleWith(casualty.trace.traceline.direction);
//Moved to new method: radiansToRoundedDegString
/*double angle_deg = angle_rad*180/Math.PI;
double angle_deg_mod =((180+angle_deg)%360)-180;
string bin = this.toResString(angle_deg_mod);*/
string bin = this.radiansToRoundedDegString(angle_rad);
double reweigh_factor = (this.lightsource_weigh_intensity)
? (casualty.trace.lightsource.weighted_intensity/casualty.trace.lightsource.total_lightsource_intensity)
: 1;
this.addToBin(angle_histogram, bin, casualty.intensity*reweigh_factor, true);
/*
//Console.WriteLine("bin: "+bin+", angledegmod:"+angle_deg_mod+", hist_res:"+this.angle_histogram_resolution);
if (angle_histogram.ContainsKey(bin)) //{
angle_histogram[bin] = angle_histogram[bin]+casualty.intensity;
//Console.WriteLine("bin {"+bin+"} increased."); }
else {
this.addToOtherBin(casualty.intensity, angle_histogram);
//Console.WriteLine("WARNING: BIN {"+bin+"} NOT FOUND FOR HISTOGRAM."+angle_deg_mod+"/"+angle_deg);\
} */
}
string angle_histogram_csv_filename = this.tj.exportpath+this.angle_histogram_csv_filename.Replace("%o",anObject.tag);
this.appendWriteWithConfigVariables(angle_histogram_csv_filename, angle_histogram);
}
示例4: exportSVG
public string exportSVG(Scientrace.PhysicalObject3d anObject, Scientrace.SurfaceSide side, Scientrace.PDPSource pdpSource)
{
//Scientrace.Parallelogram surface = anObject.getDistributionSurface();
//this.spotsize = Math.Sqrt(Math.Pow(surface.u.length,2)+Math.Pow(surface.v.length,2))*this.spotdiagonalfraction;
this.spotsize = Math.Sqrt(Math.Pow(anObject.svgxsize,2)+Math.Pow(anObject.svgysize,2))*this.spotdiagonalfraction;
StringBuilder retstr = new StringBuilder(10000000); // this string may become very big, allocating this amount of memory may help.
retstr.Append(this.exportSVGOpening(anObject));
Scientrace.Location loc2d;
StringBuilder pol_lines = new StringBuilder("<!-- START OF POLARISATION LINES -->",300000);
StringBuilder centerSpots = new StringBuilder("<!-- START OF SPOTS CENTERS -->",300000);
//Console.WriteLine("Now writing "+this.spots.Count+" spots");
//int icount = 0;
foreach(Scientrace.Spot casualty in this.spots) {
if ((casualty.object3d == anObject)
&& (anObject.directedTowardsObjectside(side, casualty.trace))) {
loc2d = anObject.getSVG2DLoc(casualty.loc);
// double pol_fac_1 = Math.Pow(casualty.pol_vec_1.length,2)*1.0;//*casualty.pol_vec_1.length * casualty.intensity*3;
// double pol_fac_2 = Math.Pow(casualty.pol_vec_2.length,2)*1.0;//*casualty.pol_vec_2.length * casualty.intensity*3;
double pol_fac_1 = Math.Pow(casualty.pol_vec_1.length,1)*1.00*Math.Sqrt(casualty.intensity);//*casualty.pol_vec_1.length * casualty.intensity*3;
double pol_fac_2 = Math.Pow(casualty.pol_vec_2.length,1)*1.00*Math.Sqrt(casualty.intensity);//*casualty.pol_vec_2.length * casualty.intensity*3;
Scientrace.Vector pol_vec_1_2d = (anObject.get2DLoc(
casualty.pol_vec_1.projectOnPlaneWithNormal(anObject.getSurfaceNormal()).toLocation()
)-anObject.get2DLoc(Location.ZeroLoc())).normaliseIfNotZero() * pol_fac_1;
Scientrace.Vector pol_vec_2_2d = (anObject.get2DLoc(
casualty.pol_vec_2.projectOnPlaneWithNormal(anObject.getSurfaceNormal()).toLocation()
)-anObject.get2DLoc(Location.ZeroLoc())).normaliseIfNotZero() * pol_fac_2;
if (this.svg_export_photoncloud) {
retstr.Append(@"<g>
<circle cx='"+loc2d.x+"' cy='"+(anObject.svgysize-loc2d.y)+"' r='"+(casualty.intensity*this.spotsize)+"' style='"+
"fill:"+this.getPhotonColourForPDPSource(casualty, pdpSource, anObject)
[email protected]";fill-opacity:0.3;stroke:none'>
<title><!-- Tooltip -->"+this.spotDescriptor(casualty, anObject,true)[email protected]"</title>
</circle>
</g>");
} // end if draw photoncloud (to create the frogg-egg kinda image)
centerSpots.Append(@"<g>
<circle cx='"+loc2d.x+"' cy='"+(anObject.svgysize-loc2d.y)+"' r='"+(casualty.intensity*this.spotsize/(this.svg_export_photoncloud?4:1))+"' style='"+
"fill:"+this.getPhotonColourForPDPSource(casualty, pdpSource, anObject)
[email protected]";fill-opacity:8;stroke:none'>
<title><!-- Tooltip -->"+this.spotDescriptor(casualty, anObject,false)[email protected]"</title>
</circle>
</g>");
pol_lines.Append(@"
<line x1='"+(loc2d.x-(pol_vec_1_2d.x*this.spotsize))+"' y1='"+(anObject.svgysize-(loc2d.y-(pol_vec_1_2d.y*this.spotsize)))+"' x2='"+(loc2d.x+(pol_vec_1_2d.x*this.spotsize))+"' y2='"+(anObject.svgysize-(loc2d.y+(pol_vec_1_2d.y*this.spotsize)))+"' style='stroke:rgb(0,96,192);stroke-width:"+(casualty.intensity*this.spotsize/5)[email protected]"' />
<line x1='"+(loc2d.x-(pol_vec_2_2d.x*this.spotsize))+"' y1='"+(anObject.svgysize-(loc2d.y-(pol_vec_2_2d.y*this.spotsize)))+"' x2='"+(loc2d.x+(pol_vec_2_2d.x*this.spotsize))+"' y2='"+(anObject.svgysize-(loc2d.y+(pol_vec_2_2d.y*this.spotsize)))+"' style='stroke:rgb(192,96,0);stroke-width:"+(casualty.intensity*this.spotsize/5)[email protected]"' />
<line x1='"+(loc2d.x-(pol_vec_1_2d.x*this.spotsize))+"' y1='"+(anObject.svgysize-(loc2d.y-(pol_vec_1_2d.y*this.spotsize)))+"' x2='"+(loc2d.x+(pol_vec_1_2d.x*this.spotsize))+"' y2='"+(anObject.svgysize-(loc2d.y+(pol_vec_1_2d.y*this.spotsize)))+"' style='stroke:rgb(256,256,256);stroke-width:"+(casualty.intensity*this.spotsize/8)[email protected]"' />
<line x1='"+(loc2d.x-(pol_vec_2_2d.x*this.spotsize))+"' y1='"+(anObject.svgysize-(loc2d.y-(pol_vec_2_2d.y*this.spotsize)))+"' x2='"+(loc2d.x+(pol_vec_2_2d.x*this.spotsize))+"' y2='"+(anObject.svgysize-(loc2d.y+(pol_vec_2_2d.y*this.spotsize)))+"' style='stroke:rgb(256,256,256);stroke-width:"+(casualty.intensity*this.spotsize/8)[email protected]"' />
");
} // end condition for spot to be on the correct object and from the proper direction
}
centerSpots.Append("<!-- END OF CENTERSPOTS -->");
pol_lines.Append("<!-- END OF POLARISATION LINES -->");
retstr.Append(centerSpots);
retstr.Append(pol_lines);
foreach(Scientrace.SurfaceMarker marker in anObject.markers) {
retstr.Append(marker.exportSVG());
}
if (this.inline_legend) {
retstr.Append("<!-- Start Legend for "+pdpSource.ToString()+" -->");
retstr.Append(this.colourLegend(pdpSource));
retstr.Append("<!-- End Legend for "+pdpSource.ToString()+" -->");
}
retstr.Append("</svg> ");
return retstr.ToString();
}