Exemplo n.º 1
0
        public IntersectionResult GetSegmentSimplifiedRectangleIntersection_TestCase(bool filled, params double[] nums)
        {
            var seg  = new Segment(nums[0], nums[1], nums[2], nums[3]);
            var rect = new SimplifiedRectangle(nums[4], nums[5], nums[6], nums[7]);

            return(GeometryMethods.GetSegmentSimplifiedRectangleIntersection(seg, rect, out var result, filled));
        }
Exemplo n.º 2
0
        private static bool IsSegmentIntersectingRectangle(Segment seg, SimplifiedRectangle rect)
        {
            var intersection =
                GeometryMethods.GetSegmentSimplifiedRectangleIntersection(seg, rect, out var intres, true);

            if (intersection == IntersectionResult.None)
            {
                return(false);
            }

            if (intersection == IntersectionResult.Point)
            {
                if (intres.Equals(seg.Begin) || intres.Equals(seg.End))
                {
                    return(false);
                }
            }

            if (intersection == IntersectionResult.Points)
            {
                var points = (Vector2[])intres;
                if (seg.Begin.Equals(points[0]) && seg.End.Equals(points[1]) ||
                    seg.Begin.Equals(points[1]) && seg.End.Equals(points[0]))
                {
                    return(false);
                }
            }

            return(true);
        }