Class GeometricEllipse

java.lang.Object
imagingbook.common.geometry.ellipse.GeometricEllipse
All Implemented Interfaces:
Primitive2d, ShapeProducer

public class GeometricEllipse extends Object implements ShapeProducer, Primitive2d

Represents an ellipse with major axis length ra, minor axis length rb, center point (xc, yc), and orientation theta. Instances are immutable. See Secs. 11.2.2 and F.3.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

    • ra

      public final double ra
      Ellipse parameters.
    • rb

      public final double rb
      Ellipse parameters.
    • xc

      public final double xc
      Ellipse parameters.
    • yc

      public final double yc
      Ellipse parameters.
    • theta

      public final double theta
      Ellipse parameters.
  • Constructor Details

    • GeometricEllipse

      public GeometricEllipse(double ra, double rb, double xc, double yc, double theta)
      Constructor. Axis lengths may be exchanged to ensure ra ≥ rb.
      Parameters:
      ra - major axis length
      rb - minor axis length
      xc - center point (x)
      yc - center point (y)
      theta - orientation
    • GeometricEllipse

      public GeometricEllipse(double ra, double rb, double xc, double yc)
      Constructor, short version for axis-aligned ellipses. Axis lengths may be exchanged to ensure ra ≥ rb.
      Parameters:
      ra - major axis length
      rb - minor axis length
      xc - center point (x)
      yc - center point (y)
    • GeometricEllipse

      public GeometricEllipse(double[] p)
      Constructor.
      Parameters:
      p - parameter vector [ra, rb, xc, yc, theta].
      See Also:
    • GeometricEllipse

      Constructor. Creates a new GeometricEllipse from a AlgebraicEllipse instance.
      Parameters:
      ae - a AlgebraicEllipse instance
  • Method Details

    • getGeometricEllipseParameters

      public static double[] getGeometricEllipseParameters(AlgebraicEllipse ae)
      Calculates and returns the geometric ellipse parameters from a given algebraic ellipse (see Eqns. 19-23 at http://mathworld.wolfram.com/Ellipse.html).
      Parameters:
      ae - a AlgebraicEllipse instance with parameters (A,...,F)
      Returns:
      the geometric ellipse parameters (ra, rb, xc, yc, theta)
      See Also:
    • getParameters

      public double[] getParameters()
      Returns a vector of parameters for this ellipse. The length of the vector and the meaning of the parameters depends on the concrete ellipse type.
      Returns:
      a vector of parameters [ra, rb, xc, yc, theta]
    • getCenter

      public Pnt2d getCenter()
    • getArea

      public double getArea()
    • getAlgebraicDistance

      public double getAlgebraicDistance(Pnt2d p)
    • getClosestPoint

      public Pnt2d getClosestPoint(Pnt2d pnt)
      Returns the ellipse point closest to the specified point. To perform this calculation for multiple points on the same ellipse use OrthogonalEllipseProjector.
      Parameters:
      pnt - some 2D point
      Returns:
      the closest ("contact") point on the ellipse
      See Also:
    • getClosestPoint

      public double[] getClosestPoint(double[] pnt)
    • getMeanSquareError

      public double getMeanSquareError(Pnt2d[] points)
      Returns the mean squared error between this ellipse 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 closest (geometric) distance of the specified point to this ellipse.
      Specified by:
      getDistance in interface Primitive2d
      Parameters:
      p - some 2D point
      Returns:
      the distance to the closest point on the ellipse
    • 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 getShapes(double)).

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

      Deprecated.
    • duplicate

    • equals

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

      public boolean equals(GeometricEllipse other, double tolerance)
    • toString

      public String toString()
      Overrides:
      toString in class Object