public void writeX3DAngles(Scientrace.Object3dEnvironment env, StringBuilder retsb)
        {
            Scientrace.Location tloc;
            foreach (Scientrace.Angle angle in this.angles)
            {
                tloc = angle.getLocation();
                Scientrace.X3DGridPoint x3dgp = new Scientrace.X3DGridPoint(env, tloc,
                                                                            tloc + angle.intersection.enter.flatshape.plane.u.toUnitVector().toLocation() * (env.radius / 100),
                                                                            tloc + angle.intersection.enter.flatshape.plane.v.toUnitVector().toLocation() * (env.radius / 100));
                //Console.WriteLine("Writing spot "+angle.ToString()+" to X3D");
                if (this.drawInteractionPlanes)
                {
                    retsb.Append(x3dgp.exportX3DnosphereRGB("1 1 0"));
                }
                if (this.drawInteractionNormals)
                {
                    retsb.Append(X3DGridPoint.get_RGBA_Line_XML(tloc, tloc + angle.intersection.enter.flatshape.plane.getNorm().negative() * 0.125, "1 0 1 0.4"));
                }
                retsb.Append(@"
<Transform scale='" + (env.radius / 1250).ToString() + " " + (env.radius / 1250).ToString() + " " + (env.radius / 1250).ToString() + @"' translation='" + angle.getLocation().trico() + @"'>
<Shape>
<Sphere /> 
<Appearance>
<Material emissiveColor='0 1 0' transparency='" + (1 - angle.fromTrace.intensity) + @"' /><!--angle-->
</Appearance> 
</Shape>
</Transform> ");
            }
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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;
        }
 public void writeX3DAngles(Scientrace.Object3dEnvironment env, StringBuilder retsb)
 {
     Scientrace.Location tloc;
     foreach (Scientrace.Angle angle in this.angles) {
     tloc = angle.getLocation();
     Scientrace.X3DGridPoint x3dgp = new Scientrace.X3DGridPoint(env, tloc,
                                         tloc+angle.intersection.enter.flatshape.plane.u.toUnitVector().toLocation()*(env.radius/100),
                                         tloc+angle.intersection.enter.flatshape.plane.v.toUnitVector().toLocation()*(env.radius/100));
     //Console.WriteLine("Writing spot "+angle.ToString()+" to X3D");
     if (this.drawInteractionPlanes) {
         retsb.Append(x3dgp.exportX3DnosphereRGB("1 1 0"));
         }
     if (this.drawInteractionNormals) {
         retsb.Append(X3DGridPoint.get_RGBA_Line_XML(tloc, tloc+angle.intersection.enter.flatshape.plane.getNorm().negative()*0.125, "1 0 1 0.4"));
         }
     retsb.Append(@"
     <Transform scale='"+(env.radius/1250).ToString()+" "+(env.radius/1250).ToString()+" "+(env.radius/1250).ToString()+@"' translation='"+angle.getLocation().trico()+@"'>
     <Shape>
     <Sphere />
     <Appearance>
     <Material emissiveColor='0 1 0' transparency='"+(1-angle.fromTrace.intensity)+@"' /><!--angle-->
     </Appearance>
     </Shape>
     </Transform> ");
     }
 }