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


C# LineSegment.GetIntersectionWith方法代码示例

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


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

示例1: IntersectionPointTest

        public void IntersectionPointTest( float ax1, float ay1, float ax2, float ay2, float bx1, float by1, float bx2, float by2, float ix, float iy, IntersectionType type )
        {
            LineSegment segA = new LineSegment( new Point( ax1, ay1 ), new Point( ax2, ay2 ) );
            LineSegment segB = new LineSegment( new Point( bx1, by1 ), new Point( bx2, by2 ) );
            Point expectedIntersection = new Point( ix, iy );

            Assert.DoesNotThrow( ( ) =>
            {
                Point? segSeg = segA.GetIntersectionWith( segB );
                Point? segLine = segA.GetIntersectionWith( (Line) segB );
                Point? lineSeg = ( (Line) segA ).GetIntersectionWith( segB );

                if ( type == IntersectionType.AllFour )
                {
                    Assert.AreEqual( expectedIntersection, segSeg );
                }
                else
                {
                    Assert.AreEqual( null, segSeg );
                }

                if ( ( type == IntersectionType.AllFour ) || ( type == IntersectionType.SegmentA ) )
                {
                    Assert.AreEqual( expectedIntersection, segLine );
                }
                else
                {
                    Assert.AreEqual( null, segLine );
                }

                if ( ( type == IntersectionType.AllFour ) || ( type == IntersectionType.SegmentB ) )
                {
                    Assert.AreEqual( expectedIntersection, lineSeg );
                }
                else
                {
                    Assert.AreEqual( null, lineSeg );
                }
            } );

            Point? lineLine = ( (Line) segA ).GetIntersectionWith( (Line) segB );

            if ( type != IntersectionType.None )
            {
                Assert.AreEqual( expectedIntersection, lineLine );
            }
            else
            {
                Assert.AreEqual( null, lineLine );
            }
        }
开发者ID:Kenneth-Posey,项目名称:aforge-clone,代码行数:51,代码来源:LineSegmentTest.cs

示例2: CollinearIntersectionPointTest

        public void CollinearIntersectionPointTest(float ax1, float ay1, float ax2, float ay2, float bx1, float by1, float bx2, float by2)
        {
            LineSegment segA = new LineSegment( new Point( ax1, ay1 ), new Point( ax2, ay2 ) );
            LineSegment segB = new LineSegment( new Point( bx1, by1 ), new Point( bx2, by2 ) );

            // are we really collinear?
            Assert.Throws<InvalidOperationException>( ( ) => ( (Line) segA ).GetIntersectionWith( (Line) segB ) );

            Assert.Throws<InvalidOperationException>( ( ) => segA.GetIntersectionWith( (Line) segB ) );
            Assert.Throws<InvalidOperationException>( ( ) => ( (Line) segA ).GetIntersectionWith( segB ) );
            Assert.Throws<InvalidOperationException>( ( ) => segB.GetIntersectionWith( (Line) segA ) );
            Assert.Throws<InvalidOperationException>( ( ) => ( (Line) segB ).GetIntersectionWith( segA ) );
            Assert.AreEqual( null, segB.GetIntersectionWith( segA ) );
            Assert.AreEqual( null, segA.GetIntersectionWith( segB ) );
        }
开发者ID:jorik041,项目名称:aforge,代码行数:15,代码来源:LineSegmentTest.cs

示例3: ParallelIntersectionPointTest

        public void ParallelIntersectionPointTest( float ax1, float ay1, float ax2, float ay2, float bx1, float by1, float bx2, float by2 )
        {
            LineSegment segA = new LineSegment( new Point( ax1, ay1 ), new Point( ax2, ay2 ) );
            LineSegment segB = new LineSegment( new Point( bx1, by1 ), new Point( bx2, by2 ) );

            // are we really parallel?
            Assert.AreEqual( null, ( (Line) segA ).GetIntersectionWith( (Line) segB ) );

            Assert.AreEqual( null, segA.GetIntersectionWith( (Line) segB ) );
            Assert.AreEqual( null, ( (Line) segA ).GetIntersectionWith( segB ) );
            Assert.AreEqual( null, segB.GetIntersectionWith( (Line) segA ) );
            Assert.AreEqual( null, ( (Line) segB ).GetIntersectionWith( segA ) );
            Assert.AreEqual( null, segB.GetIntersectionWith( segA ) );
            Assert.AreEqual( null, segA.GetIntersectionWith( segB ) );
        }
开发者ID:jorik041,项目名称:aforge,代码行数:15,代码来源:LineSegmentTest.cs


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