Class GeometricCircle

java.lang.Object
imagingbook.common.geometry.circle.GeometricCircle
All Implemented Interfaces:
Primitive2d, ShapeProducer

public class GeometricCircle extends Object implements ShapeProducer, Primitive2d

Represents a geometric circle with center point (xc, yc) and radius r. Instances are immutable. See Sec. 11.1.1 and Appendix F.2.1 of [1] for details.

[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).

Version:
2022/11/17
  • Field Details

    • xc

      public final double xc
      Circle parameter.
    • yc

      public final double yc
      Circle parameter.
    • r

      public final double r
      Circle parameter.
  • Constructor Details

  • Method Details

    • getParameters

      public double[] getParameters()
      Returns a vector of geometric circle parameters (xc, yc, r).
      Returns:
      geometric circle parameters (xc, yc, r)
    • getCenter

      public Pnt2d getCenter()
      Returns the center point of this circle.
      Returns:
      the center point
    • getMeanSquareError

      public double getMeanSquareError(Pnt2d[] points)
      Calculates and returns the mean of the squared distances between this circle and a set of 2D points.
      Parameters:
      points - a set of sample points (usually the points used for fitting)
      Returns:
      the mean squared error
    • getDistance

      public double getDistance(Pnt2d p)
      Returns the (unsigned) distance between the specified point and this circle. The result is always non-negative.
      Specified by:
      getDistance in interface Primitive2d
      Parameters:
      p - a 2D point
      Returns:
      the point's distance from the circle
    • getSignedDistance

      public double getSignedDistance(Pnt2d p)
      Returns the signed distance between the specified point and this circle. The result is positive for points outside the circle, negative inside.
      Parameters:
      p - a 2D point
      Returns:
      the point's signed distance from the circle
    • 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
    • getShapes

      public Shape[] getShapes(double scale)
      Description copied from interface: ShapeProducer
      Returns a fixed sequence of Shape items for drawing this object, which must contain at least one item. This is to produce graphic representations that are too complex for a single Shape item. 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, a GeometricEllipse returns three shape items: (a) the ellipse curve, (b) the center mark, (c) the major axes (see GeometricEllipse.getShapes(double)).

      Specified by:
      getShapes in interface ShapeProducer
      Parameters:
      scale - a scale factor (may be used or ignored)
      Returns:
      sequence of Shape items
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(GeometricCircle other, double tolerance)
    • equals

      public boolean equals(GeometricCircle other, double tolXc, double tolYc, double tolR)
    • duplicate

      Returns a copy of this circle.
      Returns:
      a copy of this circle
    • toString

      public String toString()
      Overrides:
      toString in class Object