java.lang.Object
imagingbook.common.geometry.ellipse.GeometricEllipse
- All Implemented Interfaces:
Primitive2d
,ShapeProducer
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGeometricEllipse
(double[] p) Constructor.GeometricEllipse
(double ra, double rb, double xc, double yc) Constructor, short version for axis-aligned ellipses.GeometricEllipse
(double ra, double rb, double xc, double yc, double theta) Constructor.Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
equals
(GeometricEllipse other, double tolerance) boolean
double
double
getArea()
double[]
getClosestPoint
(double[] pnt) getClosestPoint
(Pnt2d pnt) Returns the ellipse point closest to the specified point.double
getDistance
(Pnt2d p) Returns the closest (geometric) distance of the specified point to this ellipse.static double[]
Calculates and returns the geometric ellipse parameters from a given algebraic ellipse (see Eqns.Deprecated.double
getMeanSquareError
(Pnt2d[] points) Returns the mean squared error between this ellipse and a set of 2D points.double[]
Returns a vector of parameters for this ellipse.getShape
(double scale) Returns a scaledShape
for this object (default scale is 1).Shape[]
getShapes
(double scale) Returns a fixed sequence ofShape
items for drawing this object, which must contain at least one item.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface imagingbook.common.geometry.shape.ShapeProducer
getShape, getShapes
-
Field Details
-
ra
Ellipse parameters. -
rb
Ellipse parameters. -
xc
Ellipse parameters. -
yc
Ellipse parameters. -
theta
Ellipse parameters.
-
-
Constructor Details
-
GeometricEllipse
Constructor. Axis lengths may be exchanged to ensure ra ≥ rb.- Parameters:
ra
- major axis lengthrb
- minor axis lengthxc
- center point (x)yc
- center point (y)theta
- orientation
-
GeometricEllipse
Constructor, short version for axis-aligned ellipses. Axis lengths may be exchanged to ensure ra ≥ rb.- Parameters:
ra
- major axis lengthrb
- minor axis lengthxc
- center point (x)yc
- center point (y)
-
GeometricEllipse
Constructor.- Parameters:
p
- parameter vector [ra, rb, xc, yc, theta].- See Also:
-
GeometricEllipse
Constructor. Creates a newGeometricEllipse
from aAlgebraicEllipse
instance.- Parameters:
ae
- aAlgebraicEllipse
instance
-
-
Method Details
-
getGeometricEllipseParameters
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
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
-
getArea
-
getAlgebraicDistance
-
getClosestPoint
Returns the ellipse point closest to the specified point. To perform this calculation for multiple points on the same ellipse useOrthogonalEllipseProjector
.- Parameters:
pnt
- some 2D point- Returns:
- the closest ("contact") point on the ellipse
- See Also:
-
getClosestPoint
-
getMeanSquareError
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
Returns the closest (geometric) distance of the specified point to this ellipse.- Specified by:
getDistance
in interfacePrimitive2d
- Parameters:
p
- some 2D point- Returns:
- the distance to the closest point on the ellipse
-
getShape
Description copied from interface:ShapeProducer
Returns a scaledShape
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, forPnt2d
it specifies the size of the marker (seePnt2d.getShape(double)
.- Specified by:
getShape
in interfaceShapeProducer
- Parameters:
scale
- the scale of the shape- Returns:
- a
Shape
instance
-
getShapes
Description copied from interface:ShapeProducer
Returns a fixed sequence ofShape
items for drawing this object, which must contain at least one item. This is to produce graphic representations that are too complex for a singleShape
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, aGeometricEllipse
returns three shape items: (a) the ellipse curve, (b) the center mark, (c) the major axes (seegetShapes(double)
).- Specified by:
getShapes
in interfaceShapeProducer
- Parameters:
scale
- a scale factor (may be used or ignored)- Returns:
- sequence of
Shape
items
-
getLeftAxisPoint
Deprecated. -
duplicate
-
equals
-
equals
-
toString
-