- All Implemented Interfaces:
ShapeProducer
Represents a major axis-aligned bounding box of a 2D point set. At least one point is required to set up a bounding box. If the direction vector is undefined (e.g., in the case of a single input point), the unit vector in x-direction is assumed. See Sec. 8.6.4 (Alg. 8.6) of [1] for details.
[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).
- Version:
- 2022/11/01
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAxisAlignedBoundingBox(Pnt2d[] points) Constructor, creates aAxisAlignedBoundingBoxinstance from an array ofPnt2dpoints.AxisAlignedBoundingBox(Iterable<Pnt2d> points) -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if this bounding box contains the specified point using the default tolerance.booleanChecks if this bounding box contains the specified point using the specified tolerance.Returns an array of fourAlgebraicLineinstances which coincide with the outline of the bounding box.double[]Returns the orientation vector of this bounding box (pointing in the direction of its major axis).getShape(double scale) Returns a scaledShapefor this object (default scale is 1).Shape[]getShapes(double scale) Returns a fixed sequence ofShapeitems for drawing this object, which must contain at least one item.Pnt2d[]Returns an array holding the 4 corner points of the bounding box.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface imagingbook.common.geometry.shape.ShapeProducer
getShape, getShapes
-
Field Details
-
DefaultContainsTolerance
- See Also:
-
-
Constructor Details
-
AxisAlignedBoundingBox
Constructor, creates aAxisAlignedBoundingBoxinstance from anIterableoverPnt2d. At least one distinct point is required.- Parameters:
points- an iterator over 2D points
-
AxisAlignedBoundingBox
Constructor, creates aAxisAlignedBoundingBoxinstance from an array ofPnt2dpoints. At least one distinct point is required.- Parameters:
points- an array of 2D points
-
-
Method Details
-
getOrientationVector
Returns the orientation vector of this bounding box (pointing in the direction of its major axis).- Returns:
- the orientation vector of this bounding box
-
getBoundingLines
Returns an array of fourAlgebraicLineinstances which coincide with the outline of the bounding box. The lines can be used to determine if a given point is inside the box or not (seecontains(Pnt2d, double)).- Returns:
- an array of bounding lines
-
getVertices
Returns an array holding the 4 corner points of the bounding box.- Returns:
- as described above
-
getShape
Description copied from interface:ShapeProducerReturns a scaledShapefor this object (default scale is 1). Must be defined by implementing classes. The interpretation of the scale factor is left to the implementing class. For example, forPnt2dit specifies the size of the marker (seePnt2d.getShape(double).- Specified by:
getShapein interfaceShapeProducer- Parameters:
scale- the scale of the shape- Returns:
- a
Shapeinstance
-
getShapes
Description copied from interface:ShapeProducerReturns a fixed sequence ofShapeitems for drawing this object, which must contain at least one item. This is to produce graphic representations that are too complex for a singleShapeitem. The returned shapes may also be displayed with different strokes or colors.By default, this method returns a single item which is the primary shape (obtained by
ShapeProducer.getShape(double)). Implementing classes should override this method if more than one shape must be returned For example, aGeometricEllipsereturns three shape items: (a) the ellipse curve, (b) the center mark, (c) the major axes (seeGeometricEllipse.getShapes(double)).- Specified by:
getShapesin interfaceShapeProducer- Parameters:
scale- a scale factor (may be used or ignored)- Returns:
- sequence of
Shapeitems
-
contains
Checks if this bounding box contains the specified point using the default tolerance. This method is used instead ofPath2D.contains(double, double)to avoid false results due to roundoff errors.- Parameters:
p- some 2D point- Returns:
- true if the point is inside the bounding box
-
contains
Checks if this bounding box contains the specified point using the specified tolerance. This method is used instead ofPath2D.contains(double, double)to avoid false results due to roundoff errors.- Parameters:
p- some 2D pointtolerance- positive quantity for being outside- Returns:
- true if the point is inside the bounding box
-
toString
-