0% found this document useful (0 votes)
114 views12 pages

Intersecting Two Quadrics With Geogebra: Abstract. This Paper Presents The First Implementation in Geogebra

This document presents an algorithm for computing the intersection curve of two quadric surfaces in 3D space using GeoGebra. The algorithm projects the intersection curve onto the plane z=0, called the cutcurve, and determines its singularities and structure. It then lifts the cutcurve back into 3D, computing the intersection curve. This allows GeoGebra to represent and compute the intersection of general quadric surfaces, overcoming previous limitations.

Uploaded by

Moises Toledo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
114 views12 pages

Intersecting Two Quadrics With Geogebra: Abstract. This Paper Presents The First Implementation in Geogebra

This document presents an algorithm for computing the intersection curve of two quadric surfaces in 3D space using GeoGebra. The algorithm projects the intersection curve onto the plane z=0, called the cutcurve, and determines its singularities and structure. It then lifts the cutcurve back into 3D, computing the intersection curve. This allows GeoGebra to represent and compute the intersection of general quadric surfaces, overcoming previous limitations.

Uploaded by

Moises Toledo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Intersecting Two Quadrics

with GeoGebra

Alexandre Trocado1(B) , Laureano Gonzalez-Vega2 ,


and José Manuel Dos Santos1
1
Universidade Aberta, Lisbon, Portugal
[email protected], [email protected]
2
Universidad de Cantabria, Santander, Spain
[email protected]

Abstract. This paper presents the first implementation in GeoGebra


of an algorithm computing the intersection curve of two quadrics. This
approach is based on computing the projection of the intersection curve,
also known as cutcurve, determining its singularities and structure and
lifting to 3D this plane curve. The considered problem can be used to
show some of the difficulties arising when implementing in GeoGebra
a geometric algorithm based on the algebraic analysis of the equations
defining the considered objects.

Keywords: GeoGebra · Cutcurve · Intersection curve · Lifting

1 Introduction

Algorithms for computing quadrics intersection date back to the late seventies.
Computing the representation of the curve defined as the intersection of two
quadrics has been a relevant problem to solve over the last decades. Levin in
1976 and 1979 (see [6,7]) introduced a method failing when the intersection
curve is singular and even generates results that are not topologically correct.
Levin’s method has been improved by Wang et al. (see [12]) making it capable
of computing geometric and structural information. Besides, Dupont et al. (see
[2]) succeeded in finding parameterizations that overcame the fact that Levin’s
method generated formulas that were not suited for further symbolic processing.
On the other hand, Mourrain et al. (see [8]) studied a sweeping algorithm for
computing the arrangement of a set of quadrics in R3 that reduces the intersec-
tion of two quadrics to a dynamic two-dimensional problem. Dupont et al. (see
[3–5]) proposed algorithms that enable to compute in practice an exact form
of the parameterization of the intersection curve of two quadrics with rational
coefficients. These algorithms represent a substantial improvement of Levin’s

Second author is partially supported by the Spanish Ministerio de Economia y Compet-


itividad and by the European Regional Development Fund (ERDF), under the project
MTM2017-88796-P.
c Springer Nature Switzerland AG 2019
M. Ćirić et al. (Eds.): CAI 2019, LNCS 11545, pp. 237–248, 2019.
https://doi.org/10.1007/978-3-030-21363-3_20
238 A. Trocado et al.

method and its subsequent refinements. Another approach is based on the using
of the cutcurve and resultants (see [9,11]). This method can handle all kinds of
inputs including all degenerate ones where intersection curves involve cutcurves
with singularities. Here we propose an implementation of this method, in GeoGe-
bra, adapting the algorithm developed by Trocado and Gonzalez-Vega [11] to
the special characteristics of GeoGebra.
GeoGebra is a software system for doing dynamic geometry and algebra in
the plane. Since 2001 GeoGebra has gone from a dynamic geometry software
(DGS) to a powerful computational tool in several areas of mathematics. Power-
ful algebraic capabilities have been introduced in GeoGebra, such as an efficient
spreadsheet that can deal with many kind of objects, an algebraic and symbolic
system and several graphical views that extend the possibility of multidimen-
sional representations. The recent 3D features allow more intuitive interaction
with three-dimensional objects than most existing mathematical software. How-
ever, there are still missing capabilities in GeoGebra 3D, namely the determina-
tion of the intersection curve of two quadrics.
The aim of this paper is to present a new tool that allows to compute in
GeoGebra a graphical representation of the intersection curve of two quadrics
and, when possible, its parameterization. The implemented algorithm uses resul-
tants to determine the projection of the intersection curve in the plane z = 0
(the so called cutcurve) and the lifting of its regular and singular points is made
by using only one subresultant (the index one subresultant; see [11]). The imple-
mented algorithm presented here does not need to compute any resultant or
subresultant since they are provided fully precomputed (those formulae can be
found in [11]). When the Computer Algebra capabilities of GeoGebra do not
allow to compute a parameterization of the cutcurve (may be involving radicals)
or when such a parameterization is very complicated to deal with, a discretiza-
tion of this curve is determined. The lifting is independent of how the cutcurve
is presented: we get either a discretization or a parameterization (involving in
some cases radicals) of the intersection curve.

2 Mathematical Tools
Quadrics are the simplest non linear surfaces used in many areas and computing
their intersection is a relevant problem.
Definition 1. Quadrics are algebraic surfaces defined by the equation (ai,j ∈
R):

a11 x2 +a22 y 2 +a33 z 2 +2a12 xy+2a13 xz +2a23 yz +2a14 x+2a24 y+2a34 z +a44 = 0.

In order to allow GeoGebra to compute the intersection curve of two quadrics


by using the algorithm in [11] we only need to use resultants and subresultants.
We will compute the intersection curve of two quadrics E1 and E2 presented by
their implicit equations:

f (x, y, z) = z 2 + p1 (x, y)z + p0 (x, y) g(x, y, z) = z 2 + q1 (x, y)z + q0 (x, y)


Intersecting Two Quadrics with GeoGebra 239

with deg(p1 ) ≤ 1, deg(p0 ) ≤ 2, deg(q1 ) ≤ 1 and deg(q0 ) ≤ 2. Since p1 and q1 are


two polynomials of degree one:
p1 = a1 x + a2 y + a3 q 1 = b1 x + b 2 y + b 3 .
The polynomials p0 and q0 have degree two:
p0 = a4 x2 +a5 xy +a6 y 2 +a7 x+a8 y +a9 q0 = b4 x2 +b5 xy +b6 y 2 +b7 x+b8 y +b9 .
Other cases (ie degree in z smaller than 2) can be considered too (details can be
found in [11]).
As usual (see [11]), to determine the projection of the intersection curve on
the plane z = 0, resultants will be used.
Definition 2. Let f and g be the two polynomials in R[x, y, z]
f (x, y, z) = z 2 + p1 (x, y)z + p0 (x, y) g(x, y, z) = z 2 + q1 (x, y)z + q0 (x, y)
(deg(p1 (x, y)) ≤ 1, deg(p0 (x, y)) ≤ 2, deg(q1 (x, y)) ≤ 1 and deg(q0 (x, y)) ≤
2) defining the quadrics whose intersection curve is to be computed. Then the
Sylvester resultant of f and g, with respect to z, is equal to:
 
 1 p1 (x, y) p0 (x, y) 0 
 
 0 1 p1 (x, y) p0 (x, y) 
S0 (x, y) = Resultant(f, g; z) = 
def

 1 q1 (x, y) q0 (x, y) 0 
0 1 q1 (x, y) q0 (x, y) 
 
 p0 (x, y) p1 (x, y) 
2 
= (p0 (x, y) − q0 (x, y)) − (p1 (x, y) − q1 (x, y))  .
q0 (x, y) q1 (x, y) 
The projection of the intersection curve is contained in the curve of R2 defined
implicitly by S0 (x, y) = 0.
Computing the intersection of the two quadrics defined by f and g is equiva-
lent to solve in R the system of polynomial equations f (x, y, z) = 0, g(x, y, z) = 0
which is equivalent to solve
S0 (x, y) = 0 ∧ (q1 (x, y) − p1 (x, y)) z + (q0 (x, y) − p0 (x, y)) = 0. (1)
These two equations correspond to the subresultants of index 0 and 1 of f and
g with respect to z (see [11]).
When f or g have degree 1 in z, S0 (x, y) is also the resultant of f and g with
respect to z and the subresultant of index 1 is one of the quadrics of degree 1.
The case of both equations with degree zero reduces to the intersection of two
conics and, for sake of simplicity, will not be included here.

3 Implementation of the Algorithm in GeoGebra


3.1 3D Capabilities of GeoGebra for Intersecting Two Quadrics
GeoGebra allows us to represent and determine the intersection curve of some
quadrics with a plane by using the command IntersectPath. We can also use the
command IntersectConic to determine the intersection of two quadrics when this
can be characterised as the intersection of a plane with a quadric [1]. Figure 1
provides some examples of these cases.
240 A. Trocado et al.

Quadrics

f (x, y) = x2 + xy + x + y + 1
g(x, y) = −2

GeoGebra Commands
a : x ^2 + x y + x + y + 1 = 0
b : z = -2
IntersectConic (b , a )

Quadrics

f (x, y) = x2 + y 2 + z 2 − 2
g(x, y) = x2 + (y − 1)2 + z 2 − 2

GeoGebra Commands
a : x ^2+ y ^2+ z ^2=2
b : x ^2+( y -1) ^2+ z ^2=2
IntersectConic (b , a )

Fig. 1. Some cases when GeoGebra can determine the intersection of two quadrics.

3.2 The Algorithm


Let E1 and E2 be two quadrics in R3 defined by f (x, y, z) = 0 and g(x, y, z) = 0
respectively. For computing the intersection curve of E1 and E2 in GeoGebra
we will consider three cases depending on the degree in z of f and g: both of
them with degree two, one with degree two and the other one with degree one
and both of them with degree one. The cases of one equation (or both) with
degree 0, for sake of simplicity, will not be included here but they follow the
same strategy (see [11]). For the three cases considered here, we will show how
the algorithm in [11] can be implemented in GeoGebra by adapting it to the
special characteristics of this software in order to get a more efficient behavior of
GeoGebra when computing the intersection curve of the two considered quadrics.
The method to be implemented in GeoGebra will be as follows (see [11]):
starts by computing the projection of the intersection curve of E1 and E2 (the
so-called cutcurve), continues with its analysis (paying special attention to its
singular points) and ends with its lifting.
Two Quadrics of Degree 2 in z
Let E1 and E2 be two quadrics defined by:

f (x, y, z) = z 2 + p1 (x, y)z + p0 (x, y) g(x, y, z) = z 2 + q1 (x, y)z + q0 (x, y).

The cutcurve of E1 and E2 is the set


 
(x, y) ∈ R2 : S0 (x, y) = 0, p1 (x, y)2 − 4p0 (x, y) ≥ 0, q1 (x, y)2 − 4q0 (x, y) ≥ 0 .
Intersecting Two Quadrics with GeoGebra 241

The curves defined by p1 (x, y)2 − 4p0 (x, y) = 0 and q1 (x, y)2 − 4q0 (x, y) = 0 are
called the silhouette curves of E1 and E2 , respectively.
The way of proceeding here will be the following one:

(a) Compute S0 (x, y).


(b) Compute the region
 
AE1 ,E2 = (x, y) ∈ R2 : p1 (x, y)2 − 4p0 (x, y) ≥ 0, q1 (x, y)2 − 4q0 (x, y) ≥ 0

where the cutcurve lives: requires to compute the region defined by the two
silhouette curves which are two conics.
(c) Compute the singular points of the cutcurve on the line p1 = q1 .
(d) Compute the singular points of the cutcurve outside the line p1 = q1 .
(e) Compute “enough” regular points of the cutcurve (either in closed form or
through a discretization) and their lifting.
(f) Compute the lifting of the singular points of the cutcurve.

As seen in [11], we have:


1 4 2 2

S0 (x, y) = (p1 − q1 ) + (ΔE1 − ΔE2 ) − 2 (p1 − q1 ) (ΔE1 + ΔE2 ) (2)
16
where ΔE1 = p21 − 4p0 and ΔE2 = q12 − 4q0 .

Fig. 2. Silhouette curves of two quadrics (in red and blue) and the cutcurve (in green)

The cutcurve and the region AE1 ,E2 where the cutcurve lives can be defined
in GeoGebra in closed form by using the commands1 .
* The validation region within a list *
l1 :={(( a1 x + a2 y + a3 ) ^2 -4 ( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 ) ) >=0 ,(( b1 x + b2 y
+ b3 ) ^2 -4 ( b4 x ^2+ b5 x y + b6 y ^2+ b7 x + b8 y + b9 ) ) >=0}
* Definition of the curve defined by the resultant *
S0 := Implicitcurve (1 / 16 (( a1 x + a2 y + a3 -( b1 x + b2 y + b3 ) ) ^4+(( a1 x + a2 y + a3 ) ^2 -4
( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 ) -(( b1 x + b2 y + b3 ) ^2 -4 ( b4 x ^2+ b5 x y +
b6 y ^2+ b7 x + b8 y + b9 ) ) ) ^2 -2( a1 x + a2 y + a3 -( b1 x + b2 y + b3 ) ) ^2 (( a1 x + a2 y + a3 )
^2 -4 ( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 ) +( b1 x + b2 y + b3 ) ^2 -4 ( b4 x ^2+ b5 x
y + b6 y ^2+ b7 x + b8 y + b9 ) ) ) )
* Definition of the cutcurve *
cond (x , y ) := Product ( l1 ) * CAS *
K1 := point ( S0 )
K2 := If ( cond ( x ( K1 ) ,y ( K1 ) ) >0 , K1 )
cutcurve := Locus ( K2 , K1 )

1
In the GeoGebra commands presented here, we denote x# by x#.
242 A. Trocado et al.

The lifting of the regular points of the cutcurve is determined by:

p0 (α, β) − q0 (α, β)
z= . (3)
q1 (α, β) − p1 (α, β)

All regular points of the cutcurve are outside the line p1 (x, y) = q1 (x, y). The
same formula is to be used for lifting the singular points of the cutcurve outside
the line p1 (x, y) = q1 (x, y).
Some cutcurves can not be parameterized easily in closed form even by using
radicals: since the cutcurve has degree at most four, it can be parameterized
by using radicals but this parameterization is quite complicated and does not
take into account properly the real branches (see for example [10]). This is the
reason why the lifting of the regular points of the cutcurve will be made on
the discretization of the cutcurve branches (when such a parameterization is too
involved). To do that in GeoGebra, we need to define a free point, A, on the
cutcurve and compute its lifting by using the GeoGebra commands:
* Define a free point on the cutcurve *
A = Point ( cutcurve )
* Lifting of point A *
P =( x ( A ) ,y ( A ) ,( a4 x ( A ) ^2+ a5 x ( A ) y ( A ) + a6 y ( A ) ^2+ a7 x ( A ) + a8 y ( A ) + a9 -( b4 x ( A ) ^2+
b5 x ( A ) y ( A ) + b6 y ( A ) ^2+ b7 x ( A ) + b8 y ( A ) + b9 ) ) / ( b1 x ( A ) + b2 y ( A ) + b3 -( a1 x ( A )
+ a2 y ( A ) + a3 ) ) )
* Lifting of the cutcurve *
Locus (P , A )

In practice, if the cutcurve has singular points then Locus, close to some of
these points, does not work very properly. This is the reason why the singular
points will be determined separately and the lifting of the regular points close
to them will be made in a different way.
Singular points of the cutcurve can be classified as follows: those lying on
the intersection of the cutcurve and the line p1 (x, y) = q1 (x, y) and those lying
outside the line, p1 (x, y) = q1 (x, y), always coming from tangential intersection
points of E1 and E2 . Singular points of the cutcurve on the line p1 (x, y) = q1 (x, y)
are determined by solving ΔE1 (x, y) − ΔE2 (x, y) = 0 ∧ p1 (x, y) = q1 (x, y) which
amounts to solve an univariate equation of degree 2. These singular points are
stored in the list s. Only those singular points stored in s in AE1 ,E2 will be stored
in the list s2.
s := Solutions ({ a1 x + a2 y + a3 = b1 x + b2 y + b3 , ( a1 x + a2 y + a3 ) ^2 -4 ( a4 x ^2+ a5 x y + a6
y ^2+ a7 x + a8 y + a9 ) =( b1 x + b2 y + b3 ) ^2 -4 ( b4 x ^2+ b5 x y + b6 y ^2+ b7 x + b8 y +
b9 ) } ,{x , y }) * CAS *
* Testing points of s that live in the validation region *
s2 := RemoveUndefined ( Sequence ( If ( cond ( Element (s , i , 1) , Element (s , i , 2) ) > 0 ,
{ Element (s , i , 1) , Element (s , i , 2) }) , i , 1 , Length ( s ) ) )

The lifting of the points generated by the Locus GeoGebra function works
properly on the regular points of the cutcurve and on its singular points outside
the line p1 (x, y) = q1 (x, y). Therefore we only need to deal with the lifting of
the points in the list s2 but also with those regular points of the cutcurve which
are close to the points in the list s2. For that we remove from the cutcurve the
circles with center the points in the list s2 and radius eps ∈ R+ (defined by the
user). To achieve this goal, we use the following GeoGebra command:
Intersecting Two Quadrics with GeoGebra 243

* Sequence of circles stored in a list l2 *


l2 := Sequence (( x - Element ( s2 ,i ,1) ) ^2+( y - Element ( s2 ,i ,2) ) ^2 >= eps ^2 ,i ,1 , Length ( s2
))

The points on the cutcurve to be lifted by using (3) are characterized by the
conditions defining the region AE1 ,E2 excluding the circles around the points on
the line p1 (x, y) = q1 (x, y) and on the cutcurve. In order to do this we define
the list l3 by using the conditions mentioned above, thus defining a new point,
B existing only if the conditions in l3 are verified. Making use of the point B,
we define in GeoGebra a new curve, called adaptcutcurve, by using the following
commands:
* Defining a list with both conditions *
l3 := Join ( l1 , l2 )
* Function returning zero if and only if at least one condition is not
verified *
d (x , y ) := Product ( l3 ) * CAS *
B := If ( d ( x ( A ) ,y ( A ) ) >0 , A )
* Representing the cutcurve excluding the circles around the singular points
on the line p_1 (x , y ) = q_1 (x , y ) *
adaptcutcurve := If ( Length ( s2 ) !=0 , Locus (B , A ) , cutcurve )

Let C be a point in the curve adaptcutcurve. This point runs along the whole
cutcurve except for several small circles around the singular points on the line
p1 (x, y) = q1 (x, y). The lifting of the curve adaptcutcurve is determined by the
following GeoGebra commands:
* Defining the lifting of the adapted cutcurve *
C := Point ( adaptcutcurve )
P :=( x ( C ) ,y ( C ) ,( a4 ( x ( C ) ) ^2+ a5 ( x ( C ) ) ( y ( C ) ) + a6 ( y ( C ) ) ^2+ a7 ( x ( C ) ) + a8 ( y ( C ) ) +
a9 -( b4 ( x ( C ) ) ^2+ b5 ( x ( C ) ) ( y ( C ) ) + b6 ( y ( C ) ) ^2+ b7 ( x ( C ) ) + b8 ( y ( C ) ) + b9 ) ) /( b1
( x ( C ) ) + b2 ( y ( C ) ) + b3 -( a1 ( x ( C ) ) + a2 ( y ( C ) ) + a3 ) ) )
adaptlift := Locus (P , C )

The singular points of the cutcurve on the line p1 (x, y) = q1 (x, y), stored in
s2, will be lifted by using:

−p1 (α, β) ± p1 (α, β)2 − 4p0 (α, β)
z= (4)
2
or 
−q1 (α, β) ±
q1 (α, β)2 − 4q0 (α, β)
z= (5)
2
The GeoGebra commands performing the lifting of these points are:
* Definition of functions *
lift1 :=( -( a1 x + a2 y + a3 ) + sqrt (( a1 x + a2 y + a3 ) ^2 -4 ( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8
y + a9 ) ) ) /2
lift2 :=( -( a1 x + a2 y + a3 ) - sqrt (( a1 x + a2 y + a3 ) ^2 -4 ( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8
y + a9 ) ) ) /2
* Definition of the lift *
sing1 := Sequence (( Element ( s2 ,i ,1) , Element ( s2 ,i ,2) , lift1 ( Element ( s2 ,i ,1) ,
Element ( s2 ,i ,2) ) ) ,i ,1 , Length ( s2 ) )
sing2 := Sequence (( Element ( s2 ,i ,1) , Element ( s2 ,i ,2) , lift2 ( Element ( s2 ,i ,1) ,
Element ( s2 ,i ,2) ) ) ,i ,1 , Length ( s2 ) )

As mentioned before (see [11]) singular points of the cutcurve not belonging
to the line p1 (x, y) = q1 (x, y) come from tangential intersection points of E1
and E2 . The determination of these points is quite complicated but they will
244 A. Trocado et al.

be very easy to lift: by continuity the lifting of the points produced by the
Locus GeoGebra function around these singular points produces automatically
their lifting to the intersection curve (and it is not necessary to compute them
explicitly).
Regular points of the cutcurve in the silhouette curves (see Fig. 2) can be
determined by solving (according to Eq. (2)):

2(p0 + q0 ) = p1 q1 , Δε1 = 0 and 2(p0 + q0 ) = p1 q1 , Δε2 = 0

which amounts, for each system, to intersect two conics. In order to determine
the lifting of the regular points of the cutcurve in the silhouette curves we must
use the following GeoGebra commands:
silh1 := Solutions ({2*(( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 ) +( b4 x ^2+ b5 x y + b6 y
^2+ b7 x + b8 y + b9 ) ) =( a1 x + a2 y + a3 ) *( b1 x + b2 y + b3 ) ,(( a1 x + a2 y + a3 ) ^2 -4 ( a4 x
^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 ) ) } ,{x , y }) * CAS *
silh2 := Solutions ({2*(( a4 x ^2+ a5 x y + a6 y ^2 + a7 x + a8 y + a9 ) +( b4 x ^2+ b5 x y + b6 y
^2+ b7 x + b8 y + b9 ) ) =( a1 x + a2 y + a3 ) *( b1 x + b2 y + b3 ) ,(( b1 x + b2 y + b3 ) ^2 -4 ( b4
x ^2+ b5 x y + b6 y ^2+ b7 x + b8 y + b9 ) ) } ,{x , y }) * CAS *
* Definition of the function that lifts regular points *
lift :=( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 -( b4 x ^2 + b5 x y + b6 y ^2+ b7 x + b8 y + b9 )
) /( b1 x + b2 y + b3 -( a1 x + a2 y + a3 ) )
ls1 := Sequence (( Element ( silh1 ,i ,1) , Element ( silh1 ,i ,2) , lift ( Element ( silh1 ,i
,1) , Element ( silh1 ,i ,2) ) ) ,i ,1 , Length ( silh1 ) )
ls2 := Sequence (( Element ( silh2 ,i ,1) , Element ( silh2 ,i ,2) , lift ( Element ( silh2 ,i
,1) , Element ( silh2 ,i ,2) ) ) ,i ,1 , Length ( silh2 ) )

At the neighbourhood of any singular point in p1 (x, y) = q1 (x, y) we will


compute n points for each branch to the left and to the right of the considered
singular point. Note that near the silhouette curves, GeoGebra might not repre-
sent properly the cutcurve due to precision problems: this is specially important
when the cutcurve is tangent to one of the silhouette curves. This discretization
for each branch to the left and to the right of every singular point is the way we
use to avoid the problems brought by GeoGebra into this situation.
* Defining x values near to singular points *
amp = eps / n
seq := Sequence ( Sequence ( Element ( s2 ,j ,1) - i amp , i , -n , n ) ,j ,1 , Length ( s2 ) )
* Definition of the curve inside the validation region and near to singular
points *
e := If (( b1 x + b2 y + b3 ) ^2 -4 ( b4 x ^2+ b5 x y + b6 y ^2+ b7 x + b8 y + b9 ) >=0 && ( a1 x + a2
y + a3 ) ^2 -4 ( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 ) >=0 ,1/16 (( a1 x + a2 y + a3 -(
b1 x + b2 y + b3 ) ) ^4+(( a1 x + a2 y + a3 ) ^2 -4 ( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 )
-(( b1 x + b2 y + b3 ) ^2 -4 ( b4 x ^2+ b5 x y + b6 y ^2+ b7 x + b8 y + b9 ) ) ) ^2 -2( a1 x + a2 y +
a3 -( b1 x + b2 y + b3 ) ) ^2 (( a1 x + a2 y + a3 ) ^2 -4 ( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y
+ a9 ) +( b1 x + b2 y + b3 ) ^2 -4 ( b4 x ^2+ b5 x y + b6 y ^2+ b7 x + b8 y + b9 ) ) ) )
* Compute y coordinate of every point on the cutcurve from every x value
stored in seq *
yseq := Sequence ( Sequence ( NSolve ( e ( Element ( seq ,j , i ) ,y ) ,y ) ,i ,1 ,2* n +1) ,j ,1 , Length
( s2 ) ) * CAS *

For every x value stored in seq and y value in yseq we define a list, grouping x
with y, and storing them in the list pair defined by using the following GeoGebra
commands:
pair := Sequence ( Sequence ( Sequence ( If ( Element ( yseq ,i , j ) =={} ,( Element ( seq ,i , j ) ,
maxim ) ,( Element ( seq ,i , j ) , RightSide ( Element ( Element ( yseq ,i , j ) ,k ) ) ) ) ,k ,1 , If
( Element ( yseq ,i , j ) =={} ,1 , Length ( Element ( yseq ,i , j ) ) ) ) ,j ,1 ,2* n +1) ,i ,1 ,
Length ( s2 ) ) * CAS *
Intersecting Two Quadrics with GeoGebra 245

The lifting of this set of points, the list fill below, will be constructed by using
the function lift, (3), applied to any regular point whose distance to the singular
one is between eps and eps/10. On the other hand, points whose distance to the
singular point is less than eps/10 will be lift by using the functions lift1 (4) and
lift2 (5).
* Definition of the lifting *
fill := Sequence ( Sequence ( Sequence ( If ( distance (( x ( Element ( pair , k , j , i ) ) , y (
Element ( pair , k , j , i ) ) ) ,( Element ( s2 ,k ,1) , Element ( s2 ,k ,2) ) ) < eps /10 ,( x (
Element ( pair , k , j , i ) ) , y ( Element ( pair , k , j , i ) ) , lift1 ( x ( Element ( pair ,
k , j , i ) ) , y ( Element ( pair , k , j , i ) ) ) ) , If ( eps /10 < distance (( x ( Element (
pair , k , j , i ) ) , y ( Element ( pair , k , j , i ) ) ) ,( Element ( s2 ,k ,1) , Element ( s2 ,k
,2) ) ) <eps ,( x ( Element ( pair , k , j , i ) ) , y ( Element ( pair , k , j , i ) ) , lift ( x (
Element ( pair , k , j , i ) ) , y ( Element ( pair , k , j , i ) ) ) ) ) ) , i , 1 , Length (
Element ( pair ,k , j ) ) ) , j , 1 , 2* n +1) , k , 1 , Length ( s2 ) )

Example 3. Let f and g be two ellip-


soids defined by: f (x, y, z) = z 2 +
(−2/3x + 2/3y) z + 1/3x2 + 2/3y 2 − 1/3
g (x, y, z) = z 2 + (−2/17x + 1/17y−
2/17) z + 1/4x2 + 1/17y 2 + 2/17x − 3/17.

Fig. 3. Two ellipsoids, the intersection


curve and relevant points.

In Fig. 3, green points result from the lifting of the singular points of the
cutcurve, while the red ones result from the lifting of common points between
the silhouette curves and the cutcurve.
In order to create a tool, in GeoGebra, it is necessary to use the menu Tools
and then the option Create New Tool. All eighteen parameters, that define the
two quadrics and the parameters n and eps must be selected as input. For the
output it is necessary to select the lists sing1, sing2, ls1, ls2, fill and the locus
adaptlift.
In the particular case when p1 (x, y) ≡ q1 (x, y), the cutcurve verifies:
2
S0 (x, y) = (ΔE1 − ΔE2 ) /16 = (p0 − q0 )2 .
The condition S0 (x, y) = 0 ∧ p1 (x, y) = q1 (x, y) is equivalent to p0 (x, y) =
q0 (x, y). Thus, all the points of the cutcurve are considered as singular and their
lifting (by using (4) or (5)) is defined by:
part1 := If ( a1 x + a2 y + a3 = b1 x + b2 y + b3 , Sequence (( Element (s ,i ,1) ,
Element (s ,i ,2) , lift1 ( Element (s ,i ,1) , Element (s ,i ,2) ) ) ,i ,1 , Length ( s ) ) )

part2 := If ( a1 x + a2 y + a3 = b1 x + b2 y + b3 , Sequence (( Element (s ,i ,1) ,


Element (s ,i ,2) , lift2 ( Element (s ,i ,1) , Element (s ,i ,2) ) ) ,i ,1 , Length ( s ) ) )

It should be pointed out that, in this case, GeoGebra gives a parameterization


of the intersection curve of the two considered quadrics.
Quadrics of Degree 2 and 1 in z
Let f and g be the polynomials in R[x, y, z] defined by:
f (x, y, z) = z 2 + p1 (x, y)z + p0 (x, y) g(x, y, z) = q1 (x, y)z + q0 (x, y)
246 A. Trocado et al.

In this case the cutcurve is defined by S0 (x, y) = p0 q12 − p1 q0 q1 + q02 in the region
defined by p21 − 4p0 ≥ 0. The lifting of any regular point (α, β) of the cutcurve
will be determined by z = −q0 (α, β)/q1 (α, β). Points of the cutcurve determined
by q1 (x, y) = 0 can only be lifted by using (4) and, in this case, we only have one
silhouette curve. The GeoGebra commands to use start defining the following
elements:
l1 :={( a1 x + a2 y + a3 ) ^2 -4 ( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 ) >=0}
S0 := ImplicitCurve (( b1 x + b2 y + b3 ) ^2 ( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 ) - ( a1
x + a2 y + a3 ) ( b4 x ^2+ b5 x y + b6 y ^2+ b7 x + b8 y + b9 ) ( b1 x + b2 y + b3 ) +( b4 x ^2 + b5
x y + b6 y ^2+ b7 x + b8 y + b9 ) ^2)
cond (x , y ) :=( a1 x + a2 y + a3 ) ^2 -4 ( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 )
lift :=( -( b4 x ^2+ b5 x y + b6 y ^2+ b7 x + b8 y + b9 ) ) / ( b1 x + b2 y + b3 )
P :=( x ( C ) ,y ( C ) ,( -( b4 ( x ( C ) ) ^2+ b5 ( x ( C ) ) ( y ( C ) ) + b6 ( y ( C ) ) ^2+ b7 ( x ( C ) ) + b8 ( y ( C ) )
+ b9 ) ) /( b1 ( x ( C ) ) + b2 ( y ( C ) ) + b3 ) )
s := Solutions ({( b4 x ^2 + b5 x y + b6 y ^2 + b7 x + b8 y + b9 ) =0 ,( b1 x + b2 y +
b3 ) =0} ,{ x , y })
silh1 := Solutions ({( b1 x + b2 y + b3 ) ^2 ( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 ) - ( a1
x + a2 y + a3 ) ( b4 x ^2+ b5 x y + b6 y ^2+ b7 x + b8 y + b9 ) ( b1 x + b2 y + b3 ) +( b4 x
^2+ b5 x y + b6 y ^2+ b7 x + b8 y + b9 ) ^2=0 ,( a1 x + a2 y + a3 ) ^2 - 4 ( a4 x ^2+ a5 x y +
a6 y ^2+ a7 x + a8 y + a9 ) =0} ,{ x , y })
e := If (( a1 x + a2 y + a3 ) ^2 -4 ( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 ) >=0 ,( b1 x + b2 y +
b3 ) ^2 ( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 ) -( a1 x + a2 y + a3 ) ( b4 x ^2+ b5 x y +
b6 y ^2+ b7 x + b8 y + b9 ) ( b1 x + b2 y + b3 ) +( b4 x ^2+ b5 x y + b6 y ^2+ b7 x + b8 y + b9 )
^2)

The computation of the intersection curve in this case follows the same GeoGebra
strategy shown previously.

Example 4. Let f be the hyperboloid of


one sheet and g the hyperbolic paraboloid
defined by:
f (x, y, z) = z 2 + 3z − x2 + y 2 − 3
g (x, y, z) = (x + y)z − 2x
The intersection curve can be represented
by GeoGebra: see Fig. 4.

Fig. 4. Hyperboloid of one sheet


and hyperbolic paraboloid intersection
curve and relevant points in GeoGebra

Two Quadrics of Degree 1 in z


Let f and g be the polynomials in R[x, y, z] defined by:

f (x, y, z) = p1 (x, y)z + p0 (x, y) g(x, y, z) = q1 (x, y)z + q0 (x, y)

The cutcurve is defined by S0 (x, y) = p1 q0 − p0 q1 . Note that, in this case, S0 is


a polynomial of degree three, at most. As before, in some cases GeoGebra gives
us the exact parameterization of the cutcurve. However, in general, the way to
proceed will be similar to the previous cases. As seen in [11], when p1 (α, β) = 0
or q1 (α, β) = 0, the lifting of (α, β) is given by:

p0 (α, β) q0 (α, β)
z=− or z=− ,
p1 (α, β) q1 (α, β)
Intersecting Two Quadrics with GeoGebra 247

respectively. If p1 (α, β) = p0 (α, β) = 0 then p0 (α, β) = q0 (α, β) = 0 and the line


{(α, β, z) : z ∈ R} is in the intersection curve.
In this case we use in GeoGebra the following commands:
e (x , y ) :=( a1 x + a2 y + a3 ) *( b4 x ^2+ b5 x y + b6 y ^2+ b7 x + b8 y + b9 ) -( a4 x ^2+ a5 x y + a6
y ^2+ a7 x + a8 y + a9 ) *( b1 x + b2 y + b3 )
cutcurve := ImplicitCurve ( e (x , y ) )

* Determine points that p1 =0 && p0 =0 *


s2 := Solutions ({ a1 x + a2 y + a3 =0 ,( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 ) =0} ,{ x , y })
* CAS *
* Lifting points that p1 !=0*
lift := -( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 ) /( a1 x + a2 y + a3 )

* Define the region near to points that p1 =0 && p0 =0*


l3 := Sequence (( x - Element ( s2 , i , 1) ) ^2+( y - Element ( s2 , i , 2) ) ^2 >= eps ^2 ,i ,1 ,
Length ( s2 ) )

* Define adaptcutcurve - curve without region near to points that p1 =0 & p0 =0*
A = Point ( cutcurve )
d (x , y ) := Product ( l3 ) * CAS *
B := If ( d ( x ( A ) ,y ( A ) ) >0 , A )
K1 := Point ( cutcurve )
K2 := K1
adaptcutcurve := If ( Length ( s2 ) != 0 , Locus (B , A ) , Locus ( K2 , K1 ) )
C := Point ( adaptcutcurve )
P :=( x ( C ) ,y ( C ) , -( a4 ( x ( C ) ) ^2+ a5 ( x ( C ) ) ( y ( C ) ) + a6 ( y ( C ) ) ^2+ a7 ( x ( C ) ) + a8 ( y ( C ) ) +
a9 ) /( a1 ( x ( C ) ) + a2 ( y ( C ) ) + a3 ) )

* Lifting of points that p1 =0 && p0 =0 *


lift1 := -(( b4 x ^2 + b5 x y + b6 y ^2 + b7 x + b8 y + b9 ) /( b1 x + b2 y + b3 ) )
sing1 := Sequence (( Element ( s2 ,i ,1) , Element ( s2 ,i ,2) , lift1 ( Element ( s2 ,i ,1) ,
Element ( s2 ,i ,2) ) ) ,i ,1 , Length ( s2 ) )

* Determine points that p1 =0 && p0 =0 && q1 =0 && q0 =0 *


s3 := Solutions ({ a1 x + a2 y + a3 = 0 ,( a4 x ^2+ a5 x y + a6 y ^2+ a7 x + a8 y + a9 ) =0 ,( b1
x + b2 y + b3 ) =0 , b4 x ^2+ b5 x y + b6 y ^2+ b7 x + b8 y + b9 =0} ,{ x , y })

* Define vertical lines *


line := Sequence ( Line (( Element ( s3 ,i ,1) , Element ( s3 ,i ,2) ) , zAxis ) ,i ,1 , Length ( s3 ) )

Example 5. Let f be the hyperbolic


paraboloid and g the hyperboloid of one
sheet defined by:
f (x, y, z) = xz + x2 + 2y − 1
g(x, y, z) = yz + x2 + y 2 − 2x
The parameterization of the intersection
curve can be computed by GeoGebra by
using the presented approach (Fig. 5).

Fig. 5. Intersection between the hyper-


boloid of one sheet and the hyperbolic
paraboloid.

4 Conclusion
For computing in GeoGebra the intersection curve of two quadrics, we have
adapted to GeoGebra the algorithm in [11]. Applying this implementation to fifty
248 A. Trocado et al.

examples randomly generated, it produced the intersection curve in a few seconds


for each case. Despite some limitations of the Locus function in GeoGebra the
implementation worked efficiently in all cases. Sometimes the performance of the
software was a little slow namely when there were many singular points. Another
topic to be considered deals with the values of the parameters n and eps which
need to be carefully chosen by the user. In conclusion, our goal was attained,
producing an implementation in GeoGebra of the algorithm in [11].

References
1. Dos Santos, J.M.: Intersection of two surfaces in GeoGebra. Revista do Instituto
GeoGebra de São Paulo 6(2), 04–09 (2017)
2. Dupont, L., Lazard, S., Lazard, D., Petitjean, S.: Near-optimal parameterization
of the intersection of quadrics. In: Proceedings of the Annual Symposium on Com-
putational Geometry (2003). https://doi.org/10.1145/777829.777830
3. Dupont, L., Lazard, D., Lazard, S., Petitjean, S.: Near-optimal parameterization
of the intersection of quadrics: II. A classification of pencils. J. Symbolic Comput.
(2008). https://doi.org/10.1016/j.jsc.2007.10.012
4. Dupont, L., Lazard, D., Lazard, S., Petitjean, S.: Near-optimal parameterization of
the intersection of quadrics: III. Parameterizing singular intersections. J. Symbolic
Comput. (2008). https://doi.org/10.1016/j.jsc.2007.10.007
5. Dupont, L., Lazard, D., Lazard, S., Petitjean, S.: Near-optimal parameterization of
the intersection of quadrics: I. The generic algorithm. J. Symbolic Comput. (2008).
https://doi.org/10.1016/j.jsc.2007.10.006
6. Levin, J.: A parametric algorithm for drawing pictures of solid objects composed
of quadric surfaces. Commun. ACM 10, 555–563 (1976). https://doi.org/10.1145/
360349.360355
7. Levin, J.Z.: Mathematical models for determining the intersections of quadric sur-
faces. Comput. Graph. Image Process. 11(1), 73–87 (1979)
8. Mourrain, B., Tecourt, J.P., Teillaud, M.: On the computation of an arrangement
of quadrics in 3D. Comput. Geom. Theory Appl. (2005). https://doi.org/10.1016/
j.comgeo.2004.05.003
9. Schomer, E., Wolpert, N.: An exact and efficient approach for computing a cell
in an arrangement of quadrics. Comput. Geom. Theory Appl. (2006). https://doi.
org/10.1016/j.comgeo.2004.02.007
10. Sendra, J.R., Sevilla, D.: Radical parametrizations of algebraic curves by adjoint
curves. J. Symbolic Comput. 46(9), 1030–1038 (2011)
11. Trocado, A., Gonzalez-Vega, L.: On the intersection of two quadrics (2018, Sub-
mitted). http://arxiv.org/abs/1903.06983
12. Wang, W., Goldman, R., Tu, C.: Enhancing Levin’s method for computing quadric-
surface intersections. Comput. Aided Geom. Des. (2003). https://doi.org/10.1016/
S0167-8396(03)00081-5

You might also like