当前位置: 首页>>代码示例>>C#>>正文


C# Scientrace类代码示例

本文整理汇总了C#中Scientrace的典型用法代码示例。如果您正苦于以下问题:C# Scientrace类的具体用法?C# Scientrace怎么用?C# Scientrace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Scientrace类属于命名空间,在下文中一共展示了Scientrace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: containsExclude

 public bool containsExclude(Scientrace.Location aLocation, double excludedMargin)
 {
     if (aLocation == null) { return false; }
     Scientrace.Location sLoc = (aLocation-this.loc); //shifted location based on plane origin
     Scientrace.Location tLoc = this.trf.transform(sLoc); //transformed location based on the plane basevectors and its normal
     return (tLoc.z >= excludedMargin);
 }
开发者ID:JoepBC,项目名称:scientrace,代码行数:7,代码来源:PlaneBorder.cs

示例2: TriangularPrism

        //length inherited from Prism
        public TriangularPrism(Scientrace.Object3dCollection parent, Scientrace.MaterialProperties mprops, 
			Scientrace.Location loc, Scientrace.NonzeroVector width, Scientrace.NonzeroVector height, 
			Scientrace.NonzeroVector length)
            : base(parent, mprops)
        {
            this.paramInit(loc, width, height, length);
        }
开发者ID:JoepBC,项目名称:scientrace,代码行数:8,代码来源:TriangularPrism.cs

示例3: constructPlaneNodeLoc

        public Scientrace.Location constructPlaneNodeLoc(Scientrace.Location planeCenter, double radius,
						double angle, Scientrace.NonzeroVector baseVec1, Scientrace.NonzeroVector baseVec2)
        {
            Scientrace.Vector ix = baseVec1.toVector()*radius*Math.Sin(angle);
            Scientrace.Vector iy = baseVec2.toVector()*radius*Math.Cos(angle);
            return planeCenter+ix+iy;
        }
开发者ID:JoepBC,项目名称:scientrace,代码行数:7,代码来源:PlanoConvexLens.cs

示例4: initCreatedRefractTrace

        public void initCreatedRefractTrace(Trace refractTrace, UnitVector surfaceNormal, Scientrace.Object3d fromObject3d, Scientrace.Object3d toObject3d)
        {
            double oldrefindex = fromObject3d.materialproperties.refractiveindex(this);
            double newrefindex = toObject3d.materialproperties.refractiveindex(this);
            //for definitions on the parameters below, check fullInternalReflects function.

            UnitVector incoming_trace_direction = this.traceline.direction;
            if (incoming_trace_direction.dotProduct(surfaceNormal) > 0) {
            surfaceNormal = surfaceNormal.negative();
            }

            Scientrace.UnitVector nnorm = surfaceNormal.negative();
            Scientrace.Vector incoming_normal_projection = nnorm*(incoming_trace_direction.dotProduct(nnorm));
            Vector L1 = incoming_trace_direction-incoming_normal_projection;
            double L2 = (oldrefindex/newrefindex)*L1.length;

            if (incoming_trace_direction == incoming_normal_projection) {
            //in case of normal incident light: do not refract.
            refractTrace.traceline.direction = incoming_trace_direction;
            return;
            }

            try {
            refractTrace.traceline.direction = ((nnorm*Math.Sqrt(1 - Math.Pow(L2,2)))
                    +(L1.tryToUnitVector()*L2)).tryToUnitVector();
            } catch (ZeroNonzeroVectorException) {
                Console.WriteLine("WARNING: cannot define direction for refraction trace. Using surface normal instead. (L1: "+incoming_trace_direction.trico()+", L2:"+incoming_normal_projection.trico()+").");
                refractTrace.traceline.direction = nnorm;
            } //end try/catch
        }
开发者ID:JoepBC,项目名称:scientrace,代码行数:30,代码来源:Trace-Obsolete_No_Polarisation_Support.cs

示例5: PhysicalObject3d

 public PhysicalObject3d(Object3dCollection parent, Scientrace.MaterialProperties materialproperties)
     : base(parent, materialproperties)
 {
     this.surface_sides = new HashSet<SurfaceSide>() {Scientrace.SurfaceSide.Both};
     //this.surface_sides.Add(Scientrace.SurfaceSide.Both);
     //this.materialproperties = materialproperties;
 }
开发者ID:JoepBC,项目名称:scientrace,代码行数:7,代码来源:PhysicalObject3d.cs

示例6: RandomCircleLightSource

        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));
            }
        }
开发者ID:JoepBC,项目名称:scientrace,代码行数:32,代码来源:RandomCircleLightSource.cs

示例7: exportX3D

        public override string exportX3D(Scientrace.Object3dEnvironment env)
        {
            System.Text.StringBuilder retx3d = new System.Text.StringBuilder("<!-- SPHERE GRID start -->", 10000);

            Scientrace.Location tNodeLoc;
            Scientrace.Location tMerConnectLoc;
            Scientrace.Location tLatConnectLoc;
            Scientrace.X3DGridPoint tGridPoint;

            for (int ic = 0; ic <= this.x3d_circles_of_latitude; ic++) { //0-pi
            for (int im = 0; im < this.x3d_meridians; im++) { //0-2pi

                tNodeLoc = this.getNodeLoc(ic, im);
                tMerConnectLoc =
                    (ic > 0 && ic < this.x3d_meridians) ? // do not connect "points" located at north and south pole
                        this.getNodeLoc(ic, (im+1)%this.x3d_meridians)
                        : null;
                tLatConnectLoc = this.getNodeLoc(ic+1, im);

                // a gridpoint has a location and two neighbour location to which to connect to
                tGridPoint = new Scientrace.X3DGridPoint(env, tNodeLoc,
                    tMerConnectLoc, tLatConnectLoc);
                retx3d.AppendLine(tGridPoint.exportX3DnosphereRGBA("0.4 0.8 0 1"));
                }}
            retx3d.Append("<!-- Sphere grid end -->");
            return retx3d.ToString();
        }
开发者ID:JoepBC,项目名称:scientrace,代码行数:27,代码来源:Sphere.cs

示例8: Intersection

        public Intersection(bool intersects, Scientrace.Object3d object3d)
        {
            this.intersects = intersects;
            this.object3d = object3d;

            this.checkObject();//<- DEBUGGING:
        }
开发者ID:JoepBC,项目名称:scientrace,代码行数:7,代码来源:Intersection.cs

示例9: constructLightSource

        /* TO IMPLEMENT: Class="RandomToSurface"
        <LightSource BeamCount="N" Class="RandomToSurface" Seed="1">
        <Surface Class="circle" Radius="r" />
        <Center xyz="LENSXYZ" />
        <Normal xyz="DIRXYZ" />
        </Surface>
        </LightSource>

        */
        public Scientrace.LightSource constructLightSource(XElement xel, Scientrace.Object3dEnvironment env)
        {
            /* //Special property removed at 20151021
            XElement xspec = xel.Element("Spectrum");
            Scientrace.LightSpectrum aSpectrum = null;
            if (xspec == null) {
            //throw new XMLException("No Spectrum element found for: "+xel.ToString());
            } else {
            XMLSpectrumParser xsp = new XMLSpectrumParser();
            aSpectrum = xsp.parseLightSpectrum(xspec);
            }
            */

            //modified at 20150707
            //ShadowScientrace.ShadowLightSource shadowLS =
            //		new ShadowScientrace.ShadowLightSource(typeof(Scientrace.SpiralLightSource), env, aSpectrum);
            ShadowScientrace.ShadowLightSource shadowLS =
                new ShadowScientrace.ShadowLightSource(null, env);

            this.setClassInfo(xel, shadowLS);

            this.setLightSourceConstructorParams(shadowLS, xel);
            this.setLightSourceSettings(shadowLS, xel);

            return shadowLS.factory("no id");
        }
开发者ID:JoepBC,项目名称:scientrace,代码行数:35,代码来源:ShadowLightSourceConstruct.cs

示例10: exportX3D

        public string exportX3D(Scientrace.Object3dEnvironment env)
        {
            Scientrace.Vector a, b, c, d;
            //square
            a = Vector.ZeroVector();
            b = this.plane.u;
            c = this.plane.u+this.plane.v;
            d = this.plane.v;

            string colstr = "0.5 0.5 0.5 0.2";
            return @"<!-- Start Parallelogram instance -->\n <Transform translation='"+this.plane.loc.trico()[email protected]"'>
            <Shape>
            <!-- Coordinate prism sequence (matches coordIndex actually) 0 1 2 3 0 -->
            <LineSet vertexCount='5'>
            <Coordinate point='
            "+a.tricon()+b.tricon()+c.tricon()+d.tricon()+a.tricon()+"'/>" +

            /*@"<ColorRGBA color='0 1 0 1 0 1 0 1
            0 1 0 1 0 1 0 1
            0 1 0 1 0 1 0 1
            0 1 0 1 0 1 0 1' />
            </LineSet>" + */
            @"<ColorRGBA color='"+colstr +" "+colstr +" "+colstr +" "+colstr +" "+colstr +" "+colstr +" "+colstr +" "+colstr [email protected]"' />
            </LineSet>" +
            @"      </Shape>" +
            @"    </Transform>\n<!-- End Parallelogram instance -->";
        }
开发者ID:JoepBC,项目名称:scientrace,代码行数:27,代码来源:Parallelogram.cs

示例11: getCustomTracesListFromXData

        public List<Scientrace.Trace> getCustomTracesListFromXData(XElement xlight,
												Scientrace.Object3dEnvironment env)
        {
            string traces_filename = (this.X.getXStringByName(xlight, "Filename", null));
            if (traces_filename != null)
                if (System.IO.File.Exists(traces_filename)) {
                    XDocument xd = XDocument.Load(traces_filename);
                    return this.getCustomTracesListFromXData(xd.Element("LightSource"), env);
                    } else throw new System.IO.FileNotFoundException("CustomTraces filename ("+traces_filename+") does not exist.");
            // If there aren't any Trace sub-Elements, you might as well stop here (return null)
            if (!xlight.Elements("Trace").Any())
                        return null;
            List <Scientrace.Trace> customtraces = new List<Scientrace.Trace>();
            foreach (XElement xtrace in xlight.Elements("Trace")) {
                double wavelength = this.X.getXDouble(xtrace, "Wavelength",
                                        (this.X.getXDouble(xtrace, "m",
                                            ((this.X.getXDouble(xtrace, "nm", -1))*1E-9))
                                            )
                                        );
                if (wavelength <= 0) {
                    throw new XMLException("Error parsing wavelength from CustomTraces Lightsource. XML Source: \n"+
                        xtrace.ToString());
                    }
                double intensity = this.X.getXDouble(xtrace, "Intensity", 1);
                Scientrace.Location loc = this.X.getXLocation(xtrace, "Location");
                Scientrace.UnitVector dir = this.X.getXNzVectorByName(xtrace, "Direction").toUnitVector();
                customtraces.Add(
                                 new Scientrace.Trace(wavelength, null, new Scientrace.Line(loc, dir),
                                                      env, intensity, intensity)
                                 );
                }
            return customtraces;
        }
开发者ID:JoepBC,项目名称:scientrace,代码行数:33,代码来源:ShadowLightSourceConstruct.cs

示例12: orientedAgainst

 public new UnitVector orientedAgainst(Scientrace.Vector aVector)
 {
     if (aVector.dotProduct(this) > 0) {
     return this.negative();
     }
     return this;
 }
开发者ID:JoepBC,项目名称:scientrace,代码行数:7,代码来源:UnitVector.cs

示例13: formulaVector

 public Scientrace.Vector formulaVector(Scientrace.Vector aVector, XElement xformula)
 {
     string f_x = "x";
     string f_y = "y";
     string f_z = "z";
     if (xformula.Attribute("xyz") != null) {
     try {
         string xyz = xformula.Attribute("xyz").Value;
         char[] delimiterChars = { ';', '\t' };
         string[] elements = xyz.Split(delimiterChars);
         if (elements.Length !=3) {
             throw new XMLException("Element "+xformula.ToString()+" has \""+elements.Length+ "\" != 3 valid vector elements. ");
             }
         f_x=elements[0];
         f_y=elements[1];
         f_z=elements[2];
         } catch { throw new XMLException("Formula "+xformula.ToString()+" does not have proper parameters for {xyz} attribute (can't parse {"+xformula.Attribute("xyz").Value.ToString()+"}. Perhaps incorrect use of PreProcess variables or decimal separators?)."); }
     } // attribute "xyz"
     f_x = this.getXStringByName(xformula, "x", f_x);
     f_y = this.getXStringByName(xformula, "y", f_y);
     f_z = this.getXStringByName(xformula, "z", f_z);
     Dictionary<string, object> replace_vectors = new Dictionary<string, object>(){{"x", (decimal)aVector.x}, {"y", (decimal)aVector.y}, {"z", (decimal)aVector.z} };
     return new Scientrace.Vector(
     Scientrace.MathStrings.solveString(f_x, replace_vectors),
     Scientrace.MathStrings.solveString(f_y, replace_vectors),
     Scientrace.MathStrings.solveString(f_z, replace_vectors)
     );
 }
开发者ID:JoepBC,项目名称:scientrace,代码行数:28,代码来源:CustomXMLDocumentOperations.cs

示例14: getColorFromHTML

 public Scientrace.RGBColor getColorFromHTML(string varname, Scientrace.RGBColor defval)
 {
     Scientrace.RGBColor retval;
     retval = Scientrace.RGBColor.FromHTML(this.getString(varname));
     if (retval == null) return defval;
     return retval;
 }
开发者ID:JoepBC,项目名称:scientrace,代码行数:7,代码来源:ShadowClasses.cs

示例15: angleToRGB

        public string angleToRGB(Scientrace.Spot aCasualty, PhysicalObject3d physObj)
        {
            UnitVector inAngle = aCasualty.trace.traceline.direction;
            Scientrace.Parallelogram pg = physObj.getDistributionSurface();
            Scientrace.NonzeroVector norm = physObj.getSurfaceNormal();

            UnitVector y = pg.plane.v.toUnitVector();
            UnitVector x = null;
            try {
            x = norm.crossProduct(y).tryToUnitVector();
            } catch { throw new ZeroNonzeroVectorException("The vertical vector (plane.v) is parallel to the unit normal.");
            }
            double dx = x.dotProduct(inAngle);
            double dy = y.dotProduct(inAngle);

            double lengthFraction = Math.Sqrt((dx*dx)+(dy*dy));
            //Console.WriteLine("Length: "+lengthFraction+ " vs: "+((x*dx)+(y*dy)).length);

            double angle = Math.Atan2(dy, dx);

            return this.angleToHTML(angle, 2*Math.Asin(lengthFraction)/Math.PI);

            //physObj.getSurfaceNormal()
            //aCasualty.object3d.
            //		throw new Exception("Not yet implemented");
        }
开发者ID:JoepBC,项目名称:scientrace,代码行数:26,代码来源:TraceJournal-Image_Data_Export.cs


注:本文中的Scientrace类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。