示例#1
0
        /// <summary>
        /// Determine if two lines intersect anywhere
        /// </summary>
        /// <param name="rhs">The other line</param>
        /// <returns>true if the lines exist, otherwise false</returns>
        public bool Intersects(Line2D <T> rhs)
        {
            Locus <T> result1 = Intersection(rhs);
            Locus <T> result2 = Overlaps(rhs);

            return(!(result1 is EmptyLocus <T> && result2 is EmptyLocus <T>));
        }
示例#2
0
        /// <summary>
        /// Determine the intersection of a line with this rectangle
        /// <para>If the line is contained within the rectangle it is not considered intersecting</para>
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public Locus <T> Intersection(Line2D <T> line)
        {
            Locus <T> result = new EmptyLocus <T>();

            foreach (Line2D <T> vertice in Vertices)
            {
                Locus <T> verticeIntersection = line.Intersection(vertice);
                if (!(verticeIntersection is EmptyLocus <T>))
                {
                    result = CombineIntersections((dynamic)result, (dynamic)verticeIntersection);
                }
            }
            return(result);
        }
示例#3
0
 public void OverlapTest(Line2D <Int32> lhs, Line2D <Int32> rhs, Locus <Int32> result)
 {
     Assert.AreEqual(result, lhs.Overlaps(rhs));
 }
示例#4
0
 public void IntersectionTest(Line2D <Int32> lhs, Line2D <Int32> rhs, Locus <Int32> expected)
 {
     Assert.AreEqual(expected, lhs.Intersection(rhs));
 }