コード例 #1
0
        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)