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


C# Line.DoesIntersect方法代码示例

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


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

示例1: Line_DoesIntersectPolyhedron

        public void Line_DoesIntersectPolyhedron()
        {
            //make a polyhedron
            Point bottom1 = Point.Origin;
            Point bottom2 = Point.MakePointWithInches(4, 0, 0);
            Point bottom3 = Point.MakePointWithInches(4, 12, 0);
            Point bottom4 = Point.MakePointWithInches(0, 12, 0);

            Point top1 = Point.MakePointWithInches(0, 0, 2);
            Point top2 = Point.MakePointWithInches(4, 0, 2);
            Point top3 = Point.MakePointWithInches(4, 12, 2);
            Point top4 = Point.MakePointWithInches(0, 12, 2);

            List<Polygon> faces = new List<Polygon>();
            Polygon bottomFace = new Polygon(new List<Point> {bottom1, bottom2, bottom3, bottom4});
            Polygon topFace = new Polygon(new List<Point> { top1, top2, top3, top4 });
            Polygon frontFace = new Polygon(new List<Point> { bottom1, bottom2, top2, top1 });
            Polygon rightFace = new Polygon(new List<Point> { bottom2, bottom3, top3, top2 });
            Polygon backFace = new Polygon(new List<Point> { bottom3, bottom4, top4, top3 });
            Polygon leftFace = new Polygon(new List<Point> { bottom4, bottom1, top1, top4 });
            
            faces.Add(bottomFace);
            faces.Add(topFace);
            faces.Add(frontFace);
            faces.Add(rightFace);
            faces.Add(backFace);
            faces.Add(leftFace);
            
            Polyhedron testPolyhedron = new Polyhedron(faces);

            //now make some lines that will intersect it
            Line intersecting1 = new Line(Point.MakePointWithInches(2, 0, 1), Point.MakePointWithInches(2, 1, 1));
            Line intersecting2 = new Line(Point.MakePointWithInches(2, 0, .5), Point.MakePointWithInches(5, 12, 1));
            Line intersectingAlongSide = new Line(Point.Origin, Point.MakePointWithInches(0, 1, 0));
            Line noIntersect = new Line(Point.MakePointWithInches(5, 0, 0), Point.MakePointWithInches(5, 1, 0));

            // Temporary
            frontFace.DoesIntersect(intersecting1).Should().BeTrue();
            backFace.DoesIntersect(intersecting1).Should().BeTrue();
            // Temporary


            intersecting1.DoesIntersect(testPolyhedron).Should().BeTrue();
            intersecting2.DoesIntersect(testPolyhedron).Should().BeTrue();
            intersectingAlongSide.DoesIntersect(testPolyhedron).Should().BeTrue();
            noIntersect.DoesIntersect(testPolyhedron).Should().BeFalse();
        }
开发者ID:ParagonTruss,项目名称:GeometryClassLibrary,代码行数:47,代码来源:LineTests.cs

示例2: Line_DoesIntersectLineSegment

        public void Line_DoesIntersectLineSegment()
        {
            Line line1 = new Line(Point.MakePointWithInches(3, 0, 0), Point.MakePointWithInches(-3, 0, 0));
            LineSegment segment1 = new LineSegment(Point.MakePointWithInches(3, -3, 0), Point.MakePointWithInches(2, 0, 0));

            bool resultT1 = line1.DoesIntersect(segment1);
        }
开发者ID:ParagonTruss,项目名称:GeometryClassLibrary,代码行数:7,代码来源:LineTests.cs


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