Distance Between Ellipses in 2D

Similar documents
Section 1.1. Introduction to R n

Content. Chapter 4 Functions Basic concepts on real functions 62. Credits 11

MAT 200, Midterm Exam Solution. a. (5 points) Compute the determinant of the matrix A =

ISOMETRIES OF R n KEITH CONRAD

Chapter 6. Orthogonality

Inner Product Spaces and Orthogonality

Figure 1.1 Vector A and Vector F

December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B. KITCHENS

MAT188H1S Lec0101 Burbulla

Linear Programming. March 14, 2014

Identifying second degree equations

Algebra 2 Chapter 1 Vocabulary. identity - A statement that equates two equivalent expressions.

by the matrix A results in a vector which is a reflection of the given

Similarity and Diagonalization. Similar Matrices

Linearly Independent Sets and Linearly Dependent Sets

Math 215 HW #6 Solutions

Linear Algebra Notes

LINES AND PLANES CHRIS JOHNSON

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

Lectures notes on orthogonal matrices (with exercises) Linear Algebra II - Spring 2004 by D. Klain

[1] Diagonal factorization

5. Orthogonal matrices

Chapter 19. General Matrices. An n m matrix is an array. a 11 a 12 a 1m a 21 a 22 a 2m A = a n1 a n2 a nm. The matrix A has n row vectors

Notes on Orthogonal and Symmetric Matrices MENU, Winter 2013

1 VECTOR SPACES AND SUBSPACES

LINEAR ALGEBRA W W L CHEN

Orthogonal Projections

CS3220 Lecture Notes: QR factorization and orthogonal transformations

DATA ANALYSIS II. Matrix Algorithms

Algebra Unpacked Content For the new Common Core standards that will be effective in all North Carolina schools in the school year.

3.1. Solving linear equations. Introduction. Prerequisites. Learning Outcomes. Learning Style

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

Inner Product Spaces

Parametric Equations and the Parabola (Extension 1)

Lecture L3 - Vectors, Matrices and Coordinate Transformations

Introduction to Matrix Algebra

Physics 235 Chapter 1. Chapter 1 Matrices, Vectors, and Vector Calculus

Essential Mathematics for Computer Graphics fast

Nonlinear Iterative Partial Least Squares Method

South Carolina College- and Career-Ready (SCCCR) Pre-Calculus

Equations, Inequalities & Partial Fractions

1 Introduction to Matrices

Eigenvalues and Eigenvectors

Chapter 17. Orthogonal Matrices and Symmetries of Space

Introduction to Matrices for Engineers

Mathematics Course 111: Algebra I Part IV: Vector Spaces

Linear algebra and the geometry of quadratic equations. Similarity transformations and orthogonal matrices

6. Cholesky factorization

Biggar High School Mathematics Department. National 5 Learning Intentions & Success Criteria: Assessing My Progress

Lecture 5: Singular Value Decomposition SVD (1)

Vector Math Computer Graphics Scott D. Anderson

Rotation Matrices and Homogeneous Transformations

Least-Squares Intersection of Lines

Adding vectors We can do arithmetic with vectors. We ll start with vector addition and related operations. Suppose you have two vectors

11.1. Objectives. Component Form of a Vector. Component Form of a Vector. Component Form of a Vector. Vectors and the Geometry of Space

Mathematics Pre-Test Sample Questions A. { 11, 7} B. { 7,0,7} C. { 7, 7} D. { 11, 11}

9 MATRICES AND TRANSFORMATIONS

Linear Algebra Notes for Marsden and Tromba Vector Calculus

x(x + 5) x 2 25 (x + 5)(x 5) = x 6(x 4) x ( x 4) + 3

LINEAR ALGEBRA. September 23, 2010

1.5 SOLUTION SETS OF LINEAR SYSTEMS

Geometric description of the cross product of the vectors u and v. The cross product of two vectors is a vector! u x v is perpendicular to u and v

PYTHAGOREAN TRIPLES KEITH CONRAD

13.4 THE CROSS PRODUCT

Equations Involving Lines and Planes Standard equations for lines in space

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

MATH APPLIED MATRIX THEORY

Math Common Core Sampler Test

Solving Simultaneous Equations and Matrices

2x + y = 3. Since the second equation is precisely the same as the first equation, it is enough to find x and y satisfying the system

Geometry of Vectors. 1 Cartesian Coordinates. Carlo Tomasi

Similar matrices and Jordan form

3.3. Solving Polynomial Equations. Introduction. Prerequisites. Learning Outcomes

Question 2: How do you solve a matrix equation using the matrix inverse?

MATH 304 Linear Algebra Lecture 18: Rank and nullity of a matrix.

Inner product. Definition of inner product

x1 x 2 x 3 y 1 y 2 y 3 x 1 y 2 x 2 y 1 0.

A linear combination is a sum of scalars times quantities. Such expressions arise quite frequently and have the form

The Matrix Elements of a 3 3 Orthogonal Matrix Revisited

13 MATH FACTS a = The elements of a vector have a graphical interpretation, which is particularly easy to see in two or three dimensions.

Linear Algebra Review. Vectors

Section 9.5: Equations of Lines and Planes

APPLICATIONS AND MODELING WITH QUADRATIC EQUATIONS

JUST THE MATHS UNIT NUMBER 1.8. ALGEBRA 8 (Polynomials) A.J.Hobson

Operation Count; Numerical Linear Algebra

3. Let A and B be two n n orthogonal matrices. Then prove that AB and BA are both orthogonal matrices. Prove a similar result for unitary matrices.

Solving Systems of Linear Equations

Abstract: We describe the beautiful LU factorization of a square matrix (or how to write Gaussian elimination in terms of matrix multiplication).

The Characteristic Polynomial

Linear Equations in Linear Algebra

Recall the basic property of the transpose (for any A): v A t Aw = v w, v, w R n.

MATH 304 Linear Algebra Lecture 9: Subspaces of vector spaces (continued). Span. Spanning set.

Section 1.4. Lines, Planes, and Hyperplanes. The Calculus of Functions of Several Variables

APPLICATIONS. are symmetric, but. are not.

Systems of Linear Equations

Derive 5: The Easiest... Just Got Better!

University of Lille I PC first year list of exercises n 7. Review

Numerical Analysis Lecture Notes

The Singular Value Decomposition in Symmetric (Löwdin) Orthogonalization and Data Compression

The Fourth International DERIVE-TI92/89 Conference Liverpool, U.K., July Derive 5: The Easiest... Just Got Better!

Transcription:

Distance Between Ellipses in 2D David Eberly Geometric Tools, LLC http://www.geometrictools.com/ Copyright c 1998-2016. All Rights Reserved. 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