de.unihalle.informatik.MiToBo.core.datatypes

• java.lang.Object

• ```@ALDParametrizedClass
extends Object```

A curve is defined by the following implicit equation:

The type of the curve is derived based on the following matrices:

For further details about how different types of curves are identified refer to the documentation of `MTBQuadraticCurve2D.CurveType`.

If the curve is an ellipse, but not a circle, i.e.

where the first two define the center of the ellipse, and A and B refer to the semi-major and semi-minor axes lengths. Note that it is not strictly defined which axis A or B defines the major axis and which one the minor. The fifth parameter refers to the orientation angle of the ellipse in counter-clockwise direction from the x-axis to the major axis.

For details about the definition of various types of curves refer to
Koecher/Krieg, Ebene Geometrie, 3. Auflage, Springer Verlage, 2007.

Author:
Birgit Moeller
`FitQuadraticCurveToPointSet`, `FitEllipseToPointSet`, Ellipses on WolframMathWorld
• ### Nested Class Summary

Nested Classes
Modifier 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.
• ### Field Summary

Fields
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 Summary

Constructors
Constructor and Description
`MTBQuadraticCurve2D()`
Default constructor.
```MTBQuadraticCurve2D(double[] parameters, boolean implicit)```
Constructor.
• ### Method Summary

All Methods
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.
`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.
`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.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Field Detail

• #### accuracy

`private static final double accuracy`
Local accuracy for comparisons of values against zero.
Constant Field Values
• #### a

`protected double a`
Implicit curve parameter a.
• #### b

`protected double b`
Implicit curve parameter b.
• #### c

`protected double c`
Implicit curve parameter c.
• #### d

`protected double d`
Implicit curve parameter d.
• #### e

`protected double e`
Implicit curve parameter e.
• #### f

`protected double f`
Implicit curve parameter f.
• #### centerX

```@ALDClassParameter(label="Center in x")
protected double centerX```
Ellipse center in x-direction.
• #### centerY

```@ALDClassParameter(label="Center in y")
protected double centerY```
Ellipse center in x-direction.
• #### semiAxisLengthA

```@ALDClassParameter(label="Semi-length of axis a.")
protected double semiAxisLengthA```
Half-length of axis a.
• #### semiAxisLengthB

```@ALDClassParameter(label="Semi-length of axis b.")
protected double semiAxisLengthB```
Half-length of axis b.
• #### orientation

```@ALDClassParameter(label="Orientation")
protected double orientation```
Ellipse orientation in degrees.

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.

• #### curveType

`protected MTBQuadraticCurve2D.CurveType curveType`
Type of curve.
• ### Constructor Detail

`public MTBQuadraticCurve2D()`
Default constructor.

```public MTBQuadraticCurve2D(double[] parameters,
boolean implicit)```
Constructor.

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:
`parameters` - Set of curve parameters.
`implicit` - If true, parameters define an implicit curve.
• ### Method Detail

• #### determineTypeOfCurve

`protected MTBQuadraticCurve2D.CurveType determineTypeOfCurve()`
Figure out which kind of curve we have.
• #### calcEllipseParameters

`protected void calcEllipseParameters()`
Calculate concrete ellipse parameters from implicit equation.

Note that calculation of ellipse parameters is only possible for non-degenerate ellipses.

• #### normalizeImplicitParameters

`public void normalizeImplicitParameters()`
Normalizes the implicit parameters so that f=1.0.

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.

• #### print

`public void print()`
Prints parameters of curve to standard output.
• #### getType

`public MTBQuadraticCurve2D.CurveType getType()`
Returns the type of the curve.
Returns:
Type of curve.
• #### getParameterA

`public double getParameterA()`
Get value of implicit parameter a.
Returns:
Value of a.
• #### getParameterB

`public double getParameterB()`
Get value of implicit parameter b.
Returns:
Value of b.
• #### getParameterC

`public double getParameterC()`
Get value of implicit parameter c.
Returns:
Value of c.
• #### getParameterD

`public double getParameterD()`
Get value of implicit parameter d.
Returns:
Value of d.
• #### getParameterE

`public double getParameterE()`
Get value of implicit parameter e.
Returns:
Value of e.
• #### getParameterF

`public double getParameterF()`
Get value of implicit parameter f.
Returns:
Value of f.
• #### getCenterX

`public double getCenterX()`
Get coordinate of center in x.
Returns:
Center x-coordinate.
• #### getCenterY

`public double getCenterY()`
Get coordinate of center in y.
Returns:
Center y-coordinate.
• #### getSemiLengthAxisA

`public double getSemiLengthAxisA()`
Get half-length of axis A.
Returns:
Half-length of axis A.
• #### getSemiLengthAxisB

`public double getSemiLengthAxisB()`
Get half-length of axis B.
Returns:
Half-length of axis B.
• #### getOrientation

`public double getOrientation()`
Get orientation.
Returns:
Orientation in degrees.
• #### getDistanceAlgebraic

`public double getDistanceAlgebraic(Collection<Point2D.Double> ps)`
Returns the algebraic distance of the given point set.

The algebraic distance is defined as follows:

Note that the implicit parameters of the curve must have been provided before, if only the explicit parameters are given the result is undefined.
Returns:
Algebraic distance of the points.
• #### getDistanceEuclideanPointToEllipse

```public double getDistanceEuclideanPointToEllipse(Point2D.Double p)
throws de.jstacs.algorithms.optimization.DimensionException,
de.jstacs.algorithms.optimization.TerminationException,
IOException,
de.jstacs.algorithms.optimization.EvaluationException,
Exception```
Returns the Euclidean distance of a point to an ellipse.

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`.

Note that if the curve is not of type `CurveType.CT_ELLIPSE` the value `Double.NaN` is returned.

Returns:
Euclidean distance of the point to the ellipse.
Throws:
`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```