Distance Between Ellipses in 2D

Similar documents
Reconstructing an Ellipsoid from its Perspective Projection onto a Plane

The Laplace Expansion Theorem: Computing the Determinants and Inverses of Matrices

Information About Ellipses

Perspective Projection of an Ellipse

Least-Squares Fitting of Data with Polynomials

Fitting a Natural Spline to Samples of the Form (t, f(t))

Intersection of Ellipsoids

Intersection of Infinite Cylinders

Intersection of Rectangle and Ellipse

Interpolation of Rigid Motions in 3D

A Relationship Between Minimum Bending Energy and Degree Elevation for Bézier Curves

Intersection of Objects with Linear and Angular Velocities using Oriented Bounding Boxes

Solving Systems of Polynomial Equations

Intersection of Ellipses

Distance from a Point to an Ellipse, an Ellipsoid, or a Hyperellipsoid

Computing Orthonormal Sets in 2D, 3D, and 4D

The Area of Intersecting Ellipses

Exercises * on Linear Algebra

The matrix will only be consistent if the last entry of row three is 0, meaning 2b 3 + b 2 b 1 = 0.

Algebra I Fall 2007

CSC 470 Introduction to Computer Graphics. Mathematical Foundations Part 2

Linear Algebra Section 2.6 : LU Decomposition Section 2.7 : Permutations and transposes Wednesday, February 13th Math 301 Week #4

Distance from Line to Rectangle in 3D

Identifying second degree equations

Principal Curvatures of Surfaces

2018 Fall 2210Q Section 013 Midterm Exam I Solution

Distance to Circles in 3D

Matrices. A matrix is a method of writing a set of numbers using rows and columns. Cells in a matrix can be referenced in the form.

Elementary maths for GMT

Linear Algebra: Matrix Eigenvalue Problems

Chapter 2. Ma 322 Fall Ma 322. Sept 23-27

A matrix over a field F is a rectangular array of elements from F. The symbol

Least Squares Fitting of Data by Linear or Quadratic Structures

Linear Algebra & Geometry why is linear algebra useful in computer vision?

APPENDIX A. Background Mathematics. A.1 Linear Algebra. Vector algebra. Let x denote the n-dimensional column vector with components x 1 x 2.

Least Squares Fitting of Data

1 Matrices and matrix algebra

Math 118, Fall 2014 Final Exam

MATH Topics in Applied Mathematics Lecture 12: Evaluation of determinants. Cross product.

Vectors and Matrices

CSL361 Problem set 4: Basic linear algebra

Converting Between Coordinate Systems

Tropical Polynomials

2014 Summer Review for Students Entering Algebra 2. TI-84 Plus Graphing Calculator is required for this course.

Three-Dimensional Coordinate Systems. Three-Dimensional Coordinate Systems. Three-Dimensional Coordinate Systems. Three-Dimensional Coordinate Systems

ELEMENTARY MATRIX ALGEBRA

7.5 Operations with Matrices. Copyright Cengage Learning. All rights reserved.

1.1 Single Variable Calculus versus Multivariable Calculus Rectangular Coordinate Systems... 4

Conceptual Questions for Review

10. Linear Systems of ODEs, Matrix multiplication, superposition principle (parts of sections )

Linear Algebra March 16, 2019

12.5 Equations of Lines and Planes

Linear Algebra Exercises

Matrix Basic Concepts

Chapter 6: Orthogonality

Tutorials in Optimization. Richard Socher

Geometry of the Special Unitary Group

APPLICATIONS The eigenvalues are λ = 5, 5. An orthonormal basis of eigenvectors consists of

ISOMETRIES OF R n KEITH CONRAD

Topics. Vectors (column matrices): Vector addition and scalar multiplication The matrix of a linear function y Ax The elements of a matrix A : A ij

A A x i x j i j (i, j) (j, i) Let. Compute the value of for and

Lecture 10: Eigenvectors and eigenvalues (Numerical Recipes, Chapter 11)

A geometric proof of the spectral theorem for real symmetric matrices

Engineering Notebook

ELEMENTARY LINEAR ALGEBRA

Linear Algebra and Matrix Inversion

Low-Degree Polynomial Roots

Dynamic Collision Detection using Oriented Bounding Boxes

Elementary maths for GMT

Calculation in the special cases n = 2 and n = 3:

1111: Linear Algebra I

Math 315: Linear Algebra Solutions to Assignment 7

Reflections and Rotations in R 3

11 a 12 a 13 a 21 a 22 a b 12 b 13 b 21 b 22 b b 11 a 12 + b 12 a 13 + b 13 a 21 + b 21 a 22 + b 22 a 23 + b 23

Chapter 7: Symmetric Matrices and Quadratic Forms

Algebra 2A Unit 1 Week 1 Day Activity Unit 1 Week 2 Day Activity Unit 1 Week 3 Day Activity Unit 2 Week 1 Day Activity

Econ Slides from Lecture 8

Name: MATH 3195 :: Fall 2011 :: Exam 2. No document, no calculator, 1h00. Explanations and justifications are expected for full credit.

1 Matrices and vector spaces

Math 1553, Introduction to Linear Algebra

15 Singular Value Decomposition

is Use at most six elementary row operations. (Partial

Lecture 1: Systems of linear equations and their solutions

MATH Max-min Theory Fall 2016

Symmetric and anti symmetric matrices

1 Vectors. c Kun Wang. Math 151, Fall Vector Supplement

Notes for Advanced Level Further Mathematics. (iii) =1, hence are parametric

j=1 u 1jv 1j. 1/ 2 Lemma 1. An orthogonal set of vectors must be linearly independent.

Introduction to Linear Algebra, Second Edition, Serge Lange

a11 a A = : a 21 a 22

8. Diagonalization.

MATH 221: SOLUTIONS TO SELECTED HOMEWORK PROBLEMS

7.6 The Inverse of a Square Matrix

Math 234. What you should know on day one. August 28, You should be able to use general principles like. x = cos t, y = sin t, 0 t π.

CHAPTER 1 Systems of Linear Equations

HOMEWORK PROBLEMS FROM STRANG S LINEAR ALGEBRA AND ITS APPLICATIONS (4TH EDITION)

Problem Set # 1 Solution, 18.06

Math 2331 Linear Algebra

Rigid Geometric Transformations

Kevin James. MTHSC 206 Section 12.5 Equations of Lines and Planes

Transcription:

Distance Between Ellipses in 2D David Eberly, Geometric Tools, Redmond WA 98052 https://www.geometrictools.com/ This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. Created: May 13, 2002 Last Modified: March 1, 2008 Contents 1 Discussion 2 1

1 Discussion This document shows how to compute the distance between two ellipses in two dimensions. The algorithm is based on constrained minimization and elimination theory. In this construction it is assumed that the ellipses are separated no intersection, one not contained in the other). An ellipse is represented parametrically by specifying a center C, two unit-length and mutually orthogonal axes ξ and η, and two lengths a and b. The four extreme points in the directions of the specified axes are C ± aξ and C ± bη. Introducing an angle θ [0, 2π), the parametric form is Some vector algebra shows that Xθ) = C + a cos θ)ξ + b sin θ)η. It follows that cos θ = ξ X C) a 1 = cos 2 θ + sin 2 θ and sin θ = η X C). b = 1 a ξ X C)) 2 + 1 b η X C)) 2 = X C) T ξξ T a 2 + ηηt b 2 ) X C) = X C) T R T D 2 RX C) where R T = [ξ η], a rotation matrix, and D = Diag1/a, 1/b), a diagonal matrix whose diagonal entries are 1/a and 1/b. The two ellipses are represented algebraically by quadratic equations and Q 0 X) = X C 0 ) T R T 0 D 2 0R 0 X C 0 ) 1 = 0 1) Q 1 Y) = Y C 1 ) T R T 1 D 2 1R 1 Y C 1 ) 1 = 0. 2) The problem is to compute X and Y, a point on each ellipse, that minimize X Y 2 subject to the constraints Q 0 X) = 0 and Q 1 Y) = 0. This may be solved by the method of Lagrange multipliers. However, it turns out that it is convenient to first make a change of variables. Define U = D 0 R 0 X C 0 ) and V = D 1 R 1 Y C 1 ). The constraints become U = 1 and V = 1. The goal now is to minimize X Y 2 = AU BV + C 2 subject to U and V being unit length. The quantities on the right-hand side are A = R0 T D0 1, B = RT 1 D1 1, and = C 0 C 1. Introduce Lagrange multipliers s and t and define F U, V; s, t) = AU BV + 2 + s U 2 1) + t V 2 1). The minimum occurs when F = 0 where the gradient is with respect to six variables: the two components of U, the two components of V, and the two multipliers s and t. The derivative with respect to U leads to the equation U = AT AU BV + ) + su = 0. 3) 2

The derivative with respect to V leads to the equation V = BT AU BV + ) tv = 0. 4) The derivatives with respect to s and t lead to equations that just reproduce the constraints, s = U 2 1 = 0 and t = V 2 1 = 0. Multiplying by the inverses of the transposes in equations 3) and 4) leads to sa T U + AU BV + ) = 0 tb T V AU BV + ) = 0 The first equation implies that A T U and AU BV + are parallel. The second equation implies that B T V and AU BV + are parallel. Consequently, the three vectors A T U, B T V, and AU BV + are all parallel. Define W = A T U) where x, y) = y, x). The fact that A T U and AU BV+ are parallel implies The fact that A T U and B T V are parallel implies W T AU BV + ) = 0. W T B T V) = 0. The two equations are rearranged in matrix form as m 00 m 01 m 10 m 11 WT B V = W T B T V = WT AU + ) 0 = n 0 where the 2 2 coefficient matrix on the left-hand side is partitioned into two row vectors. Each entry of the coefficient matrix that multiplies V is a linear polynomial in the components of U. The first row entry in the 2 1 column vector on the right-hand side is a quadratic polynomial in the components of U. The rotation matrices in the ellipses are R 0 = c 0 s 0 s 0 c 0 and R 1 = c 1 s 1 s 1 c 1 for some angles φ 0 and φ 1 with c i = cosφ i ), s i = sinφ i ) for i = 0, 1. The diagonal matrices are D 0 = Diag1/, 1/ ) and D 1 = Diag1/a 1, 1/b 1 ). Define U = u 0, ), V = v 0, v 1 ), and = 0, 1 ). The components of the linear system are calculated to be a1 sinφ0 φ1) m 00 = u 0 + m 01 = b1 cosφ0 φ1) u 0 + a1 cosφ0 φ1) b1 sinφ0 φ1) m 10 = sinφ0 φ1) a 1 u 0 + cosφ0 φ1) a 1 m 11 = cosφ0 φ1) u 0 + sinφ0 φ1) n = 0s 0 b 1 1c0 ) u 0 + ) 0c 0 + 1s0 + b 1 ) b0 u 0. 3

The solution to the system for V is v 0 = m 11 n/m 00 m 11 m 01 m 10 ) v 1 = m 10 n/m 00 m 11 m 01 m 10 ). 5) Since V is unit length, or 1 = m 11n) 2 + m 10 n) 2 m 00 m 11 m 01 m 10 ) 2 P u 0, ) = m 2 11 + m 2 10)n 2 m 00 m 11 m 01 m 10 ) 2 = 0. The polynomial P is of degree 6 when both ellipses are not circles. If the first ellipse is a circle, then the coefficient of u 0 in n is zero, in which case P is of degree 4. Suppose P has degree 6; then P u 0, ) = 6 k=0 p k u 0 )u k 1 = p 0 + p 2 u 2 1 + p 4 u 4 1 + p 6 u 6 1) + u1 p1 + p 3 u 2 1 + p 5 u 4 ) 1 6) where p k u 0 ) are polynomials in u 0 whose degree is at most 6 k. We also know that U is unit length, so replacing this in equation 6) leads to u 2 1 = 1 u 2 0. 7) P u 0, ) = p 0 + p 2 1 u 2 0) + p 4 1 u 2 0) 2 + p 6 1 u 2 0) 3) + p1 + p 3 1 u 2 0) + p 5 1 u 2 0) 2) = αu 0 ) + βu 0 ) where αu 0 ) is a polynomial of degree 6 and βu 0 ) is a polynomial of degree 5. Setting this to zero and solving yields = αu 0) βu 0 ). Squaring, using equation 7), and rearranging terms leads to The polynomial S has degree 12. Su 0 ) = α 2 u 0 ) + u 2 0 1)β 2 u 0 ) = 0. 8) The following procedure creates pairs U and V, each potentially yielding the minimum distance between ellipses. 1. Solve equation 8) for its real-valued roots. For each root u 0 do: 2. Solve equation 7) for = ± 1 u 2 0. For each of the two pairs U = u 0, ) do: 3. Compute V from equation 5) by evaluating m ij and n at U and do: 4. Evaluate the squared distance AU BV + 2. 4

5. For all squared distances obtained by the above steps, the minimum value is the squared distance between the ellipses. In the case of a circle and an ellipse that is not a circle, P has degree 4, leading to a polynomial S of degree 8. It is better to formulate the problem by translating the circle to the origin and translating the ellipse center by the same amount. The distance between ellipse and circle is now obtained by computing distance from the ellipse to the origin, a calculation that requires solving a degree 4 polynomial equation, then subtracting the circle radius from that distance. Another observation is that you can set up the distance calculator as a numerical minimizer of a function of two variables. Just use the parametric representations for the ellipses. The two variables are the angles φ 0 and φ 1. Try your favorite minimizer on the squared distance between ellipses points, a function of the two angles. 5