    # Contact detection between an ellipsoid and a combination of quadrics

We analyze the characteristic polynomial associated to an ellipsoid and another quadric in the context of the contact detection problem. We obtain a necessary and sufficient condition for an efficient method to detect contact. This condition is a feature on the size and the shape of the quadrics and can be checked directly from their parameters. Under this hypothesis, contact can be noticed by means of discriminants of the characteristic polynomial. Furthermore, relative positions can be classified through the sign of the coefficients of this polynomial.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1. Introduction

The contact detection problem between objects is recurrent in CAD/CAM. Many disciplines such as computer graphics, computer animation, robotics, industrial manufacturing or surgical simulation, among many others, require the detection of collisions between objects in many of their developments. Different surfaces have been used to model the great variety of shapes of the objects under consideration. Furthermore, depending on the chosen surfaces, appropriate methods based on their features are developed. For example, methods applied to polyhedra (see, for example, ) differ from others developed for differentiable surfaces (see [1, 12] and references therein).

During last two decades, there has been an increasing use of quadric surfaces for modeling objects within the context of collision detection. This family of surfaces, together with conic curves, has been extensively studied, especially using techniques from Projective Geometry (see, for example,  for a classical reference where polarity is used to study the relative position of a pair of conics). When considering a pair of quadrics, much information about them is obtained using their associated pencil. Moreover, the characteristic polynomial obtained from the pencil provides important information linking the two surfaces. The work of Wang et al.  was seminal in introducing this polynomial associated to the pencil of two ellipsoids to detect contact between them. These methods have been extended to other quadric surfaces [2, 3] and exploited for practical uses, such as the detection of position for UAVs [4, 8]. The analysis of the intersection of quadrics was initiated much earlier (see ) and continues to be an active research field (see [15, 19, 21, 22, 23, 26] and references therein).

Quadric surfaces allow to approximate very accurately a large variety of shapes. This is one of the main reasons for their use in contact detection problems. Also, since quadric surfaces are described by means of a quadratic polynomial, they are easier to handle than many other curved surfaces. In this paper we consider two quadrics, one of which is an ellipsoid. This particular surface is the only closed quadric surface. This feature makes it the most appropriate selection for modeling an object just by one surface. Moreover, the three degrees of freedom provided by its three axes allow to approximate many different objects. This justifies that an important part of the literature in this field involves ellipsoids (see, for instance,

[16, 19, 22, 24]). However, the ellipsoid has positive curvature and the shape of other objects requires the use of other quadric surfaces, for example, hyperboloids with negative curvature. In this paper we address the problem of contact detection between an ellipsoid and another quadric surface.

Generally, we consider an ellipsoid and another quadric surface . While previous works as [2, 3, 24] treated particular quadrics, here we consider a wider class of surfaces. Along this work, the possible quadric surface is going to be one of the following: ellipsoid, hyperbolic or elliptic paraboloid, hyperboloid of one or two sheets, elliptic, parabolic or hyperbolic cylinder, or two planes. We shall make clear that we avoid the use of two coincidental planes as the quadric , since from a geometric viewpoint they are equivalent to one plane. Let and be their associated matrices. The characteristic polynomial of the pencil is the fourth degree polynomial given by

 (1) P(λ)=det(λE+Q).

Notice that, since is non-degenerate, the roots of are the characteristic roots of the matrix , so we will refer to them as the characteristic roots of .

The characteristic roots of permitted to detect the relative position between two ellipsoids, an ellipsoid and a paraboloid, or an ellipsoid and a hyperboloid of one sheet in [24, 2, 3] in some instances. In particular, it was shown that if there exists two complex conjugate (non-real) roots of then the quadric surfaces are in non-tangent contact. The converse is not true in general, as two quadrics may intersect non-tangentially and have four real roots (counted with multiplicity).

Since the existence of non-real roots can be easily detected by the discriminant of the polynomial , it would be desirable to understand under which circumstances contact between quadrics can be noticed by a direct computation of the discriminant. This is the first aim of this work and with that purpose we introduce the following concept that relates the size and shape of the two quadric surfaces.

###### Definition 1.

Smallness condition. We say that the ellipsoid is small with respect to the quadric surface if the intersection of the two quadric surfaces cannot be two curves at any relative position.

We consider that a curve is a -dimensional connected set. The number of connected components of the intersection of two quadric surfaces ranges from to (see ), so the smallness condition rules out the possibility of two connected components in the intersection which are curves, but allows two isolated tangent points. We will see in Section 3 (Lemma 7) that the possibility of one isolated tangent point and a curve is also eliminated by the smallness condition. A similar definition was first given in  to solve the particular problem of an ellipsoid and an elliptic paraboloid, although the condition was slightly more restrictive, since two tangent points were not allowed as a possible intersection set.

The smallness condition given in Definition 1 is going to be analyzed in detail in Section 2. Intersecting planes or cones do not satisfy Definition 1 for any ellipsoid, whereas for other quadric surfaces it depends on some relations between the length axes and the curvature of the two surfaces. In Theorem 5 we show how to check that and satisfy the smallness condition by means of the parameters in the quadric equations. This characterization in terms of the parameters makes the condition more tractable computationally and allows a purely algorithmic checking.

We respond to the first objective of this work showing that the smallness condition in Definition 1 is a precise hypothesis that implies the equivalence between transversal contact (i.e., non-tangent contact) of the two quadric surfaces and the presence of non-real characteristic roots.

###### Theorem 2.

Let be a small ellipsoid with respect to the quadric surface . Then and are in transversal contact if and only if the characteristic polynomial has a pair of complex conjugate (non-real) roots.

The proof of Theorem 2 is given in Section 3. The approach differs substantially to those followed in previous works as [2, 3], since it is based on the analysis of the possible intersections between quadrics. Moreover, the new approach relies on a combination of algebraic tools and methods from differential geometry.

Based on Theorem 2, we can detect contact exclusively using discriminants associated to the characteristic polynomial, without the need of computing explicitly the roots of (1). This provides an efficient way of detecting contact as will be shown in Section 3 (see Corollary 9). The detection of contact and relative positions between an ellipsoid and a plane is considered separately in Section 5.1 (see Theorem 13).

Additionally to the detection of contact through the nature of the characteristic roots, the information encoded in the characteristic polynomial allows to detect the relative position between the two quadrics. Section 4 is devoted to this task in the present context and previous results in [2, 3, 24] are extended. In Theorem 12, the relative position of the small ellipsoid with respect to the quadric surface is characterized in terms of the sign of the characteristic roots or, alternatively, in terms of the sign of the coefficients of . Thus, this provides a computationally efficient method to approach the problem of identifying relative positions.

The second main goal of this work is to provide an efficient method to detect contact between a small ellipsoid and a combination of quadrics. The idea of composing geometric objects was considered, for example, in  for specific quadrics. We are considering here a more general context addressed in Section 5, where an algorithm is proposed for an efficient detection of the relative position between them. Thus, this proposal allows to model a great variety of real-world situations where two objects interact: a small ellipsoid models one of them and the other one is modeled by pieces of quadrics separated by a plane or other quadrics. A simple example is included to illustrate the method for particular quadric surfaces.

## 2. The smallness condition

Along this section we analyze in detail the smallness condition given in Definition 1. First, we must emphasize that the smallness condition is a condition in a pair of surfaces and it depends on the relation between the two of them. Also, it is intrinsic to the geometry of the two surfaces, so it does not depend on a particular position, but on the possibility that the two surfaces intersect in two curves when they are placed appropriately. As a consequence, since rigid motions do not alter the geometry of the surfaces, this smallness condition is invariant under rigid transformations of space.

Notice that if the quadric is a pair of intersecting planes or a cone, then one can place close enough to the intersecting ray or the vertex, respectively, to see that the smallness condition is not satisfied. Therefore, intersecting planes and cones are excluded from the analysis.

One of the main interests of Theorem 2 is that we get a simple way to detect contact between the quadric surfaces. This provides an efficient algorithm with a simple implementation. Since the smallness condition is a necessary hypothesis, for practical purposes it would also be convenient to express it in a way that can be checked computationally. We will make this condition more tangible by inequalities in terms of the parameters of the quadrics.

Depending on the quadric that we consider, the smallness condition in Definition 1 results in different kind of restrictions. Some are related with the distance between particular points in and affects directly to the axes of , whereas others depend on the curvature and impose conditions on the relations between the axes of . In order to specify them we consider a general ellipsoid in standard form

 (2) x2α2+y2β2+z2γ2=1, with α≥β≥γ,

### 2.1. Direct restrictions on the axes (size).

We assume is small with respect to the quadric . If is an ellipsoid, a hyperboloid of one or two sheets, an elliptic or a hyperbolic cylinder, or two parallel planes, then a first relation between the parameters of and is obtained by a direct study of distances between points of the surfaces. If the quadric is an ellipsoid

 x2a2+y2b2+z2c2=1, with a≥b≥c,

it is immediate that if the ellipsoid is small in comparison with then the largest axis of must be smaller than or equal to the smallest axis of . Hence, we conclude that . If the quadric is a hyperboloid of one sheet

 x2a2+y2b2−z2c2=1, with a≥b,

then the major axis of must be smaller than or equal to the smaller axis of . Hence, we conclude that . Also, if the quadric is a hyperboloid of two sheets

 x2a2+y2b2−z2c2=−1, with a≥b,

then the major axis of must be smaller than or equal to the distance between vertices in . Hence we conclude that .

The cases where is a cylinder can be projected orthogonally to a plane which is perpendicular to the axis. If is an elliptic cylinder with , it is clear that a necessary condition is . Whereas if is a hyperbolic cylinder then .

Finally, for parallel planes with equation , we observe that is the minimum distance between two points that lie on different planes. Hence, the only restriction to avoid the possibility of two curves in the intersection is that .

### 2.2. Restrictions on the relations between axes (shape).

The previous conditions between the ellipsoid and the quadric , however, are not sufficient for the smallness condition to be satisfied. See, for example, Figure 1. The curvature of the two quadric surfaces also plays a role in the verification of the smallness condition. Recall that the normal curvature of a surface at a point in a fixed direction is given by the curvature at of the curve obtained by the normal section in the direction of , this is, obtained by intersecting the surface with the normal plane at which contains . Also, the maximum and minimum normal curvatures ( and ) at a point are the principal curvatures of the surface at . We denote by and , respectively, the maximum and minimum principal curvature of the surface . The other conditions that the surfaces and must satisfy for to be small in comparison with can be stated in terms of the principal curvatures of the surfaces. Figure 1. The ellipsoid is not small with respect to the hyperboloid. There is a condition on the principal curvatures of the quadric surfaces for the smallness condition to be satisfied.
###### Lemma 3.

If an ellipsoid is small with respect to another quadric then

 κQmax≤κEmin.
###### Proof.

In order to compare the principal curvatures of the two surfaces, we are going to place the quadrics in the more favorable position for the presence of intersection curves. Then we reduce the problem in one dimension by considering sections by a suitable plane. Note that if the smallness condition is not satisfied, then there is an appropriate position between the quadrics so that the intersection has two curves. Hence an intentionally chosen normal section by a plane gives two conics that intersect in four different points. The conic obtained from the small ellipsoid is an small ellipse (i.e. an ellipse that cannot intersect the other conic in more than two points). Consequently, the result follows directly from the following:

Claim: if the smallness condition is satisfied, then the curvature at any point of the small ellipse is greater than or equal to the curvature at any point of the other conic.

The next objective is to prove this claim. The problem trivializes if one conic is a ray, so we study the situations given by pairs of conics of the form ellipse-ellipse, ellipse-parabola or ellipse-hyperbola and analyze them separately as follows.

Ellipse-ellipse: in order to simplify the calculation and compare curvatures we place the small ellipse so that it is tangent to the other ellipse in one vertex (see Figure 2(i)). Now the corresponding equations are

 (3) E:(x−a+β)2β2+y2α2=1 and% C1:x2a2+y2b2=1,

where and . The diameter of is smaller than or equal to any axis of for the smallness condition to be satisfied. Hence and we work with the inequalities in the parameters of the conics given by . Figure 2. The small ellipse E (red) is placed to be tangent to the conic C at the point of minimum curvature of the E and maximum curvature of C.

Note that this placement of the pair of conics is obtained as a section from an appropriate placement of the pair of quadric surfaces. If , then and we have two circles of the same radius that can coincide in all points, which is an admissible situation. Henceforth we assume and there is only one possible solution to the system of equations (3) for the smallness condition to be satisfied. Note that if they intersect in three points, then a slight variation of the position makes them intersect at four different points. Using we substitute in the equation of to obtain

 x=a or x=a(a2α2−2aα2β+b2β2)a2α2−b2β2.

The first solution corresponds to the tangent point and the second one gives

 (4)

For the smallness condition to be satisfied, there can not be more solutions for in (4) than . This implies that in (4). Note that if , then and the expression for reduces to . Now, if , since , all factors in (4) have to be positive, so we conclude that . In conclusion, we have that the desired relation between the parameters is .

An ellipse given by can be parameterized as with . Since the curvature along the curve is given by (see, for example, ), we have that the maximum curvature is attained at one vertex and its value is . Analogously, we see that the minimum curvature of the small ellipse is . Thus, the relation can be written equivalently in terms of the maximum and minimum curvatures of the ellipses as

 ab2≤βα2.

Ellipse-hyperbola: we place the ellipse , as in the previous case, tangent to the hyperbola at the vertex point (see Figure 2(ii)). The corresponding equations are

 (5) E:(x−a−β)2β2+y2α2=1 and% C2:x2a2−y2b2=1,

where . An analogous argument to that given for two ellipses now shows the relation between the maximum curvature of the hyperbola, which is attained at the vertex point and values , and the minimum curvature of the ellipse:

 ab2≤βα2.

Ellipse-parabola: we place the small ellipse tangent at the vertex point of the parabola (see Figure 2(iii)) so that the equations of the conics are

 E:x2α2+(y−β)2β2=1 and C3:x2a2−y=0.

The smallness condition is satisfied if and only if the system of equations has only the solution . We repeat the process above analyzing this two equations. As a result we obtain that the maximum curvature of the parabola, realized at the vertex point with value , is less than or equal to the minimum curvature of the ellipse:

 2a2≤βα2.

Hence the claim follows. ∎

### 2.3. Smallness condition for E and Q in standard form

Based on the previous analysis and the curvature conditions given in Lemma 3, we can now characterize the smallness condition in terms of relations between the parameters of the quadric surfaces.

###### Lemma 4.

Let be an ellipsoid given by equation (2) and let be another quadric in standard form. Then the conditions given in Table 1 are necessary and sufficient for to be small with respect to .

###### Proof.

In the case of the ellipsoid, the hyperboloids and the elliptic and hyperbolic cylinders, when doing sections by normal planes, one can obtain ellipses and hyperbolas. Thus, considering any section, the diameter of the ellipse given by has to be smaller than the axes of the ellipse and the transverse axis of the hyperbola of . These give rise to the first condition in each of these cases in Table 1. For all the quadric surfaces but parallel planes there is a condition in terms of the principal curvatures that was given in Lemma 3.

If the smallness condition is not satisfied, then there is a position where the two surfaces intersect in two curves. Moving the surface adequately if necessary, a case by case analysis of the pair of surfaces shows that the condition on the axes of the quadrics (see Subsection 2.1) or the condition on the curvature (see Subsection 2.2) is not satisfied. ∎

### 2.4. Smallness condition for E and Q in general form

The results given in this paper are intended to be used in practical real-life contexts, where one does not generally have quadric surfaces in standard form. Since the smallness condition is a necessary hypothesis, it is convenient to have a way to check it, without necessarily changing coordinates and reducing equations to standard form. As the smallness condition is invariant under rigid transformations, the associated invariants to quadric surfaces are enough to determine whether the smallness condition holds for a given pair of quadrics. In this subsection we recall which are the needed invariants and provide the precise relations between them to check the smallness condition.

The general equation of a quadric in Euclidean coordinates given by

 (6) 3∑i,j=1aijxixj+3∑i=12bixi+c=0, where aij=aji,

can be written as with and the quadric’s matrix:

 Q=(aij|bjbi|c) with i,j=1,2,3.

Associated to this equation, we have the following invariants:

• The determinant of : .

• The eigenvalues of

, that are labeled as and . Observe that, as a consequence, the trace of , , and the determinant of , , are also invariant.

• .

• If is the adjoint matrix of in : .

• .

###### Theorem 5.

Let be an ellipsoid and another quadric. Then the relations given in Table  2 are necessary and sufficient for to be small with respect to .

###### Proof.

Due to the invariance under rigid transformations of the smallness conditions and the invariants associated to the quadric surfaces, the result follows from Lemma 4. ∎

Note that, from the relations given in Table  2, it is immediate to verify whether the smallness condition holds for a given pair of quadrics.

## 3. Contact detection between the quadric surfaces

In this section we assume is an small ellipsoid with respect to a quadric . We deal with results aimed to detect contact between the two quadric surfaces. First we give the proof of Theorem 2 and, secondly, we provide more efficient methods based on the use of a system of discriminants for the characteristic polynomial.

### 3.1. Proof of Theorem 2

We prove the main result by studying the possible intersections between two quadric surfaces. In order to do that, we begin by analyzing intersections which are a curve with a tangent point (see Figure 3).

###### Lemma 6.

If and intersect in a curve and there is a point where the surfaces are tangent, then there is one normal curvature that coincides for the two surfaces at .

###### Proof.

Let be the intersection curve for and . Analyzing the possibilities of intersection curves between the quadric surfaces (see, for example, [23, 26]) we see that is a differentiable curve except, perhaps, at the tangent point (for example, if the intersection curve is a cuspidal quartic then there is a singularity at the cusp at ). We work in a neighborhood of and parameterize an arc of as so that , is continuous in and smooth in .

Since is smooth in , we choose a regular parameterization and compute for all . We normalize

to assign a unit vector

to each point for . Now, we define to extend the unit tangent vector to .

Let and be the normal curvatures at in the direction of in and , respectively, for . These two functions and vary smoothly along . Now, note that the normal curvatures and can be obtained from the curvature of by projecting on the normal vector to each of the surfaces for . Observing that the normal vector of and varies smoothly along for and that the normal vector of the two surfaces coincides in , by continuity of the normal vector, of , of and of , we conclude that the normal curvature of the two surfaces in the direction of at is the same. ∎

###### Lemma 7.

Let be small with respect to . If they intersect in a curve and are tangent at a point , then is a circle, belongs to and the quadric surfaces are tangent along .

###### Proof.

We begin by proving that belongs to . We argue by contradiction, so we assume first that does not belong to the curve . Then the intersection of the quadrics has one connected component which is the curve and another connected component which is the tangent point. A straightforward analysis of the morphology of the possible intersections between two quadrics shows that this tangent point is an isolated tangent point. Therefore, slightly translating in the appropriate direction transforms the isolated tangent point in a differentiable curve. Thus, after the translation there are two connected components which are curves, so the smallness condition is not satisfied. Hence, we conclude that belongs to .

Now, if belongs to , then Lemma 6 applies and we have that the normal curvature of the two surfaces at in the direction of the curve coincides. If , and , are the principal curvatures of the surfaces, in virtue of Lemma 3, the following relation is satisfied:

 κQmin≤κQmax≤κEmin≤κEmax.

Since and , we conclude that . Hence the normal curvature in the tangent direction of at is principal and, moreover, is the maximum principal curvature for and the minimum principal curvature for . Therefore, the point has to be a vertex of with minimum principal curvature and a vertex of with maximum principal curvature. Note that, because and are tangent at , the two surfaces share the same tangent plane at . Now, we consider a section of and by a plane trough which is orthogonal to the tangent plane at and that intersects at least in another point different from (this is possible, since is closed). This plane intersects and in two conic curves: (which is an ellipse) and (possibly with two connected components). The point is a vertex for the two curves and the curvature of at is greater than or equal to the curvature of at . Hence is necessarily an ellipse or has two connected components. More specifically, is an ellipsoid, a hyperboloid of one sheet or an elliptic cylinder.

If is an ellipsoid, since is an small ellipsoid which shares a vertex with where they are tangent, the only possibility is that the two ellipsoids are tangent along the greater ellipse of . But, because this ellipse is common to the two ellipsoids and the maximum normal curvature of is smaller than the minimum normal curvature of (see Lemma 3), the curvature at all points of the ellipse must be the same, so it is a circle. Moreover, since the curvature of this circle is the minimum normal curvature for , this quadric has to be an sphere. As a consequence of the smallness condition, since the two ellipsoids share a tangent circle, the only possibility in this case is that the two ellipsoids are coincidental spheres.

Similar arguments are used if is an hyperboloid or an elliptic cylinder to conclude that the tangent curve is a circle, but in this case we get admissible cases as in Figure 4. ∎ Figure 4. (a)  Two ellipsoids sharing a tangent circle do not satisfy the smallness condition. (b)  A circular hyperboloid of one sheet and a circular cylinder provide admissible examples.

Proof of Theorem 2.

We consider an ellipsoid and another quadric surface in the affine space. For convenience, the quadric surfaces can be thought at the real projective space and the affine space is a realization of it where we choose a plane at infinity. Since one of the quadric surfaces is an ellipsoid, the plane at infinity does not intersect the quadric surface and, therefore, the intersection of the two quadrics does not have points at the plane at infinity. Hence, when we consider the possible intersection curves in , only homotopically null curves are admissible, which give rise to close curves in affine space. Since, moreover, we consider a ellipsoid which is small in comparison with the other quadric, we can also eliminate some other cases. Neither a curve and an isolated tangent point nor a curve with a tangent point are compatible with this hypothesis, as shown in Lemma 7. A direct application of the smallness condition also rules out the possibility of two curves as the intersection set.

From a topological point of view and attending to the classification of intersections between quadrics given in , we have the following possibilities for the intersection set of and , related with their respective Segre types and the roots of the characteristic polynomial:

1. : no contact between the quadrics. The possible Segre types are , , and . Thus, the eigenvalues are real.

2. Isolated tangent points. There are two possibilities, both of which can be realized:

1. isolated tangent point: cases 7, 22, 25 and 33 in . The Segre types are , , and , which correspond to real eigenvalues.

2. isolated tangent points: cases 15 and 30 in , with corresponding Segre types and . As in the previous case, all eigenvalues are real.

3. One curve. Depending on the existence of tangency, we consider two cases:

1. connected component with no tangent points: cases 3, 13 and 17 in , with corresponding Segre types or . Hence, there is a pair of complex conjugate (non real) roots.

2. connected component with all points of tangency: case 19 in . The Segre type is , so there is a triple root and a single root.

We include the previous classification in Table 3. As a conclusion, under the hypotheses of Theorem 2, the transversal contact is identified by non-real roots. Hence, the characterization of Theorem 2 follows. ∎

###### Remark 8.

We shall emphasize that the smallness condition given in Definition 1 is a necessary hypothesis in Theorem 2. Indeed, if the intersection has two connected components which are two curves, then the associated Segre types are and , with four real roots. Also, in the two cases where the intersection is a curve and an isolated tangent point the associated Segree types are and , again with real roots. Hence, the smallness condition cannot be relaxed in Theorem 2. However, non-real roots for the characteristic polynomial always imply transversal contact, even if the smallness condition fails. Moreover, this is a general fact for any pair of quadrics. A direct analysis of the type of intersection between two quadrics (see ) for Segre types with non-real roots shows the following:

If the characteristic polynomial associated to any two quadrics has non-real roots, then they are in transversal contact.

### 3.2. Contact detection using discriminants of P(λ)

From a Complete Discrimination System one can determine the number and multiplicities of the real roots. We consider a general characteristic polynomial (1), which has degree four:

 (7) P(λ)=c4λ4+c3λ3+c2λ2+c1λ+c0,

where are coefficients determined by the parameters of the quadrics. In the case at hand, where we can detect transversal contact between quadrics just by checking two Segre types, we only need two terms of the discrimination system. We define (see [10, 25]):

 Δ3=16c24c0c2−18c24c21−4c4c32+14c4c1c3c2−6c4c0c23+c22c23−3c1c33,\omit\span\omit\span\@@LTX@noalign\vskip12.0ptplus4.0ptminus4.0pt\omitΔ4=256c30c34−192c20c1c3c24−128c20c22c24+144c20c2c23c4−27c20c43\omit\span\omit\span\@@LTX@noalign\vskip6.0ptplus2.0ptminus2.0pt\omit+144c0c21c2c24−6c0c21c23c4−4c31c33−80c0c1c22c3c4+18c0c1c2c33\omit\span\omit\span\@@LTX@noalign\vskip6.0ptplus2.0ptminus2.0pt\omit+16c0c42c4−4c0c32c23−27c41c24+18c31c2c3c4−4c21c32c4+c21c22c23.

Using the determination of roots in terms of these two discriminants, we obtain the following consequence of Theorem 2.

###### Corollary 9.

Let be a small ellipsoid with respect to the quadric surface . Then and are in transversal contact if and only if one of the following holds:

1. ,

2. and .

###### Proof.

In the proof of Theorem 2 we saw that the possible Segre types for the transversal contact are or . Following , the Segre type is determined by and by and (see Table 3). ∎

The possibility (1) in Corollary 9 is more likely to appear in real world applications than the possibility (2), since the later appears only with a double real root and the set of this configuration has zero measure in the total space. However it has to be taken into account for the implementation of a collision detection algorithm. The following example illustrates this phenomenon.

###### Example 10.

We consider the ellipsoid and the elliptic paraboloid . The characteristic polynomial is , so there is a real double root and complex conjugate roots . The discriminants satisfy:

 Δ4=0 and Δ3=−400,

as in the possibility (2) of Corollary 9. Thus, we conclude that the two quadrics are in transversal contact, as shown in Figure 5. Notice that, in virtue of Remark 8, we do not need to check that the smallness condition is satisfied. Figure 5. Contact is detected in terms of discriminants of the characteristic polynomial.

## 4. Relative positions of a small ellipsoid and another quadric

When working with two objects in real world applications, sometimes it is important not only to detect contact, but also to know the relative position between them. Especially if the detection of contact involves solid objects whose border is modeled with surfaces, during a simulation it is a necessary task to detect when the smaller body is in the interior of the other. Thus, as a first step, Theorem 2 allows to detect transversal contact between the surfaces, but if there is no contact, it would be desirable to know the relative position between the quadrics, this is, in which region of the space determined by the quadric is placed the small ellipsoid . This problem was already solved in  for a small ellipsoid and an elliptic paraboloid.

We are considering quadrics which divide the projective space into two connected regions. Thus, considering the matrix associated to the quadric and working in homogeneous coordinates as before, we distinguish regions and given by

 (8) R−={(x,y,z)∈R3/XTQX≤0} and R+={(x,y,z)∈R3/XTQX≥0}.

Since we are working in affine space, these regions are not always connected, as it occurs with the hyperboloid of two sheets, where has two connected components (see Figure 6). Moreover, in some cases, depending on the quadric , we intuitively identify with the interior region and with the exterior one (for example, if we consider an ellipsoid). However this terminology is not so convenient for other quadrics, as the hyperbolic paraboloid. Therefore we will refer to these regions as and . Also, note that we do not use strict inequalities in the definition of the two regions. Hence we allow tangent contact and still say that belongs to or . We emphasize that the intersection of and is not empty, indeed, the two regions intersect in the points of the quadric surface.

The purpose of this section is to identify the relative position of a small ellipsoid with respect to another quadric . This relative position is considered from a topological viewpoint, so we are interested in detecting the region of the space divided by in which is located. From Corollary 9 we know how to detect contact in terms of the discriminants of the characteristic polynomial . Thus, in what follows, we assume there is no contact, or just a tangent contact, so that either all points of are located in or all of them belong to . Our objective is to know in which of them are they in terms of the sign of the characteristic roots. Since the possible quadric surfaces have different features, we show in the next lemma how to deal with the hyperboloid of two sheets as a sample case. For other quadrics we proceed in an analogous way and we omit details in the interest of brevity (see Theorem 12 below).

###### Lemma 11.

Let be a small ellipsoid and a hyperboloid of two sheets. Then

• is placed in if and only if has four negative real roots.

• is placed in if and only if has two negative and two positive real roots.

###### Proof.

First note that, if is not completely within or , then it is in transversal contact with and, by Theorem 2, there are non-real characteristic roots. Hence, let be a small ellipsoid which is not in transversal contact with a hyperboloid of two sheets . Since the relative position is invariant under rigid moves, as are the roots of the characteristic polynomial (see ), we can locate so that it is in standard form as in Table 1 and its associated matrix is diagonal: . Notice also that by applying a rigid transformation the quadric still satisfy the smallness condition.

We are going to place the center of the ellipsoid at two particular points and then argue using continuity to extend the result. Since both the relative position and the roots of the characteristic polynomial are invariant under scalings (see  for details), we firstly place the ellipsoid in so that the center is at (see Figure 6(b)) and secondly place it in so that it is tangent to the vertex of (see Figure 6(c)). Now, appropriate scalings let us transform into a sphere of radius . Note that the necessary scalings of the space that transform the ellipsoid into such a sphere also transform , but it is still of the given generic form. The equation of the sphere with center is

 (9) (x−xc)2+(y−yc)2+(z−zc)2=1,

so the associated matrix is

 (10) S=⎛⎜ ⎜ ⎜⎝100−xc010−yc001−zc−xc−yc−zc−1+x2c+y2c+z2c⎞⎟ ⎟ ⎟⎠.

A direct calculation shows that the characteristic polynomial is given by

Firstly, we consider the center of the sphere to be , so is placed in , and we see that . Hence, there are 2 positive and 2 negative roots in this particular position.

Secondly, we consider the center of the sphere to be , so is placed in , and we check that . Hence, there are 4 negative characteristic roots in this particular position.

Now, since , we have that is not a characteristic root. Given that the characteristic roots are real and vary continuously as we move the ellipsoid and is not a root, the sign of the roots cannot change while we move within or . Thus, because is connected, we conclude that there are 2 positive and 2 negative roots if . Since has two connected components, we pass to the projective space (or simply repeat the previous calculation for