public void TestIntersectionByVectorArray3() { Scientrace.Object3dEnvironment env = new Scientrace.Object3dEnvironment(Scientrace.AirProperties.Instance, 100); Scientrace.Line beam = new Scientrace.Line(10, 10, 10, -1, -1, 0); Scientrace.LightSource light = new Scientrace.SingleRaySource(beam, 10, new Scientrace.AM15Spectrum(1), env); Scientrace.Trace trace = new Scientrace.Trace(500.0E-9, light, beam, env,1,1); Console.WriteLine(trace.ToString()); //Scientrace.Vector v = new Scientrace.Vector(10,10,10); Scientrace.IntersectionPoint[] ips = new Scientrace.IntersectionPoint[2]; ips[0] = null; ips[1] = null; //Scientrace.Intersection intr = new Scientrace.Intersection(trace, ips); //Assert.IsFalse(intr.intersects); }
public void Testbaseintersection1() { Scientrace.Object3dEnvironment env = new Scientrace.Object3dEnvironment(Scientrace.AirProperties.Instance, 100); /* Scientrace.CylindricalBorder cbord = new Scientrace.CylindricalBorder( new Scientrace.Location(0,0,0), new Scientrace.NonzeroVector(0,0,10), 20);*/ Scientrace.CylindricalBorder cborder = new Scientrace.CylindricalBorder( new Scientrace.Location(-10,10,-10), new Scientrace.NonzeroVector(-1,-1,0),5); Scientrace.ParabolicMirror pm = new Scientrace.ParabolicMirror(env, Scientrace.PerfectMirror.Instance, new Scientrace.Location(0,1,0), new Scientrace.UnitVector(0,0,1), 1, cborder); Scientrace.Line traceline = new Scientrace.Line(2,0,0,0,1,4); Scientrace.IntersectionPoint[] intr = pm.baseintersections(traceline); Assert.AreEqual(true, traceline.throughLocation(intr[0].loc, 0.0001)); Assert.AreEqual(new Scientrace.Location(2,2,8) ,intr[0].loc); }
public override string exportX3D(Scientrace.Object3dEnvironment env) { //TODO: try to transform to indexedlineset Scientrace.Vector a, b, c, d, e, f, g, h; a = this.width; //front circle edges b = this.height; c = this.width.negative(); d = this.height.negative(); e = this.length + this.width; //back triangle f = this.length + this.height; g = this.length - this.width; h = this.length - this.height; //circle front //circle back (translated out of the "loc" starting point) //also end ratation transform. The connecting lines don't need that. //lineset for connecting lines to make the cylinder shape visible //connecting circles Scientrace.Plane circleplane = new Scientrace.Plane(new Scientrace.Location(0, 0, 0), width, height); return("<!-- Start CircularPrism instance -->\n<Transform translation='" + this.loc.trico() + "'>" + circleplane.x3dRotationTransform() + "<Shape>" + "<Circle2D radius='" + this.width.length + "' containerField='geometry'/>" + "</Shape></Transform>" + "<Transform translation='" + this.length.trico() + "'>" + circleplane.x3dRotationTransform() + "<Shape><Circle2D radius='" + this.width.length + "' containerField='geometry'/>" + "</Shape>" + "</Transform>" + "</Transform>" + "<Shape>" + "<LineSet vertexCount='2 2 2 2'>" + "<Coordinate point='" + a.tricon() + e.tricon() + b.tricon() + f.tricon() + c.tricon() + g.tricon() + d.tricon() + h.tricon() + "'/>" + " </LineSet> </Shape> </Transform>\n<!-- End CircularPrism instance -->"); // <Color color='1 0 0 1 0.5 0 1 1 0 0 1 0 1 0 0 0 0 1 0.8 0 0.8 0.3 0 0.3 1 1 1 0 0 1 1 0 0 0 0 1 1 0.5 0 0.8 0 0.8 1 1 0 0.3 0 0.3 0 1 0 1 1 1'/> }
public string exportX3D(Scientrace.Object3dEnvironment env) { //Console.WriteLine("Writing journal to X3D"); StringBuilder retsb = new StringBuilder(500000); //let's just preserve 0.5MB's for starters. Much faster than continuously increasing. if (this.drawTraces) { this.writeX3DTraces(retsb); } if (this.drawAngles) { this.writeX3DAngles(env, retsb); } if (this.drawSpots) { this.writeX3DSpots(env, retsb); } if (this.drawCasualties) { this.writeCasualties(env, retsb); } return(retsb.ToString()); }
public RandomCircleLightSource(Scientrace.Object3dEnvironment env, Scientrace.Location center, Scientrace.UnitVector direction, Scientrace.Plane plane, double radius, int linecount, LightSpectrum spectrum) : base(env) { //this.direction = direction; Random randNum = new Random(); Scientrace.UnitVector urange, vrange; double r1, r2; urange = plane.u.toUnitVector(); vrange = plane.v.toUnitVector(); Scientrace.Line line; for (int iline = 0; iline < linecount; iline++) { //Scientrace.Line line = new Scientrace.Line(loc+(urange*randNum.NextDouble()+(vrange*randNum.NextDouble())).toLocation(), direction); r1 = 1 - randNum.NextDouble() * 2; r2 = 1 - randNum.NextDouble() * 2; if (Math.Pow(r1, 2) + Math.Pow(r2, 2) < 1) { line = new Scientrace.Line(center + ((urange * r1 * radius) + (vrange * r2 * radius)).toLocation(), direction); } else { iline--; continue; } //this.traces.Add(new Scientrace.Trace(wavelength*0.6, this, line, env)); //this.traces.Add(new Scientrace.Trace(wavelength*0.8, this, line, env)); //double wavelength = wlmin+(randNum.NextDouble()*(wlmax-wlmin)); double wavelength = spectrum.wl(iline); double intensity = spectrum.it(iline); Console.WriteLine("Warning: ParallelRandomCylindricalLightSource does not use modulo yet"); this.addTrace(new Scientrace.Trace(wavelength, this, line, env, intensity, intensity)); //this.traces.Add(new Scientrace.Trace(wavelength*1.2, this, line, env)); //this.traces.Add(new Scientrace.Trace(wavelength*1.4, this, line, env)); } }
public ScientraceBatch(string batchdir, Scientrace.Object3dEnvironment env, int numberOfCycles) { this.env = env; this.batchdir = batchdir; this.numberOfCycles = numberOfCycles; }
public CustomTracesLightSource(Scientrace.Object3dEnvironment env) : base(env) { }
public override string exportX3D(Scientrace.Object3dEnvironment env) { Scientrace.Location h1 = this.planoCenterLoc(); double r = this.sphereRadius; double x = this.getLensRadius(); double lensRadians = Math.Asin(x / r); NonzeroVector baseVecZ = this.lensPlane.getNormal(); NonzeroVector baseVec1 = null; NonzeroVector baseVec2 = null; baseVecZ.fillOrtogonalVectors(ref baseVec1, ref baseVec2); double lat_circles = 3; double meridians = 12; System.Text.StringBuilder retx3d = new System.Text.StringBuilder("<!-- PLANOCONVEXLENS GRID start -->", 1024); retx3d.Append("\t<!-- Plano part -->"); Scientrace.Location tNodeLoc; Scientrace.Location tMerConnectLoc; Scientrace.Location tLatConnectLoc; Scientrace.X3DGridPoint tGridPoint; double pi2 = Math.PI * 2; for (double iPlaneCircle = lat_circles; iPlaneCircle > 0; iPlaneCircle--) { for (double iPlaneMerid = 0; iPlaneMerid < meridians; iPlaneMerid++) { tNodeLoc = this.constructPlaneNodeLoc(h1, x * iPlaneCircle / lat_circles, pi2 * iPlaneMerid / meridians, baseVec1, baseVec2); tMerConnectLoc = this.constructPlaneNodeLoc(h1, x * iPlaneCircle / lat_circles, pi2 * (iPlaneMerid + 1) / meridians, baseVec1, baseVec2); tLatConnectLoc = this.constructPlaneNodeLoc(h1, x * (iPlaneCircle - 1) / lat_circles, pi2 * iPlaneMerid / meridians, baseVec1, baseVec2); tGridPoint = new Scientrace.X3DGridPoint(env, tNodeLoc, tMerConnectLoc, tLatConnectLoc); retx3d.AppendLine(tGridPoint.exportX3DnosphereRGBA("0.4 0 0.2 1")); } } //end for iPlaneCircles / iPlaneMerid retx3d.Append("\t<!-- End of plano part -->"); 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.constructSphereNodeLoc( lensRadians * (iSphereCircle / (2 * lat_circles)), // lat_angle = theta pi2 * (iSphereMerid / (2 * meridians)), // mer_angle = phi baseVec1, baseVec2, baseVecZ); tMerConnectLoc = this.constructSphereNodeLoc( lensRadians * (iSphereCircle / (2 * lat_circles)), // lat_angle = theta pi2 * ((iSphereMerid + 1) / (2 * meridians)), // mer_angle = phi baseVec1, baseVec2, baseVecZ); tLatConnectLoc = this.constructSphereNodeLoc( lensRadians * ((iSphereCircle - 1) / (2 * lat_circles)), // lat_angle = theta pi2 * (iSphereMerid / (2 * meridians)), // mer_angle = phi baseVec1, baseVec2, baseVecZ); tGridPoint = new Scientrace.X3DGridPoint(env, tNodeLoc, tMerConnectLoc, tLatConnectLoc); retx3d.AppendLine(tGridPoint.exportX3DnosphereRGBA("0.2 0 0.4 1")); } } // end for iSphereCircle / iSphereMerid retx3d.Append("\t<!-- Convex part -->"); retx3d.Append("\t<!-- End of Convex part -->"); retx3d.Append("<!-- End of PLANOCONVEXLENS GRID -->"); return(retx3d.ToString()); } //end string exportX3D(env)
public static double CalcRadiusFromEnv(Scientrace.Object3dEnvironment env) { return(env.radius / 1200); }
public override string exportX3D(Scientrace.Object3dEnvironment env) { int steps = this.exportX3Dgridsteps; Scientrace.AbstractGridBorder cborder = this.cborder; // Scientrace.VectorTransform cbordertrf = cborder.getTransform(); //Generate a rotating grid! Scientrace.VectorTransform cbordertrf = cborder.getGridTransform(this.zaxis); //Console.WriteLine("CBTRFcp: "+cbordertrf.ToCompactString()); /* * stloc: starting location actually representing the center of the border, * from there in the orthonormal direction of this border the collision points with * the parabolic mirror will be found (from -radius to +radius in both transform-directions */ Scientrace.Location stloc = cborder.getOrthoStartCenterLoc();// - cborder.getOthoDirection(); Scientrace.IntersectionPoint[] iparr, iparre, iparrs; Scientrace.Intersection cintr, eintr, sintr; /* * eloc is the location "east" of the current node, sloc "south" for drawing a grid * of course are terms east and south symbolic */ Scientrace.Location eloc, sloc; Scientrace.Line cline, eline, sline; //double r = cborder.getRadius(); double r1 = cborder.getURadius(); double r2 = cborder.getVRadius(); Scientrace.Vector v1 = cbordertrf.u.tryToUnitVector().toVector(); Scientrace.Vector v2 = cbordertrf.v.tryToUnitVector().toVector();; string retstr = ""; Scientrace.X3DGridPoint concentrationpoint = new Scientrace.X3DGridPoint(env, this.getConcentrationPoint(), null, null); retstr = concentrationpoint.x3DSphere(env.radius / 1000, "1 0 1", 0.5); retstr += concentrationpoint.x3DLineTo(this.loc, "1 0 1 1"); for (double ix = 0.5; ix < steps; ix++) { for (double iy = 0.5; iy <= steps; iy++) { /* Drawing a grid of lines in direction "border.orthodirection" to ParabolicMirror, * at every intersection a gridpoint is located. "cline" are those ortho-dir lines */ cline = new Scientrace.Line(((stloc - (v1 * r1) - (v2 * r2)) + (v1 * (r1 * 2 * (ix / steps))) + (v2 * (r2 * 2 * (iy / steps)))).toLocation(), cborder.getOrthoDirection()); // cborder.directionlength.toUnitVector()); /* USE THE "checkborder = false" function below to always * show the grid-points, also outside borders * iparr is the IntersectionPoint at the Parabolic Mirror for the current ix/iy iteration */ iparr = this.realIntersections(cline, true); /* DEBUG INFO foreach (IntersectionPoint ip in iparr) { * if (ip!=null) { * Console.WriteLine("IP AT: "+ip.ToString()); * } else { * Console.WriteLine("NO IP FROM: "+((stloc-(v1*r)-(v2*r))+(v1*(r*2*(ix/steps)))+(v2*(r*2*(iy/steps)))) +" AND "+cborder.getOrthoDirection()); * } * }*/ eline = new Scientrace.Line(((stloc - (v1 * r1) - (v2 * r2)) + (v1 * (r1 * 2 * ((ix + 1) / steps))) + (v2 * (r2 * 2 * (iy / steps)))).toLocation(), cborder.getOrthoDirection()); // cborder.directionlength.toUnitVector()); iparre = this.realIntersections(eline, true); //defining "east" neighbour eintr = new Intersection(eline, iparre, this); if (eintr.intersects) { eloc = eintr.enter.loc; } else { eloc = null; } sline = new Scientrace.Line(((stloc - (v1 * r1) - (v2 * r2)) + (v1 * (r1 * 2 * ((ix) / steps))) + (v2 * (r2 * 2 * ((iy + 1) / steps)))).toLocation(), cborder.getOrthoDirection()); // cborder.directionlength.toUnitVector()); iparrs = this.realIntersections(sline, true); //defining "south" neighbour sintr = new Intersection(sline, iparrs, this); if (sintr.intersects) { sloc = sintr.enter.loc; } else { sloc = null; } /* "central" point * where does line "cline" with intersections "iparr" intersect this object? */ cintr = new Intersection(cline, iparr, this, true); if (cintr.intersects) //add existing gridpoints { if (this.x3dgridspheres) { retstr = retstr + new X3DGridPoint(env, cintr.enter.loc, eloc, sloc).exportX3D(); } else { retstr = retstr + new X3DGridPoint(env, cintr.enter.loc, eloc, sloc).exportX3DnosphereRGBA("0 0 1 1"); } } } } //Console.WriteLine("!!!"+retstr); return(retstr + cborder.exportX3D(env)); }
public TestLight(Scientrace.Object3dEnvironment env, DistributionPattern dispat, SpatialDistribution spadis, Scientrace.NonzeroVector mean_direction, double maxangle, int raycount) : base(env) { /*UniformTraceModifier utm = new UniformTraceModifier( * //DistributionPattern.ProjectedSpiralGrid, * //DistributionPattern.SphericalSpiralGrid, * DistributionPattern.SingleCircle, * //DistributionPattern.SquareGrid, * * //SpatialDistribution.UniformProjections, * SpatialDistribution.UniformAngles, * new Scientrace.NonzeroVector(1,0,0), * new Scientrace.NonzeroVector(0,1,0), * new Scientrace.NonzeroVector(0,0,1));*/ UniformTraceModifier utm = new UniformTraceModifier( dispat, spadis, mean_direction); utm.setMaxAngle(maxangle); //Console.WriteLine("MAXANGLEJ: "+(maxangle*180/Math.PI)); //Console.WriteLine("MAXANGLEK: "+(utm.maxangle*180/Math.PI)); int arraysize = raycount; double[] wavelengths = new double[arraysize]; for (int k = 0; k < arraysize; k++) { wavelengths[k] = 400E-9; } /*double[] wavelengths = new double[100]{400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9}; */ /* double[] wavelengths = new double[15]{400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9, * 400E-9, 400E-9, 400E-9, 400E-9, 400E-9};*/ List <Scientrace.Location> locs = this.getLocs(); int i = 0; foreach (double lambda in wavelengths) { //Scientrace.Line ray = new Line(new Location(0, 0.0, 0.0), utm.modify(++i,wavelengths.Length).toUnitVector()); //start at node 1 -> ++i ! //this.traces.Add(new Scientrace.Trace(lambda, this, ray, env, 1 ,1)); foreach (Location aLoc in locs) { this.addTracesLoc(lambda, aLoc, utm, env, i++, wavelengths.Length); } } }
public virtual string exportX3D(Scientrace.Object3dEnvironment env) { return("<!-- X3D export not implemented for type of border -->"); }
public ParallelLightSource(Scientrace.Object3dEnvironment env) : base(env) { }
public ShadowLightSource(Type lightSourceType, Scientrace.Object3dEnvironment anObject3dEnvironment) { //Special property removed at 20151021 , Scientrace.LightSpectrum aSpectrum) { this.env = anObject3dEnvironment; //Special property removed at 20151021 this.spectrum = aSpectrum; this.class_type = lightSourceType; }
public ShadowLightSource(Type lightSourceType, Scientrace.Object3dEnvironment anObject3dEnvironment) //Special property removed at 20151021 , Scientrace.LightSpectrum aSpectrum) { { this.env = anObject3dEnvironment; //Special property removed at 20151021 this.spectrum = aSpectrum; this.class_type = lightSourceType; }
public Scientrace.SpiralLightSource setSpiralLightFromXData(XElement xlight, List <Scientrace.UniformTraceModifier> utms, Scientrace.Object3dEnvironment env) { /* "Spiral" * d class.radius, d class.loops, d distance, i beamcount, i maxinteractions, d minintensity * i modulomultiplier, str spectrum, vec location, vec direction */ double radius = this.X.getXDouble(xlight.Attribute("Radius")); if (radius < 0) { throw new ArgumentOutOfRangeException("Radius " + radius + " out of range"); } double distance = this.X.getXDouble(xlight.Attribute("Distance"), 0); int beamcount = this.X.getXInt(xlight.Attribute("RayCount"), this.X.getXInt(xlight.Attribute("BeamCount"))); //int maxinteractions = this.X.getXInt(xlight, "MaxInteractions", 8); //default value max_interactions -> 8 double minintensity = this.X.getXDouble(xlight, "MinIntensity", 0.2); //default minimum intensity for tracing set to 1% //Spiralspecific double loops = this.X.getXDouble(xlight, "Loops", -1); if (loops == -1) { loops = 1.0154 * Math.Pow(Math.PI * 2 * (1 - Math.Sqrt(((double)beamcount - 1) / (double)beamcount)), -0.5); Console.WriteLine("Number of loops for " + beamcount + " beams set to: {" + loops.ToString("#,0.000") + "}."); } Scientrace.NonzeroVector light_direction = this.X.getXNzVector(xlight.Element("Direction")); Scientrace.NonzeroVector spiral_axis = this.X.getXNzVector(xlight.Element("SpiralAxis")); Scientrace.Location centerloc = this.X.getXVector(xlight.Element("Location")).toLocation(); /*Scientrace.Location locoffset = (light_direction.toVector().negative()*distance).toLocation(); //distance cm above surface * Scientrace.Location loc = locoffset + centerloc; */ XMLSpectrumParser xsp = new XMLSpectrumParser(); Scientrace.LightSpectrum spectrum = xsp.parseLightSpectrum(xlight.Element("Spectrum")); if (spectrum == null) { throw new Exception("LightSpectrum " + xlight.Element("Spectrum").ToString() + " unknown"); } double divangle = 0; double divdistance = 0; Scientrace.NonzeroVector divpinvec = null; //= new Scientrace.NonzeroVector(0,1,0); int divsteps = 1; bool divincludebase = true; this.getDivergence(xlight, ref divangle, ref divpinvec, ref divdistance, ref divincludebase, ref divsteps); if (divangle > 0) { if (divpinvec.crossProduct(light_direction).length == 0) { throw new ArgumentOutOfRangeException("divpinvec", "Divergence Pinvector (" + divpinvec.trico() + ") is parallel to light directon (" + light_direction.trico() + ")"); } } // INSERT OPERATION THAT MAKES BOTH SPIRAL PLANE VECTORS ORTHOGONAL TO DIRECTION Scientrace.Plane spiralplane = Scientrace.Plane.newPlaneOrthogonalTo(centerloc, spiral_axis); //Scientrace.NonzeroVector direction = light_direction.tryToUnitVector(); Scientrace.SpiralLightSource retlight = new Scientrace.SpiralLightSource(env, centerloc, light_direction.toUnitVector(), spiralplane, beamcount, radius, loops, distance, spectrum); /* BEFORE REMOVAL OF DISPERSION_STEPS Scientrace.LightSource retlight = new Scientrace.SpiralLightSource(env, loc, light_direction.toUnitVector(), * spiralplane, beamcount, radius, loops, spectrum, * divangle, divpinvec, divdistance, divincludebase, divsteps); */ //retlight.max_interactions = maxinteractions; retlight.minimum_intensity_fraction = minintensity; retlight.lightsource_modifiers.AddRange(utms); //retlight.createStartTraces(); return(retlight); }
public Scientrace.Object3dEnvironment parseXEnv(XElement xenv) { //Create the collection itself with its properties first. Scientrace.Object3dEnvironment retenv; // Creating "the entire object-space" double env_radius = this.X.getXDouble(xenv, "Radius", -1); if (env_radius == -1) { Console.WriteLine("Warning: ObjectEnvironment has no radius attribute. Using 16 as an arbitrary default. You might want to change this."); env_radius = 16; } string environment_material_id = this.X.getXStringByName(xenv, "Environment", "air"); ScientraceXMLParser.readCameraSettings(xenv); Scientrace.MaterialProperties env_material = Scientrace.MaterialProperties.FromIdentifier(environment_material_id); retenv = new Scientrace.Object3dEnvironment(env_material, env_radius); retenv.perishAtBorder = true; retenv.tag = this.X.getXStringByName(xenv, "Tag", "ScientraceXML_Setup"); //Parsing lightsources this.lp = new XMLLightSourceParser(retenv); this.lp.parseLightsources(xenv, retenv); //ADDING UNDERLYING BODIES/OBJECTS this.parseXObject3dCollectionContent(xenv, retenv); //return environment return retenv; }
// public XMLLightSourceParser(XElement xel, CustomXMLDocumentOperations X, Scientrace.Object3dEnvironment env): base(xel, X) { public XMLLightSourceParser(Scientrace.Object3dEnvironment env) : base() { this.parentcollection = env; }
public abstract string exportX3D(Scientrace.Object3dEnvironment env);
public X3DGridPoint(Scientrace.Object3dEnvironment env, Scientrace.Location loc, Scientrace.Location east, Scientrace.Location south) { this.init(X3DGridPoint.CalcRadiusFromEnv(env), loc, east, south); }
public SingleRaySource(Scientrace.Line rayline, int raycount, LightSpectrum spectrum, Scientrace.Object3dEnvironment env) : base(env) { this.weighted_intensity = spectrum.total_intensity; this.spectrum = spectrum; this.linecount = raycount; this.ray = rayline; }
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)