@ALDParametrizedClass public class MTBQuadraticCurve2D extends Object
A curve is defined by the following implicit equation:
The type of the curve is derived based on the following matrices:
MTBQuadraticCurve2D.CurveType
.
If the curve is an ellipse, but not a circle, i.e.
For details about the definition of various types of curves refer
to
Koecher/Krieg, Ebene Geometrie, 3. Auflage,
Springer Verlage, 2007.
FitQuadraticCurveToPointSet
,
FitEllipseToPointSet
,
Ellipses on WolframMathWorldModifier and Type | Class and Description |
---|---|
static class |
MTBQuadraticCurve2D.CurveType
Possible types of curve.
|
private class |
MTBQuadraticCurve2D.DistanceTargetFunction
Distance function for a point's distance to an ellipse.
|
Modifier and Type | Field and Description |
---|---|
protected double |
a
Implicit curve parameter a.
|
private static double |
accuracy
Local accuracy for comparisons of values against zero.
|
protected double |
b
Implicit curve parameter b.
|
protected double |
c
Implicit curve parameter c.
|
protected double |
centerX
Ellipse center in x-direction.
|
protected double |
centerY
Ellipse center in x-direction.
|
protected MTBQuadraticCurve2D.CurveType |
curveType
Type of curve.
|
protected double |
d
Implicit curve parameter d.
|
protected double |
e
Implicit curve parameter e.
|
protected double |
f
Implicit curve parameter f.
|
protected double |
orientation
Ellipse orientation in degrees.
|
protected double |
semiAxisLengthA
Half-length of axis a.
|
protected double |
semiAxisLengthB
Half-length of axis b.
|
Constructor and Description |
---|
MTBQuadraticCurve2D()
Default constructor.
|
MTBQuadraticCurve2D(double[] parameters,
boolean implicit)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
calcEllipseParameters()
Calculate concrete ellipse parameters from implicit equation.
|
protected MTBQuadraticCurve2D.CurveType |
determineTypeOfCurve()
Figure out which kind of curve we have.
|
double |
getCenterX()
Get coordinate of center in x.
|
double |
getCenterY()
Get coordinate of center in y.
|
Point2D.Double |
getClosestPointOnEllipse(Point2D.Double p)
Returns the point on ellipse closest to given point.
|
double |
getDistanceAlgebraic(Collection<Point2D.Double> ps)
Returns the algebraic distance of the given point set.
|
double |
getDistanceEuclideanPointToEllipse(Point2D.Double p)
Returns the Euclidean distance of a point to an ellipse.
|
double |
getOrientation()
Get orientation.
|
double |
getParameterA()
Get value of implicit parameter a.
|
double |
getParameterB()
Get value of implicit parameter b.
|
double |
getParameterC()
Get value of implicit parameter c.
|
double |
getParameterD()
Get value of implicit parameter d.
|
double |
getParameterE()
Get value of implicit parameter e.
|
double |
getParameterF()
Get value of implicit parameter f.
|
double |
getSemiLengthAxisA()
Get half-length of axis A.
|
double |
getSemiLengthAxisB()
Get half-length of axis B.
|
double |
getTangentOrientation(Point2D.Double p)
Returns the orientation of the tangent at point p on the ellipse.
|
MTBQuadraticCurve2D.CurveType |
getType()
Returns the type of the curve.
|
void |
normalizeImplicitParameters()
Normalizes the implicit parameters so that f=1.0.
|
void |
print()
Prints parameters of curve to standard output.
|
private static final double accuracy
protected double a
protected double b
protected double c
protected double d
protected double e
protected double f
@ALDClassParameter(label="Center in x") protected double centerX
@ALDClassParameter(label="Center in y") protected double centerY
@ALDClassParameter(label="Semi-length of axis a.") protected double semiAxisLengthA
@ALDClassParameter(label="Semi-length of axis b.") protected double semiAxisLengthB
@ALDClassParameter(label="Orientation") protected double orientation
The orientation specifies the angle between x-axis of the coordinate system and the major axis of the ellipse with regard to an upper-left coordinate system.
protected MTBQuadraticCurve2D.CurveType curveType
public MTBQuadraticCurve2D()
public MTBQuadraticCurve2D(double[] parameters, boolean implicit)
If an implicit curve is to be initialized, the parameters in the given array are interpreted as the parameters a, b, c, d, e and f of an implicit equation. If an explicit ellipse is to be initialized the parameters are interpreted as center in x and y, half-length of major and minor axes and ellipse orientation.
Note that explicit ellipse parameters are not automatically transformed into implicit ones, however, if implicit parameters are provided internally an explicit representation is also initialized.
parameters
- Set of curve parameters.implicit
- If true, parameters define an implicit curve.protected MTBQuadraticCurve2D.CurveType determineTypeOfCurve()
protected void calcEllipseParameters()
Note that calculation of ellipse parameters is only possible for non-degenerate ellipses.
public void normalizeImplicitParameters()
Such a normalization might be beneficial to handle numerical
issues if the parameter values are rather large.
Note that the normalization does not change the parameters if the
absolute value of f is smaller than one.
public void print()
public MTBQuadraticCurve2D.CurveType getType()
public double getParameterA()
public double getParameterB()
public double getParameterC()
public double getParameterD()
public double getParameterE()
public double getParameterF()
public double getCenterX()
public double getCenterY()
public double getSemiLengthAxisA()
public double getSemiLengthAxisB()
public double getOrientation()
public double getDistanceAlgebraic(Collection<Point2D.Double> ps)
The algebraic distance is defined as follows:
public Point2D.Double getClosestPointOnEllipse(Point2D.Double p) throws de.jstacs.algorithms.optimization.DimensionException, de.jstacs.algorithms.optimization.TerminationException, IOException, de.jstacs.algorithms.optimization.EvaluationException, Exception
The closest point on the ellipse contour is searched for by using
Newton's method. The target point is the point on the ellipse
which tangent vector is perpendicular to the vector between the
given point and the closest point on the ellipse we are looking
for. For details refer to the documentation
of MTBQuadraticCurve2D.DistanceTargetFunction
.
Note that if the curve is not of type CurveType.CT_ELLIPSE
null
is returned.
Exception
de.jstacs.algorithms.optimization.EvaluationException
IOException
de.jstacs.algorithms.optimization.TerminationException
de.jstacs.algorithms.optimization.DimensionException
Nuernberg, Imperial College London, 2006,
Distance from a Point to an Ellipse
public double getDistanceEuclideanPointToEllipse(Point2D.Double p) throws de.jstacs.algorithms.optimization.DimensionException, de.jstacs.algorithms.optimization.TerminationException, IOException, de.jstacs.algorithms.optimization.EvaluationException, Exception
The Euclidean distance of a point to an ellipse is defined as the
point's distance to the closest point on the ellipse.
The distance is calculated by using Newton's method to search for
the point on the ellipse which tangent vector is perpendicular to
the vector between the given point and the closest point on the
ellipse we are looking for. For details refer to the documentation
of MTBQuadraticCurve2D.DistanceTargetFunction
and method
getClosestPointOnEllipse(java.awt.geom.Point2D.Double)
of this class which is used here.
Note that if the curve is not of type CurveType.CT_ELLIPSE
the value Double.NaN
is returned.
Exception
de.jstacs.algorithms.optimization.EvaluationException
IOException
de.jstacs.algorithms.optimization.TerminationException
de.jstacs.algorithms.optimization.DimensionException
Nuernberg, Imperial College London, 2006,
Distance from a Point to an Ellipse
public double getTangentOrientation(Point2D.Double p)
The tangent orientation is calculated as the angle between the local
tangent and the x-axis.
The basis for this calculation is the
following equation for the tangent line to an ellipse in point
$p = (x_0, y_0)$:
For extracting the orientation of the tangent the above equation is transformed to
The value of $s$ is converted into a degree value
in the range of 0 to 180 degrees. Zero degrees refer to a tangent
parallel to the x-axis, and 90 degrees refer to a tangent parallel
to the y-axis.
Note that angles are measured in upper left
coordinates!
If the given point $p$ is not on the ellipse the method result is undefined.
p
- Point on ellipse where to extract tangent orientation.Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.