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


C# Trace.ToCompactString方法代码示例

本文整理汇总了C#中Trace.ToCompactString方法的典型用法代码示例。如果您正苦于以下问题:C# Trace.ToCompactString方法的具体用法?C# Trace.ToCompactString怎么用?C# Trace.ToCompactString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Trace的用法示例。


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

示例1: intersects

        public override Intersection intersects(Trace trace)
        {
            Scientrace.Intersection firstIntersection = new Scientrace.Intersection(false, null);
            Scientrace.Intersection currentintersection = new Scientrace.Intersection(false, null);
            double? firstdistance = null;
            double currentdistance;

            SortedList slobjects = new SortedList();
            //Console.WriteLine(this.tag+" HAS "+this.objects.Count+ " o3ds");
            //copying (by reference of course) all objects to a sortedlist.
            foreach (Object3d iobject3d in this.objects) {
            //Console.WriteLine("POKING "+ iobject3d.tag);
            slobjects.Add(iobject3d.parseOrder, iobject3d);
            }
            foreach (DictionaryEntry deObject3d in slobjects) {
            Object3d iObject = (Object3d)deObject3d.Value;
            //validating currentintersection:
            currentintersection = iObject.intersectsBefore(trace, currentintersection);

            /*if (currentintersection==null) { continue; }
            if (currentintersection.enter==null) { continue; }
            if (currentintersection.exit==null) { continue; } */

            //currentintersection = iObject.intersects(trace);

            /*foreach (Object3d iobject3d in this.objects) {
            currentintersection = iobject3dl.intersects(trace);*/
            REPARSE:
            if (!currentintersection.intersects) {
                continue; //no intersection with this object? Try next object in collection (continue)
            }

            if ((currentintersection.enter.loc-trace.traceline.startingpoint).dotProduct(trace.traceline.direction) < 0) {
                //Console.WriteLine("Found object lies in the past! Skipping "+iObject.tag);
                continue;
                }// else {Console.WriteLine("not in the past, but :"+(currentintersection.enter.loc-trace.traceline.startingpoint).dotProduct(trace.traceline.direction));}

            currentdistance = currentintersection.enter.loc.distanceTo(trace.traceline.startingpoint);

            if (currentintersection.object3d == trace.currentObject) {
                /* If you're inside an object and the beam meets the same object,
                 * it should only have an "enterloc" which is where the beam "leaves" the object. */
                if (currentintersection.exit != null) { // .loc part after exit removed at 20131205
                    /* perhaps the intersection has found the object at the same starting point */
                    if (currentintersection.enter.loc.distanceTo(trace.traceline.startingpoint)
                        < trace.getMinDistinctionLength()) {
                        Console.WriteLine("New functionality: removing exit for "+currentintersection.object3d.tag);
                        currentintersection.removeExit();
                        goto REPARSE;
                        }
                    /* check this occuring warning out after internal reflections. Doesn't
                     * seem to cause any problems though. */
                    if (currentintersection.object3d != trace.currentObject) { // because if they are the same it seems like internal reflection
                        Console.WriteLine("WARNING @"+this.tag+": Collision ("+currentintersection.object3d.tag+")"+
                        " with current object ("+trace.currentObject.tag+")"+
                        " without leaving first \n-----\n"+
                            trace.ToCompactString()+ "\nentering: "+currentintersection.enter.loc.trico()+
                                              "\nexit:"+currentintersection.exit.loc.tricon()+"-----");
                        } //endif (currentintersection.object3d != trace.currentObject)

                    continue;
                    /* else: if no exit location is set, we must be leaving the current object at "enter" */
                    } else { // Leaving the current object should return to the parent collection (environment?).
                    currentintersection.leaving = true;
                    }
                /* else: if the colliding object isn't the current object */
                } else {
                // analogue as above but inverted: you cannot leave an object you're not inside.
                if (currentintersection.exit == null) {  // .loc part after exit removed at 20131205
                        //or can you?
                        //continue; NO LONGER ABORT PARSING HERE, BECAUSE:
                        //CONCLUSION:
                        //YES YOU CAN, think about an object within an object or a reflective layer
                        if (currentintersection.object3d.hasVolume) {
                            //Console.WriteLine("Leaving object with volume("+currentintersection.object3d.tag+"), but don't refract");
                            continue;
                        }
                }
            }
            if (!firstIntersection.intersects) {
                firstIntersection = currentintersection;
                firstdistance = firstIntersection.enter.loc.distanceTo(trace.traceline.startingpoint);
                continue;
            }
            /* below a firstInteraction is already set */
            currentdistance = currentintersection.enter.loc.distanceTo(trace.traceline.startingpoint);

                if (firstIntersection.leaving) {
                /* in order to make "attached objects" change into one another the
                 * colliding object has to be found instead of the "leaving" border. */
                /* object which are seperated from each other with less than the lights wavelength
                 * will be treated as connected to each other. Not first leaving previous border */
                if (currentdistance - firstdistance < trace.getMinDistinctionLength()) {
                    firstIntersection = currentintersection;
                    firstdistance = currentdistance;
                    continue;
                    }
                continue;
                }
            /*			if (firstdistance == null) {
//.........这里部分代码省略.........
开发者ID:JoepBC,项目名称:scientrace,代码行数:101,代码来源:Object3dCollection.cs

示例2: intersectionPoints

        /* end of interface IBorder3D implementation */
        public IntersectionPoint[] intersectionPoints(Trace trace)
        {
            VectorTransform trf = this.getTransform();

            // the points (any V) on the center line of this cylinder is described by "V = s + x l" for any x.
            Vector s = trf.transform(trace.traceline.startingpoint-this.loc);
            Vector l = trf.transform(trace.traceline.direction);
            double r = 1; // not (this.radius;) as the transformation rendered it 1.

            double ABCa = Math.Pow(l.x,2) + Math.Pow(l.y,2);
            double ABCb = 2*((s.x*l.x)+(s.y*l.y));
            double ABCc = Math.Pow(s.x,2) + Math.Pow(s.y,2) - r*r;

            QuadraticEquation qe = new QuadraticEquation(ABCa, ABCb, ABCc);

            Scientrace.IntersectionPoint[] ips = new Scientrace.IntersectionPoint[2]{null, null};
            if (!qe.hasAnswers) { return ips; }
            for (int iAns = 1; iAns <= qe.answerCount; iAns++) {
            double x = qe.getAnswer(iAns);
            if (Double.IsNaN(x))
                throw new ArgumentNullException("Answer {"+iAns+"} is NaN.\n\n qe details:"+qe.ToString());
            Vector tLoc = s + (l * x);
            Vector tNormal = new Vector(tLoc.x, tLoc.y, 0);
            Location oLoc = (trf.transformback(tLoc)+this.loc).toLocation();
            UnitVector oNormal = null;
            try {
                oNormal = trf.transformback(tNormal).tryToUnitVector();
                } catch { new ZeroNonzeroVectorException("oNormal is a zerovector which cannot be normalised for o3d ["+this.tag+"] and trace "+trace.ToCompactString()); }
            ips[iAns-1] = Scientrace.IntersectionPoint.locAtSurfaceNormal(oLoc, oNormal);
            }
            /*		switch (qe.answerCount) {
            case 2:
                Scientrace.Location minLoc = ((l*qe.minVal) + o).toLocation();
                Scientrace.NonzeroVector minNorm = (minLoc - c).tryToNonzeroVector();
                ips[0] = Scientrace.IntersectionPoint.locAtSurfaceNormal(minLoc, minNorm);
                Scientrace.Location plusLoc = ((l*qe.plusVal) + o).toLocation();
                Scientrace.NonzeroVector plusNorm = (plusLoc - c).tryToNonzeroVector();
                ips[1] = Scientrace.IntersectionPoint.locAtSurfaceNormal(plusLoc, plusNorm);
                return new Intersection(aTrace, ips, this);
                //goto case 1;	//continue to case 1
            case 1:
                Scientrace.Location loc = ((l*qe.plusVal) + o).toLocation();
                Scientrace.NonzeroVector norm = (loc - c).tryToNonzeroVector();
                ips[0] = Scientrace.IntersectionPoint.locAtSurfaceNormal(loc, norm);
                ips[1] = null;
                return new Intersection(aTrace, ips, this);
            default:
                throw new IndexOutOfRangeException("eq.answerCount is not allowed to be "+qe.answerCount.ToString()+"in Shpere.intersects(..)");
            } //end switch(qe.answerCount)
            */

            return ips;
        }
开发者ID:JoepBC,项目名称:scientrace,代码行数:54,代码来源:InfiniteCylinderBorder.cs


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