Class ConvexHull

java.lang.Object
imagingbook.common.geometry.hulls.ConvexHull
All Implemented Interfaces:
ShapeProducer

public class ConvexHull extends Object implements ShapeProducer

This class calculate the convex hull of a 2D point set. It is based on the convex hull implementation provided by the Apache Commons Math library, in particular classes ConvexHull2D and MonotoneChain [1]. See Sec. 8.4.2 of [2] for additional details.

[1] https://commons.apache.org/proper/commons-math/index.html
[2] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).

Version:
2022/06/24
  • Field Details

  • Constructor Details

  • Method Details

    • getVertices

      public Pnt2d[] getVertices()
      Returns a sequence of 2D points on the convex hull (in counter-clockwise order).
      Returns:
      sequence of 2D points on the convex hull
    • getShape

      public Shape getShape(double scale)
      Description copied from interface: ShapeProducer
      Returns a scaled Shape for 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, for Pnt2d it specifies the size of the marker (see Pnt2d.getShape(double).
      Specified by:
      getShape in interface ShapeProducer
      Parameters:
      scale - the scale of the shape
      Returns:
      a Shape instance
    • contains

      public boolean contains(Pnt2d p)
    • contains

      public boolean contains(Pnt2d p, double tolerance)
      Checks if this convex hull contains the specified point. This method is used instead of Path2D.contains(double, double) to avoid false results due to roundoff errors.
      Parameters:
      p - some 2D point
      tolerance - positive quantity for being outside
      Returns:
      true if the point is inside the hull