:py:mod:`gnome.utilities.geometry.BBox` ======================================= .. py:module:: gnome.utilities.geometry.BBox .. autoapi-nested-parse:: A Bounding Box object and assorted utilities , subclassed from a numpy array FIXME: The constructor functions should be class methods. It would be good to PEP8 the method names. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: gnome.utilities.geometry.BBox.BBox Functions ~~~~~~~~~ .. autoapisummary:: gnome.utilities.geometry.BBox.asBBox gnome.utilities.geometry.BBox.fromPoints gnome.utilities.geometry.BBox.fromBBArray gnome.utilities.geometry.BBox.NullBBox gnome.utilities.geometry.BBox.InfBBox .. py:class:: BBox(shape, dtype=float, buffer=None, offset=0, strides=None, order=None) Bases: :py:obj:`numpy.ndarray` A Bounding Box object: Takes Data as an array. Data is any python sequence that can be turned into a 2x2 numpy array of float64s: [[MinX, MinY ], [MaxX, MaxY ]] It is a subclass of numpy.ndarray, so for the most part it can be used as an array, and arrays that fit the above description can be used in its place. Usually created by the factory functions: asBBox and fromPoints Takes Data as an array. Data is any python sequence that can be turned into a 2x2 numpy array of float64s: [[MinX, MinY ], [MaxX, MaxY ]] You don't usually call this directly. BBox objects are created with the factory functions: asBBox and fromPoints .. py:attribute:: Left .. py:attribute:: Right .. py:attribute:: Bottom .. py:attribute:: Top .. py:attribute:: Width .. py:attribute:: Height .. py:attribute:: Center .. py:attribute:: Array__eq__ .. py:method:: Overlaps(BB) Overlap(BB): Tests if the given Bounding Box overlaps with this one. Returns True is the Bounding boxes overlap, False otherwise If they are just touching, returns True .. py:method:: Inside(BB) Inside(BB): Tests if the given Bounding Box is entirely inside this one. Returns True if it is entirely inside, or touching the border. Returns False otherwise .. py:method:: PointInside(Point) Inside(BB): Tests if the given Point is entirely inside this one. Returns True if it is entirely inside, or touching the border. Returns False otherwise Point is any length-2 sequence (tuple, list, array) or two numbers .. py:method:: Merge(BB) Joins this bounding box with the one passed in, maybe making this one bigger .. py:method:: AsPoly() Returns the four corners of the bounding box as polygon: An 4X2 array of (x,y) coordinates of the corners .. py:method:: IsNull() .. py:method:: _getLeft() .. py:method:: _getRight() .. py:method:: _getBottom() .. py:method:: _getTop() .. py:method:: _getWidth() .. py:method:: _getHeight() .. py:method:: _getCenter() .. py:method:: __eq__(BB) __eq__(BB) The equality operator A == B if and only if all the entries are the same .. py:function:: asBBox(data) returns a BBox object. If object is a BBox, it is returned unaltered If object is a numpy array, a BBox object is returned that shares a view of the data with that array. The numpy array should be of the correct format: a 2x2 numpy array of float64s: [[MinX, MinY ], [MaxX, MaxY ]] .. py:function:: fromPoints(Points) fromPoints (Points). reruns the bounding box of the set of points in Points. Points can be any python object that can be turned into a numpy NX2 array of float64s. If a single point is passed in, a zero-size Bounding Box is returned. .. py:function:: fromBBArray(BBarray) Builds a BBox object from an array of Bounding Boxes. The resulting Bounding Box encompases all the included BBs. The BBarray is in the shape: (Nx2x2) where BBarray[n] is a 2x2 array that represents a BBox .. py:function:: NullBBox() Returns a BBox object with all NaN entries. This represents a Null BB box; BB merged with it will return BB. Nothing is inside it. .. py:function:: InfBBox() Returns a BBox object with all -inf and inf entries