A mutable bounding box. Examples -------- **Create from known bounds** The default constructor takes the boundary "points" ``[[xmin, ymin], [xmax, ymax]]``. >>> Bbox([[1, 1], [3, 7]]) Bbox([[1.0, 1.0], [3.0, 7.0]]) Alternatively, a Bbox can be created
| 690 | |
| 691 | |
| 692 | class Bbox(BboxBase): |
| 693 | """ |
| 694 | A mutable bounding box. |
| 695 | |
| 696 | Examples |
| 697 | -------- |
| 698 | **Create from known bounds** |
| 699 | |
| 700 | The default constructor takes the boundary "points" ``[[xmin, ymin], |
| 701 | [xmax, ymax]]``. |
| 702 | |
| 703 | >>> Bbox([[1, 1], [3, 7]]) |
| 704 | Bbox([[1.0, 1.0], [3.0, 7.0]]) |
| 705 | |
| 706 | Alternatively, a Bbox can be created from the flattened points array, the |
| 707 | so-called "extents" ``(xmin, ymin, xmax, ymax)`` |
| 708 | |
| 709 | >>> Bbox.from_extents(1, 1, 3, 7) |
| 710 | Bbox([[1.0, 1.0], [3.0, 7.0]]) |
| 711 | |
| 712 | or from the "bounds" ``(xmin, ymin, width, height)``. |
| 713 | |
| 714 | >>> Bbox.from_bounds(1, 1, 2, 6) |
| 715 | Bbox([[1.0, 1.0], [3.0, 7.0]]) |
| 716 | |
| 717 | **Create from collections of points** |
| 718 | |
| 719 | The "empty" object for accumulating Bboxs is the null bbox, which is a |
| 720 | stand-in for the empty set. |
| 721 | |
| 722 | >>> Bbox.null() |
| 723 | Bbox([[inf, inf], [-inf, -inf]]) |
| 724 | |
| 725 | Adding points to the null bbox will give you the bbox of those points. |
| 726 | |
| 727 | >>> box = Bbox.null() |
| 728 | >>> box.update_from_data_xy([[1, 1]]) |
| 729 | >>> box |
| 730 | Bbox([[1.0, 1.0], [1.0, 1.0]]) |
| 731 | >>> box.update_from_data_xy([[2, 3], [3, 2]], ignore=False) |
| 732 | >>> box |
| 733 | Bbox([[1.0, 1.0], [3.0, 3.0]]) |
| 734 | |
| 735 | Setting ``ignore=True`` is equivalent to starting over from a null bbox. |
| 736 | |
| 737 | >>> box.update_from_data_xy([[1, 1]], ignore=True) |
| 738 | >>> box |
| 739 | Bbox([[1.0, 1.0], [1.0, 1.0]]) |
| 740 | |
| 741 | .. warning:: |
| 742 | |
| 743 | It is recommended to always specify ``ignore`` explicitly. If not, the |
| 744 | default value of ``ignore`` can be changed at any time by code with |
| 745 | access to your Bbox, for example using the method `~.Bbox.ignore`. |
| 746 | |
| 747 | **Properties of the ``null`` bbox** |
| 748 | |
| 749 | .. note:: |
no outgoing calls
searching dependent graphs…