當前位置: 首頁>>代碼示例>>C#>>正文


C# Line.TestIntersection方法代碼示例

本文整理匯總了C#中System.Line.TestIntersection方法的典型用法代碼示例。如果您正苦於以下問題:C# Line.TestIntersection方法的具體用法?C# Line.TestIntersection怎麽用?C# Line.TestIntersection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Line的用法示例。


在下文中一共展示了Line.TestIntersection方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: LineIntersection

        public void LineIntersection()
        {
            Line horizontalLine = new Line(new Vector2D(0.0f, 1.0f), new Vector2D(2.0f, 1.0f));
            Line verticalLine = new Line(new Vector2D(1.0f, 0.0f), new Vector2D(1.0f, 2.0f));

            Assert.IsTrue(horizontalLine.TestIntersection(verticalLine));
            Assert.IsTrue(horizontalLine.TestIntersection(horizontalLine));
            Assert.IsTrue(verticalLine.TestIntersection(verticalLine));

            Line offsetHorizontalLine = new Line(new Vector2D(0.0f, 3.0f), new Vector2D(2.0f, 3.0f));

            Assert.IsFalse(offsetHorizontalLine.TestIntersection(horizontalLine));

            Line reverseHorizontalLine = new Line(new Vector2D(2.0f, 1.0f), new Vector2D(0.0f, 1.0f));
            Line reverseVerticalLine = new Line(new Vector2D(1.0f, 2.0f), new Vector2D(1.0f, 0.0f));
            Line reverseOffsetHorizontalLine = new Line(new Vector2D(0.0f, 3.0f), new Vector2D(2.0f, 3.0f));

            Assert.IsTrue(reverseHorizontalLine.TestIntersection(reverseVerticalLine));
            Assert.IsTrue(reverseHorizontalLine.TestIntersection(verticalLine));
            Assert.IsTrue(reverseVerticalLine.TestIntersection(verticalLine));
            Assert.IsTrue(reverseVerticalLine.TestIntersection(reverseVerticalLine));

            Assert.IsFalse(reverseHorizontalLine.TestIntersection(reverseOffsetHorizontalLine));
            Assert.IsFalse(reverseHorizontalLine.TestIntersection(offsetHorizontalLine));
        }
開發者ID:jesseDtucker,項目名稱:Autonomy,代碼行數:25,代碼來源:LineTests.cs


注:本文中的System.Line.TestIntersection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。