Ejemplo n.º 1
0
        public void MinkowskiDifference_of_two_boxes_amounts_to_subtracting_minima_and_maxima()
        {
            var box1 = new Box2(new Interval(0.123, 0.456), new Interval(2.718, 3.141));
            var box2 = new Box2(new Interval(0.0777, 0.0888), new Interval(-0.1, +0.1));

            var expectedAnswer = Box2.Hull(box1.MinCorner - box2.MaxCorner, box1.MaxCorner - box2.MinCorner);
            var actualAnswer   = PolygonUtils.MinkowskiDifference(box1, box2);

            ExpectPolygonsAreEqualWithinTolerance(actualAnswer, expectedAnswer, _tolerance);
        }
Ejemplo n.º 2
0
        public void MinkowskiDifference_is_distributive_with_Union()
        {
            var box1 = new Box2(new Interval(0.123, 0.456), new Interval(2.718, 3.141));
            var box2 = new Box2(new Interval(0.777, 0.888), new Interval(-1, +1));
            var box3 = new Box2(new Interval(1.519, 1.784), new Interval(-0.256, +0.324));

            var diff1 = PolygonUtils.MinkowskiDifference(box1, PolygonUtils.Union(box2, box3));
            var diff2 = PolygonUtils.Union(PolygonUtils.MinkowskiDifference(box1, box2), PolygonUtils.MinkowskiDifference(box1, box3));

            ExpectPolygonsAreEqualWithinTolerance(diff1, diff2, _tolerance);
        }