Class TangentLinesTwoEllipses_F64

java.lang.Object
georegression.geometry.curves.TangentLinesTwoEllipses_F64

public class TangentLinesTwoEllipses_F64 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.
  1. Initialize by finding four lines which are approximately tangent. Two will cross the center line and two will not. See code for details
  2. 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.
  3. Repeat unit the location of each end points does not change significantly or the maximum number of iterations has been exceeded
  • Constructor Details

    • TangentLinesTwoEllipses_F64

      public TangentLinesTwoEllipses_F64(double convergenceTol, int maxIterations)
      Constructor that configures optimization parameters
      Parameters:
      convergenceTol - Tolerance for when the iterations will stop. Try 1e-8 for doubles and 1e-4 for floats
      maxIterations - Maximum number of iterations
  • Method Details

    • process

      public boolean process(EllipseRotated_F64 ellipseA, EllipseRotated_F64 ellipseB, Point2D_F64 tangentA0, Point2D_F64 tangentA1, Point2D_F64 tangentA2, Point2D_F64 tangentA3, Point2D_F64 tangentB0, Point2D_F64 tangentB1, Point2D_F64 tangentB2, Point2D_F64 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 ellipse
      ellipseB - (Input) An ellipse
      tangentA0 - (Output) Tangent point on A for line segment 0
      tangentA1 - (Output) Tangent point on A for line segment 1
      tangentA2 - (Output) Tangent point on A for line segment 2
      tangentA3 - (Output) Tangent point on A for line segment 3
      tangentB0 - (Output) Tangent point on B for line segment 0
      tangentB1 - (Output) Tangent point on B for line segment 1
      tangentB2 - (Output) Tangent point on B for line segment 2
      tangentB3 - (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 double getConvergenceTol()
    • setConvergenceTol

      public void setConvergenceTol(double convergenceTol)
    • getMaxIterations

      public int getMaxIterations()
    • setMaxIterations

      public void setMaxIterations(int maxIterations)