Package georegression.geometry.curves
Class TangentLinesTwoEllipses_F32
java.lang.Object
georegression.geometry.curves.TangentLinesTwoEllipses_F32
@Generated("georegression.geometry.curves.TangentLinesTwoEllipses_F64")
public class TangentLinesTwoEllipses_F32
extends Object
Iterative algorithm for finding the 4 pairs of tangent lines between two ellipses. The ellipses are assumed to not intersect. Line 0 and line 3 will not intersect the line joining the center of the two ellipses while line 1 and 2 will.
Algorithm: While a closed form solution does exist, it is very complex and an iterative solution is used here instead.- Initialize by finding four lines which are approximately tangent. Two will cross the center line and two will not. See code for details
- For each end point on a line find the two tangent points on the other ellipse. Keep the line which either crosses or does not cross the center line.
- Repeat unit the location of each end points does not change significantly or the maximum number of iterations has been exceeded
-
Constructor Summary
ConstructorDescriptionTangentLinesTwoEllipses_F32
(float convergenceTol, int maxIterations) Constructor that configures optimization parameters -
Method Summary
Modifier and TypeMethodDescriptionfloat
int
boolean
boolean
process
(EllipseRotated_F32 ellipseA, EllipseRotated_F32 ellipseB, Point2D_F32 tangentA0, Point2D_F32 tangentA1, Point2D_F32 tangentA2, Point2D_F32 tangentA3, Point2D_F32 tangentB0, Point2D_F32 tangentB1, Point2D_F32 tangentB2, Point2D_F32 tangentB3) Selects 4 pairs of points.void
setConvergenceTol
(float convergenceTol) void
setMaxIterations
(int maxIterations)
-
Constructor Details
-
TangentLinesTwoEllipses_F32
public TangentLinesTwoEllipses_F32(float convergenceTol, int maxIterations) Constructor that configures optimization parameters- Parameters:
convergenceTol
- Tolerance for when the iterations will stop. Try 1e-8 for floats and 1e-4 for floatsmaxIterations
- Maximum number of iterations
-
-
Method Details
-
process
public boolean process(EllipseRotated_F32 ellipseA, EllipseRotated_F32 ellipseB, Point2D_F32 tangentA0, Point2D_F32 tangentA1, Point2D_F32 tangentA2, Point2D_F32 tangentA3, Point2D_F32 tangentB0, Point2D_F32 tangentB1, Point2D_F32 tangentB2, Point2D_F32 tangentB3) Selects 4 pairs of points. Each point in the pair represents an end point in a line segment which is tangent to both ellipseA and ellipseB. Both ellipses are assumed to not intersect each other. If a fatal error occurs the function will return false. However it can return true and did not converge. To check for convergence call
isConverged()
.Line 0 and line 3 will not intersect the line joining the center of the two ellipses while line 1 and 2 will.
- Parameters:
ellipseA
- (Input) An ellipseellipseB
- (Input) An ellipsetangentA0
- (Output) Tangent point on A for line segment 0tangentA1
- (Output) Tangent point on A for line segment 1tangentA2
- (Output) Tangent point on A for line segment 2tangentA3
- (Output) Tangent point on A for line segment 3tangentB0
- (Output) Tangent point on B for line segment 0tangentB1
- (Output) Tangent point on B for line segment 1tangentB2
- (Output) Tangent point on B for line segment 2tangentB3
- (Output) Tangent point on B for line segment 3- Returns:
- true if no fatal error, false if one happened.
-
isConverged
public boolean isConverged() -
getConvergenceTol
public float getConvergenceTol() -
setConvergenceTol
public void setConvergenceTol(float convergenceTol) -
getMaxIterations
public int getMaxIterations() -
setMaxIterations
public void setMaxIterations(int maxIterations)
-