/* end of interface IBorder3D implementation */ public override string exportX3D(Object3dEnvironment env) { StringBuilder retsb = new StringBuilder(1024); X3DShapeDrawer x3dsd = new X3DShapeDrawer(); for (double angle = this.radiansMin; angle <= this.radiansMax; angle += (this.radiansMax - this.radiansMin) / this.x3dCurvedSegments) { double red = (((angle - this.radiansMin) / (this.radiansMax - this.radiansMin)) / 2) + 0.3; x3dsd.primaryRGB = red.ToString() + " 0.2 0.2"; //Console.WriteLine("radmin: "+this.radiansMin+ "radmax:"+this.radiansMax+ " iangle:"+angle); //if (angle > 0) { retsb.AppendLine( x3dsd.drawCircle(this.getCenterAtAngleLoc(angle), this.getRadiusAtAngle(angle), this.orientation)); if (this.doubleConvexRing) { retsb.AppendLine( x3dsd.drawCircle(this.getOppositeCenterAtAngleLoc(angle), this.getRadiusAtAngle(angle), this.orientation)); } // } } if (this.radiansMin > 0 && this.x3dCurvedSegments > 0) { retsb.AppendLine(x3dsd.drawCircle(this.getCenterAtAngleLoc(this.radiansMax), this.getRadiusAtAngle(this.radiansMin), this.orientation)); } return(retsb.ToString()); }
public void writeX3DTraces(StringBuilder retsb) { if (this.x3d_line_thickness == 0) { this.writeX3DTracesLines(retsb); return; } string colour = "1 0 0"; foreach (Scientrace.Trace trace in this.traces) { Location fromLoc = trace.traceline.startingpoint; Location toLoc = trace.endloc; Location diffLoc = toLoc - fromLoc; if (diffLoc.length == 0) { continue; // no line, move on. } if (this.x3dWavelengthColourLines) { colour = this.getRedRGB(trace.wavelenght) + " " + this.getGreenRGB(trace.wavelenght) + " " + this.getBlueRGB(trace.wavelenght); } X3DShapeDrawer xsd = new X3DShapeDrawer(); retsb.Append(xsd.getX3DTranslationTag(fromLoc)); retsb.Append(xsd.getX3DRotationTag(new NonzeroVector(0, diffLoc.length, 0), diffLoc.tryToNonzeroVector())); retsb.Append(xsd.getX3DTranslationTag(new Location(0, diffLoc.length * 0.5, 0))); if (this.x3d_draw_direction_arrows) { retsb.Append(@"<Shape><Appearance><Material diffuseColor='" + colour + @"'/></Appearance> <Cone height='" + (4 * this.x3d_line_thickness) + "' bottomRadius='" + (1.5 * this.x3d_line_thickness) + @"' solid='true' bottom='true' /></Shape>"); } retsb.Append(@"<Shape><Appearance><Material diffuseColor='" + colour + @"'/></Appearance> <Cylinder bottom='true' height='" + diffLoc.length + "' radius='" + (this.x3d_line_thickness / 2) + @"' side='true'/></Shape> <!-- Closing Cone + Cylinder transformations --></Transform></Transform></Transform>"); } }
public void writeX3DTraces(StringBuilder retsb) { if (this.x3d_line_thickness == 0) { this.writeX3DTracesLines(retsb); return; } string colour = "1 0 0"; foreach (Scientrace.Trace trace in this.traces) { Location fromLoc = trace.traceline.startingpoint; Location toLoc = trace.endloc; Location diffLoc = toLoc - fromLoc; if (diffLoc.length == 0) continue; // no line, move on. if (this.x3dWavelengthColourLines) { colour = this.getRedRGB(trace.wavelenght)+" "+ this.getGreenRGB(trace.wavelenght)+" "+ this.getBlueRGB(trace.wavelenght); } X3DShapeDrawer xsd = new X3DShapeDrawer(); retsb.Append(xsd.getX3DTranslationTag(fromLoc)); retsb.Append(xsd.getX3DRotationTag(new NonzeroVector(0,diffLoc.length,0), diffLoc.tryToNonzeroVector())); retsb.Append(xsd.getX3DTranslationTag(new Location(0,diffLoc.length*0.5,0))); if (this.x3d_draw_direction_arrows) retsb.Append(@"<Shape><Appearance><Material diffuseColor='"+colour+@"'/></Appearance> <Cone height='"+(4*this.x3d_line_thickness)+"' bottomRadius='"+(1.5*this.x3d_line_thickness)+@"' solid='true' bottom='true' /></Shape>"); retsb.Append(@"<Shape><Appearance><Material diffuseColor='"+colour+@"'/></Appearance> <Cylinder bottom='true' height='"+diffLoc.length+"' radius='"+(this.x3d_line_thickness/2)+@"' side='true'/></Shape> <!-- Closing Cone + Cylinder transformations --></Transform></Transform></Transform>"); } }
public override string exportX3D(Scientrace.Object3dEnvironment env) { double r1 = this.sphere1Radius; double r2 = this.sphere2Radius; //used to say sphere1Radius too? //The lensRadians is the angle made from the center of a sphere along the center of the lens to the side of the lens. double lens1Radians = this.getRadiansSphere1(); double lens2Radians = this.getRadiansSphere2(); Scientrace.NonzeroVector lens1to2Dir = (dummySphere2.loc - dummySphere1.loc).tryToUnitVector()*Math.Sign(r1)*Math.Sign(r2); Scientrace.NonzeroVector lens1Dir = lens1to2Dir*Math.Sign(r2); Scientrace.NonzeroVector lens2Dir = lens1to2Dir*-1*Math.Sign(r1); NonzeroVector baseVec1 = null; NonzeroVector baseVec2 = null; lens1to2Dir.fillOrtogonalVectors(ref baseVec1, ref baseVec2); double lat_circles = 3; double meridians = 12; System.Text.StringBuilder retx3d = new System.Text.StringBuilder(2000); retx3d.AppendLine("<!-- DOUBLECONVEXLENS GRID start -->"); X3DShapeDrawer xsd = new X3DShapeDrawer(); xsd.primaryRGB = "0.4 0 0.2"; retx3d.Append(xsd.drawSphereSlice(this, lat_circles, meridians, this.dummySphere1, 0, lens1Radians, lens1Dir.toUnitVector())); retx3d.Append(xsd.drawSphereSlice(this, lat_circles, meridians, this.dummySphere2, 0, lens2Radians, lens2Dir.toUnitVector())); retx3d.AppendLine("<!-- DOUBLECONVEXLENS GRID end -->"); return retx3d.ToString(); /* Scientrace.Location tNodeLoc; Scientrace.Location tMerConnectLoc; Scientrace.Location tLatConnectLoc; Scientrace.X3DGridPoint tGridPoint; double pi2 = Math.PI*2; retx3d.Append("\t<!-- Convex part -->" ); for (double iSphereCircle = 2*lat_circles; iSphereCircle > 0; iSphereCircle--) { for (double iSphereMerid = 0.5; iSphereMerid < 2*meridians; iSphereMerid++) { //double lat_angle = lensRadians * (iSphereCircle / lat_circles); // theta //double mer_angle = pi2 * (iSphereMerid/meridians); // mer_angle = phi tNodeLoc = this.dummySphere1.getSphericalLoc( baseVec1, baseVec2, lens1to2Dir, lens1Radians * (iSphereCircle / (2*lat_circles)), // lat_angle = theta pi2 * (iSphereMerid/(2*meridians)) // mer_angle = phi ); if (!tNodeLoc.isValid()) throw new NullReferenceException("Cannot calculate base gridpoint at @ "+this.tag); tMerConnectLoc = this.dummySphere1.getSphericalLoc( baseVec1, baseVec2, lens1to2Dir, lens1Radians * (iSphereCircle / (2*lat_circles)), // lat_angle = theta pi2 * ((iSphereMerid+1)/(2*meridians)) // mer_angle = phi ); if (!tMerConnectLoc.isValid()) throw new NullReferenceException("Cannot calculate meridian gridpoint at @ "+this.tag); tLatConnectLoc = this.dummySphere1.getSphericalLoc( baseVec1, baseVec2, lens1to2Dir, lens1Radians * ((iSphereCircle-1) / (2*lat_circles)), // lat_angle = theta pi2 * ((iSphereMerid)/(2*meridians)) // mer_angle = phi ); if (!tLatConnectLoc.isValid()) throw new NullReferenceException("Cannot calculate lateral gridpoint at @ "+this.tag); tGridPoint = new Scientrace.X3DGridPoint(env, tNodeLoc, tMerConnectLoc, tLatConnectLoc); retx3d.AppendLine(tGridPoint.exportX3Dnosphere("0.2 0 0.4 1")); }} // end for iSphereCircle / iSphereMerid retx3d.Append("\t<!-- End of Convex part -->" ); retx3d.Append("<!-- End of DOUBLECONVEXLENS GRID -->"); */ }
/* end of interface IBorder3D implementation */ public override string exportX3D(Object3dEnvironment env) { StringBuilder retsb = new StringBuilder(1024); X3DShapeDrawer x3dsd = new X3DShapeDrawer(); for (double angle = this.radiansMin; angle <= this.radiansMax; angle += (this.radiansMax-this.radiansMin)/this.x3dCurvedSegments) { double red = (((angle-this.radiansMin)/(this.radiansMax-this.radiansMin))/2)+0.3; x3dsd.primaryRGB = red.ToString()+" 0.2 0.2"; //Console.WriteLine("radmin: "+this.radiansMin+ "radmax:"+this.radiansMax+ " iangle:"+angle); //if (angle > 0) { retsb.AppendLine( x3dsd.drawCircle(this.getCenterAtAngleLoc(angle), this.getRadiusAtAngle(angle), this.orientation)); if (this.doubleConvexRing) retsb.AppendLine( x3dsd.drawCircle(this.getOppositeCenterAtAngleLoc(angle), this.getRadiusAtAngle(angle), this.orientation)); // } } if (this.radiansMin > 0 && this.x3dCurvedSegments > 0) retsb.AppendLine(x3dsd.drawCircle(this.getCenterAtAngleLoc(this.radiansMax), this.getRadiusAtAngle(this.radiansMin), this.orientation)); return retsb.ToString(); }
public override string exportX3D(Scientrace.Object3dEnvironment env) { double r1 = this.sphere1Radius; double r2 = this.sphere2Radius; //used to say sphere1Radius too? //The lensRadians is the angle made from the center of a sphere along the center of the lens to the side of the lens. double lens1Radians = this.getRadiansSphere1(); double lens2Radians = this.getRadiansSphere2(); Scientrace.NonzeroVector lens1to2Dir = (dummySphere2.loc - dummySphere1.loc).tryToUnitVector() * Math.Sign(r1) * Math.Sign(r2); Scientrace.NonzeroVector lens1Dir = lens1to2Dir * Math.Sign(r2); Scientrace.NonzeroVector lens2Dir = lens1to2Dir * -1 * Math.Sign(r1); NonzeroVector baseVec1 = null; NonzeroVector baseVec2 = null; lens1to2Dir.fillOrtogonalVectors(ref baseVec1, ref baseVec2); double lat_circles = 3; double meridians = 12; System.Text.StringBuilder retx3d = new System.Text.StringBuilder(2000); retx3d.AppendLine("<!-- DOUBLECONVEXLENS GRID start -->"); X3DShapeDrawer xsd = new X3DShapeDrawer(); xsd.primaryRGB = "0.4 0 0.2"; retx3d.Append(xsd.drawSphereSlice(this, lat_circles, meridians, this.dummySphere1, 0, lens1Radians, lens1Dir.toUnitVector())); retx3d.Append(xsd.drawSphereSlice(this, lat_circles, meridians, this.dummySphere2, 0, lens2Radians, lens2Dir.toUnitVector())); retx3d.AppendLine("<!-- DOUBLECONVEXLENS GRID end -->"); return(retx3d.ToString()); /* * Scientrace.Location tNodeLoc; * Scientrace.Location tMerConnectLoc; * Scientrace.Location tLatConnectLoc; * Scientrace.X3DGridPoint tGridPoint; * double pi2 = Math.PI*2; * * retx3d.Append("\t<!-- Convex part -->" ); * * for (double iSphereCircle = 2*lat_circles; iSphereCircle > 0; iSphereCircle--) { * for (double iSphereMerid = 0.5; iSphereMerid < 2*meridians; iSphereMerid++) { * //double lat_angle = lensRadians * (iSphereCircle / lat_circles); // theta * //double mer_angle = pi2 * (iSphereMerid/meridians); // mer_angle = phi * * tNodeLoc = this.dummySphere1.getSphericalLoc( * baseVec1, baseVec2, * lens1to2Dir, * lens1Radians * (iSphereCircle / (2*lat_circles)), // lat_angle = theta * pi2 * (iSphereMerid/(2*meridians)) // mer_angle = phi * ); * if (!tNodeLoc.isValid()) * throw new NullReferenceException("Cannot calculate base gridpoint at @ "+this.tag); * tMerConnectLoc = this.dummySphere1.getSphericalLoc( * baseVec1, baseVec2, * lens1to2Dir, * lens1Radians * (iSphereCircle / (2*lat_circles)), // lat_angle = theta * pi2 * ((iSphereMerid+1)/(2*meridians)) // mer_angle = phi * ); * if (!tMerConnectLoc.isValid()) * throw new NullReferenceException("Cannot calculate meridian gridpoint at @ "+this.tag); * * tLatConnectLoc = this.dummySphere1.getSphericalLoc( * baseVec1, baseVec2, * lens1to2Dir, * lens1Radians * ((iSphereCircle-1) / (2*lat_circles)), // lat_angle = theta * pi2 * ((iSphereMerid)/(2*meridians)) // mer_angle = phi * ); * if (!tLatConnectLoc.isValid()) * throw new NullReferenceException("Cannot calculate lateral gridpoint at @ "+this.tag); * * tGridPoint = new Scientrace.X3DGridPoint(env, tNodeLoc, tMerConnectLoc, tLatConnectLoc); * retx3d.AppendLine(tGridPoint.exportX3Dnosphere("0.2 0 0.4 1")); * }} // end for iSphereCircle / iSphereMerid * retx3d.Append("\t<!-- End of Convex part -->" ); * retx3d.Append("<!-- End of DOUBLECONVEXLENS GRID -->"); */ } //end string exportX3D(env)