• Non ci sono risultati.

Grafica Computazionale

N/A
N/A
Protected

Academic year: 2022

Condividi "Grafica Computazionale"

Copied!
166
0
0

Testo completo

(1)

Grafica Computazionale

Prof. Biancamaria Della Vecchia Laurea in Tecnologie Informatiche

Si ringrazia il Professor C.K. Shene del Dipartimento di Informatica dell'Università Tecnologica del Michigan per le note "Introduction to Computing with Geometry" dalle quali è ricavato il presente materiale didattico

Unità 1: Introduzione

Unità 2: Concetti di Geometria

Coordinate Systems, Points, Lines and Planes Simple Curves and Surfaces

Homogeneous Coordinates Geometric Transformations Problems

References Unità 3: Curve di Bézier

Introduzione Costruzione

Spostare i punti di controllo Algoritmo di De Casteljau Derivate di una curva di Bézier Suddivisione di una curva di Bézier

Elevazione del grado di una curva di Bézier Bibliografia

Unit 6: Curve B-spline Motivazioni

Funzioni di base delle B-spline Definizione

Proprietà importanti Esempi di calcolo B-spline Curves

Definition

Open Curves Closed Curves Important Properties Computing the Coefficients

A Special Case Moving Control Points Modifying Knots

Derivatives of a B-spline Curve Computer Graphics

Grafica Computazionale 1

(2)

Important Algorithms for B-spline Curves Knot Insertion

Single Insertion

Inserting a Knot Multiple Times De Boor's Algorithm

De Casteljau's and de Boor's Algorithms Subdividing a B-spline Curve

Problems References Unit 7: NURBS Curves

Motivazioni Definition

Important Properties Modifying Weights

Important Algorithms for B-spline and NURBS Curves Knot Insertion: Single Insertion

De Boor's Algorithm Problems

References Unit 8: Surfaces

Basic Concepts

Bézier Surfaces Construction

Important Properties De Casteljau's Algorithm B-spline Surfaces

Construction

Important Properties De Boor's Algorithm

Unit 9: Parameter selection and knot vector generation Overview

The Uniformly Spaced Method The Chord Length Method The Centripetal Method Knot Vector Generation

Computer Graphics

Si ringrazia il Professor C.K. Shene del Dipartimento di Informaticadell'Università Tecnologica del Michigan per le note "Introduction toComputing with Geometry" dalle quali è ricavato il presente materialedidattico 2

(3)

Introduzione

La Computer Graphics costituisce una delle più diffuse applicazioni dell informatica. È una disciplina che basandosi su metodi ed algoritmi di Analisi Numerica, insieme con particolari tecnologie e strumenti hardware, consente di visualizzare oggetti mediante il calcolatore. Senza dubbio si può affermare che non esiste applicazione in cui la grafica non possa essere di valido aiuto o quanto meno di complemento. È per questo che la grafica trova ampie applicazioni anche in settori non tecnici,ad esempio nelle indagini demografiche, nell analisi statistica e nelle applicazioni economiche in genere. A seconda del tipo di applicazione la computer graphics può dividersi in tre categorie principali:

- grafica per applicazioni economiche (business graphics);

- animazione;

- progettazione.

In questi ultimi anni le applicazioni della computer graphics nei più svariati settori economici hanno

determinato la nascita di un vero e proprio settore, la Business graphics. L obiettivo di tale disciplina è quello di presentare determinati risultati con l ausilio di grafici,rendendone così più immediata la comprensione. Dal punto di vista della programmazione queste applicazioni sono le più semplici poiché non richiedono né algoritmi particolarmente complicati né sofisticate risorse hardware per la loro realizzazione. Un altro interessante settore della Computer Graphics è quello dell animazione. Sfruttando l elevata velocità dei calcolatori attualmente disponibili sul mercato è possibile codificare programmi in grado di animare disegni con una risoluzione così spinta da dare la sensazione del movimento continuo. I campi applicativi sono i più svariati: dalla preparazione dei videogiochi o di pellicole cinematografiche all analisi cinematica di un fenomeno; ad esempio esistono programmi che, simulando gli spostamenti del corpo di un guidatore in caso d incidente automobilistico, consentono di decidere quale debba essere la disposizione migliore all interno della vettura. Senza dubbio uno dei primi campi applicativi della computer graphics è stato quello della progettazione. A seconda dei settori di applicazione essa si divide in quattro categorie:

- progettazione elettronica;

- progettazione architettonica;

- progettazione industriale;

- progettazione meccanica.

Per quanto riguarda il settore elettronico,le principali applicazioni vanno dalla progettazione dei circuiti integrati a quella di intere schede, con produzione automatica dei disegni esecutivi e della lista dei componenti necessari alla produzione. I vantaggi vanno oltre il semplice risparmio di tempo associato all esecuzione della parte grafica. Man mano che procede il progetto l uso del computer consente di controllare le scelte del progettista in termini di compatibilità e di interfacciabilità tra i componenti usati e perfino di operare una selezione tra i diversi componenti similari sulla base delle caratteristiche richieste. Anche nella progettazione architettonica la computer graphics si è rivelata estremamente utile. Le principali applicazioni riguardano l abitabilità degli ambienti, l arredamento, l analisi strutturale e, nei programmi più complessi, il disegno di viste prospettiche. Quest ultima applicazione è ancora in fase di sviluppo, richiedendo software e hardware molto avanzati; le principali difficoltà risiedono negli algoritmi di cancellazione delle linee non in vista.

Infatti la costruzione di una vista prospettica o di un assonometria richiedono lo sviluppo di una complessa Continuity Issues

Introduzione 1

(4)

logica per determinare se una data linea è in vista o se viene nascosta da altri elementi di figura. Le possibilità grafiche del computer sono oggi ampiamente utilizzate anche in quell importante settore tecnico-artistico che va sotto il nome di progettazione industriale (industrial design). Il campo applicativo dell industrial design è vastissimo e copre tutti i settori nei quali al progetto tecnico esecutivo di un determinato prodotto è necessario associare uno studio estetico approfondito del risultato che si desidera ottenere. Il computer offre

l opportunità di semplificare enormemente il lavoro di sintesi di un idea artistica,che può riguardare la forma di una suppellettile come il disegno da riprodurre su un tessuto. Così anche gli stilisti ed i creatori di moda sono attualmente utenti di packages orientati alla soluzione rapida di problemi grafici associati a questo tipo di attività altamente creative.

Infine, la progettazione meccanica è l aspetto più noto della progettazione assistita dal

calcolatore.Essa è spesso identificata con il C.A.D. stesso, cioè la progettazione automatica nel suo complesso ed è, in realtà, il capostipite di tutte le altre applicazioni. Già agli inizi degli anni sessanta, la tecnologia dell hardware in campo industriale era ad un livello tale da permettere di riprodurre con assoluta precisione forme tridimensionali di ogni tipo per mezzo di macchine utensili. Il passo successivo da compiere era quello di rendere automatico il controllo di queste macchine utensili (in inglese Computer Aided Manifacturing o più brevemente C.A.M) nonché la progettazione delle forme stesse da realizzare (in inglese Computer Aided Design o C.A.D). Mentre, come si è detto, l hardware non costituiva un problema, il software in grado di realizzare ciò era assolutamente inesistente. I modelli ed i prototipi venivano prodotti a mano da personale altamente specializzato, con l ausilio di strumenti empirici. Ad esempio, fissati alcuni punti di riferimento,si costruiva un modello fisico mediante strumenti quali le spline , cioè un sottile righello in legno molto flessibile; si ricavava poi da tale modello un disegno, ad esempio facendo uso di fogli di alluminio. Le curve così generate venivano riprodotte mediante materiale rigido al fine di creare un modello guida definitivo. Tale modello guida veniva poi utilizzato per la produzione mediante macchine munite di pantografo. Naturalmente procedimenti di questo tipo risultavano lunghi e laboriosi (con conseguente aggravio dei costi sia di

progettazione che di produzione), senza contare poi il fatto che le forme così definite erano poco accurate ed il modello-guida facilmente danneggiabile. La possibilità di utilizzare il calcolatore per ottenere

contemporaneamente precisione numerica e rapidità di calcolo avrebbe comportato l abbreviazione dei tempi di produzione, una maggiore precisione, migliore trasmissione dei dati ed ,in definitiva, costi più contenuti.

Questa è l ovvia motivazione di sistemi chiamati appunto CAD/CAM. Al giorno d oggi anche in Italia la parola CAD è ormai entrata a far parte del patrimonio culturale di chi lavora nei più disperati settori

industriali, nonché di professionisti come ingegneri, architetti, grafici pubblicitari. La diffusa conoscenza di questa applicazione dell informatica testimonia una altrettanto notevole diffusione in Italia di sistemi di progettazione computerizzati. L evoluzione del software e le crescenti potenzialità delle piattaforme hardware impiegate hanno reso l elaborazione grafica tramite il calcolatore molto più di una semplice

alternativa al tavolo da disegno tradizionale. Il CAD permette infatti l agevolazione oltre che dell operazione di disegno vera e propria anche di tutto il processo progettuale grazie alla rapidità di esecuzione, di modifica, di archiviazione dei disegni ed alla presenza di pre e post-pocessori per la preparazione e la successiva elaborazione dei dati relativi. Un sistema CAD può essere visto come uno strumento di progettazione assistita . Infatti,oltre all esecuzione del disegno vero e proprio esso consente di gestire ed integrare la distinta base (l elenco dei componenti il singolo progetto) e l archiviazione tecnico (possibilità di richiamare e di riutilizzare progetti precedenti),dunque di ottenere una maggiore efficienza della fase di progettazione oltre alla integrazione di questa con la fase di produzione.

Si analizzano ora quali sono le caratteristiche che si richiedono ad un sistema CAD.

Un tale sistema deve fornire la possibilità di progettare o lavorare su oggetti che appartengono in genere ad una di queste tre categorie:

a. oggetti che fanno parte di un meccanismo complesso nel quale giocano un ruolo importante e la cui efficacia dipende strettamente dalla loro forma (ad esempio la lama di una turbina o la carrozzeria di una

Continuity Issues

Introduzione 2

(5)

macchina da corsa). Di solito la loro forma è stata determinata con sperimentazioni successive e va riprodotta con la migliore precisione possibile.

b. oggetti che hanno solo una funzione estetica: il modello è di solito fatto a mano da una persona dotata e va riprodotto correttamente anche se non è necessaria una precisione rigorosa. Importanti sono in questi casi la continuità della forma e la curvatura: nella riproduzione si rischia di perdere quella caratteristica generale di armonia che l artista ha dato al prototipo.

c. oggetti che non hanno né pretese estetiche né di grande precisione ma che vanno assemblati tra di loro, ad esempio incollati: è necessaria grande precisione solo nelle zone di contatto.

In tutti questi casi la caratteristica fondamentale del sistema CAD è la capacità di esprimere

come insiemi di numeri la forma di un oggetto e di operare su di essa utilizzando il calcolatore, sia che si tratti dell ala di un aereo sia che si tratti di una semplice bottiglia. Inoltre a questa rappresentazione numerica della forma si richiede che:

a. sia applicabile ad una gran varietà di forme geometriche (linee, cerchi, coniche ed eventualmente anche curve di grado superiore);

b. permetta di operare su queste forme per mezzo di calcoli semplici;

c. sia indipendente dal sistema di coordinate;

d. sia facilmente utilizzabile anche da non matematici.

Un tipo di rappresentazione di curve e superfici che risponde a queste esigenze è quella parametrica. Dal punto di vista matematico,tale rappresentazione offre rispetto alla forma analitica molti vantaggi di cui alcuni sono i seguenti:

a. è una rappresentazione di tipo esplicito;

b. permette di usare la forma vettoriale che ha il pregio di essere concisa e consente di esprimere la curva come combinazione lineare a coefficienti vettoriali di funzioni scalari;

c. è indipendente dal sistema di riferimento;

d. permette di calcolare separatamente le componenti e di usare la stessa routine per il calcolo di ciascuna componente riducendo così la complessità dei programmi;

e. permette di esprimere coefficienti angolari infiniti il che è una caratteristica desiderabile dal momento che spesso i profili degli oggetti hanno tangenti verticali.

La teoria delle curve e superfici parametriche era già ben nota negli anni sessanta e costituiva una parte ben assestata della geometria. Curve e superfici parametriche, peraltro, non erano state studiate da un punto di vista computazionale, pertanto ben poco era noto sulla loro potenzialità di utilizzo di un sistema CAM/CAD.

Tant è che lo studio di tale ampia problematica ha costituito, praticamente da solo, il nucleo di base di una nuova disciplina a sé stante, il C.A.G.D. cioè Computer Aided Geometric Design, che venne ufficialmente riconosciuta come tale in occasione del congresso organizzato da R.E. Riesenfield presso l università dello

Continuity Issues

Introduzione 3

(6)

Utah nel 1974. Fu proprio Barnhill a coniare in quella occasione il nome di Computer Aided Geometric Design in cui, come egli stesso puntualizza, l aggiunta dell aggettivo geometric sta ad evidenziare il fatto che l attenzione è limitata agli aspetti matematici del CAD. In pratica i geometri computazionali studiano gli aspetti algoritmici e la misura della complessità di problemi geometrici che coinvolgono semplici oggetti geometrici come punti, linee, segmenti di linee, poligoni, cerchi e archi di circonferenza, sfere e poliedri.

Alcuni problemi classici sono: calcolare il dominio convesso di un insieme di punti; determinare i punti di intersezione di un insieme di segmenti; triangolare un poligono semplice. Mentre lo scopo è teorico ed algoritmico, il campo della geometria computazionale riguarda oggetti geometrici.

In questo corso introdurremo diverse rappresentazioni per le curve e superfici e le relative operazioni geometriche. Ci soffermeremo a lungo sul disegno di curve usando delle approssimazioni (curve di Bezier), curve B-spline, curve NURBS. Questi risultati saranno estesi alle superfici. Evidenzieremo gli aspetti computazionali inerenti i problemi geometrici.

Continuity Issues

Introduzione 4

(7)

Coordinate Systems, Points, Lines and Planes

Two-Dimensional Objects

Points

The xy-coordinate plane has two coordinate axes, the x- and y-axis. They are perpendicular to each other.

Non-perpendicular axes can be used; but, the computation cost is higher.

A point in the xy-plane is represented by two numbers, (x, y), where x and y are the coordinates of the x- and y-axes.

Lines

A line in the xy-plane has an equation as follows:

Ax + By + C = 0

It consists of three coefficients A, B and C. C is referred to as the constant term. If B is non-zero, the line equation can be rewritten as follows:

y = m x + b

where m = -A/B and b = -C/B. This is the well-known slope-intercept form in which m and b are the slope and the intercept (i.e., the intersection point of the line and the y-axis). If B is zero, the line equation becomes Ax + C = 0, which is a line parallel to the y-axis and intersects the x-axis at point (0,-C/A).

The line equation has three coefficients; but, there are only two independent ones. That is, given a line equation, dividing the equation by one of its non-zero coefficients will not change the line. For example, the line equation 4x+5y+7=0 is equivalent to x+1.25y+1.75=0 and 0.8x+y+1.4=0. Dividing an equation by a non-zero constant is usually referred to as normalization. There is one normalization that is very important to us. It is used to compute the distance between the origin to a line.

Suppose the line equation is Ax+By+C=0, the distance between the origin and the line is given as follows:

Thus, after normalizing the line equation by dividing it with the square root of the sum of the squares of A and B, the absolute value of the new constant term is the distance between the origin and the given line.

Parallel and Perpendicular Lines

Given two lines as follows:

Coordinate Systems, Points, Lines and Planes

Coordinate Systems, Points, Lines and Planes 1

(8)

Ax + By + C = 0 Ex + Fy + G = 0

they are parallel to each other if their slopes are equal. Since the slopes are -A/B and -E/F (if B and F are both non-zero), two lines are parallel to each other if and only if the following holds

AF=BE

Note that we can assume that B or F are both non-zero. Otherwise, if both are zero, the lines are parallel to the y-axis and hence are parallel to each other.

Two lines are perpendicular if and only if the product of their slopes is -1. With the line equations above, two lines are perpendicular to each other if and only if the following holds:

AE=-BF

Three-Dimensional Objects

Points

The coordinate system in space needs three coordinate axes, the x-, y- and z-axis. Therefore, a point in space has three components (x,y,z), where x, y and z are the coordinates of the x-, y- and z-axis.

Planes

A plane in space has an equation as follows:

Ax + By + Cz + D = 0

It consists of four coefficients A, B, C and D, where D is the constant term. Similar to the line case, the distance between the origin and the plane is given as

The normal vector of a plane is its gradient. The gradient of an equation f(x,y,z)=0 is defined as follows:

For a plane, its normal vector is simply <A, B, C>.

Unfortunately, a line in space cannot be represented with a single equation. However, it can be considered as the intersection of two planes. To ease our discussion, we shall switch to using vectors, although this

Coordinate Systems, Points, Lines and Planes

Parallel and Perpendicular Lines 2

(9)

traditional notation is still very useful.

Vectors

Vectors have a very important advantage in geometric computing, because it is "coordinate free." The meaning of "coordinate free" will be clear in later discussions. All vectors will be in boldface like a and A.

A vector is similar to a point. If it is a vector in the plane (resp., space), it has two (resp., three) components.

Thus, a vector in a n-dimensional space has n components. For our applications, we shall distinguish two types of vectors: position vectors and direction vectors. A position vector gives the position of a point. More precisely, a point is a vector. A direction vector gives a direction. Hence, it is not a point. In what follows, position vectors and direction vector are written with boldface upper case and lower case, respectively. For example, A and a are position and direction vectors, respectively. In many cases, such distinction is unnecessary.

As you have learned in linear algebra or in calculus, you can add and subtract vectors; but you can only multiply or divide a vector with constants.

The length of a vector is the square root of the sum of squares of all components. A unit-length vector is a vector whose length is one. A vector can be normalized by dividing its components with its length, converting the given vector to a unit-length one while keeping its direction the same. For example, if a=, then the length of a, usually written as |a|, is SQRT(50) and the normalized a is

Coordinate Systems, Points, Lines and Planes

Planes 3

(10)

Simple Curves and Surfaces

We have seen the simplest curves (lines) and surfaces (planes) in the previous page. Next to lines and planes, there are conics and quadric surfaces. Although conics and quadric surfaces have been around for about 2000 years, they are still the most popular objects in many computer aided design and modeling systems. We shall discuss conics, quadric surfaces and tori on this page only. Consulting your calculus and/or geometry books should be very helpful. Your linear algebra book should also cover some of these topics with a modern approach.

The following figures show to you three different ways of cutting a cone with a plane. The conic sections, from left to right, are an ellipse, a hyperbola and a parabola.

Curves

Circles

The simplest non-linear curve is unquestionably the circle. A circle with center (a,b) and radius r has an equation as follows:

(x - a)2 + (x - b)2 = r2

If the center is the origin, the above equation is simplified to x2 + y2 = r2

The above equations are referred to as the implicit form of the circle. The parametric form of a circle is x = rcos(t)

y = rsin(t)

The following is the parametric form of a circle whose center is not the origin:

x = a + rcos(t) y = b + rsin(t)

The above parametric form uses trigonometric functions. We shall discuss a parametric form of a circle without trigonometric functions later.

Simple Curves and Surfaces

Simple Curves and Surfaces 1

(11)

Conics in Normal Forms

A direct generalization of the circle is the so-called conic curves or simply conics. Greeks knew about conics very well. In fact, Apollonius of Perga (262 - 200 B.C.) wrote a book of several volumes about conics. Conics are the intersection curves of a plane and a circular cone (i.e., a cone whose base is a circle and whose axis is perpendicular to the base and through the center of the base circle).

There are three types of non-degenerate conics: ellipses, hyperbolas and parabolas. Ellipses and hyperbolas are called central conics because they have a center of symmetry, while parabolas are non-central.

The normal form of an ellipse is the following implicit equation:

The axes of this ellipse are the x- and y-axis, a and b are the axis lengths, and the larger one of a and b is the major axis while the smaller one is the minor axis. It is not difficult to see that an ellipse in this form has the following parametric form:

x = acos(t) y = bsin(t)

The normal form of a hyperbola is the following implicit equation:

The definition of major axis and minor axis are identical to that of ellipses. The x-axis intersects the curve at two points (a, 0) and (-a, 0) and, the y-axis does not intersect the curve at all. A possible parametric form of the above hyperbola is the following:

x = asec(t) y = btan(t)

The center of an ellipse and hyperbola, in normal form, is the coordinate origin and the curve is symmetric about its center and its axes.

The normal form of a parabola is the following implicit equation:

In this normal form, for any point (x,y) on a parabola, the value of y must be positive and the opening of this parabola is upward. The axis of this parabola is the y-axis. It is intersecting to note that the normal form of a parabola is already a parametric form. Or, if you like, you can rewrite it into the following:

Simple Curves and Surfaces

Conics in Normal Forms 2

(12)

x = t y = t2 / (4p)

Conics in General Form

Conics are degree two curves because their most general form is the following degree two implicit polynomial:

In the above polynomial, the coefficients of xy, x and y are 2B, 2D and 2E, respectively. This polynomial has six coefficients; however, dividing it with a non-zero coefficient would reduce six to five. Thus, in general, five conditions can uniquely determine a conic. In linear algebra, you perhaps have learned the way of reducing the above polynomial to a normal form using eigenvalues and eigenvectors.

Frequently, we only want to know the curve type of a general second degree polynomial. In this case, as long as the second degree equation represents a conic rather than two intersecting or parallel lines, it can easily be done as follows:

If B2 < A*C, the general equation represents an ellipse.

1.

IF B2 = A*C, the general equation represents a parabola.

2.

If B2 > A*C, the general equation represents a hyperbola.

3.

Expression B2-A*C is called the discriminant of the general second degree polynomial. Based on the above, if the value of the discriminant is less than, equal to or greater than zero, the conic is an ellipse, a parabola, or a hyperbola.

Conics in Matrix Form

One nice thing of conics is that its general form can be rewritten compactly using matrices. First, each point x

= (x, y) is considered as a column vector whose third component is 1 and hence the transpose is a row vector, written as xT = [ x, y, 1 ]. Next, the six coefficients of the general second degree polynomial are used to construct a three-by-three symmetric matrix as follows:

It is not difficult to verify that the general second degree polynomial becomes

Now what you have learned from linear algebra can be applied to this matrix form.

Simple Curves and Surfaces

Conics in General Form 3

(13)

Surfaces

Quadric Surfaces in Normal Forms

Quadric surfaces, or quadrics for short, consist of the following different types: ellipsoids, hyperboloids of one sheet, hyperboloids of two sheets, elliptic paraboloids, and hyperboloid paraboloids. The following are their normal forms in implicit forms and their shapes:

Ellipsoid

Hyperboloid of One Sheet

Hyperboloid of Two Sheets

Elliptic Paraboloid

Hyperbolic Paraboloid

Simple Curves and Surfaces

Surfaces 4

(14)

These five quadric surfaces are normally referred to as rank four quadrics. There are two types of rank three quadrics: cones and cylinders. Cylinders have three subtypes: elliptic cylinders, hyperbolic cylinders and parabolic cylinders as shown below:

Cone

Elliptic Cylinder

Hyperbolic Cylinder

Parabolic Cylinder

Simple Curves and Surfaces

Quadric Surfaces in Normal Forms 5

(15)

Quadric Surfaces in General Form

The general form of quadric surfaces is the following:

It has ten coefficients; but, as mentioned in the discussion of conics, dividing the equation with one of its non-zero coefficients reduces the number of coefficients to nine. Please also note that except for the coefficients for x2, y2 and z2 and the constant term, all coefficients has a multiplier of 2.

You might want to ask a question: is it possible to develop an algorithm for classifying the quadrics just like we did for conics? More precisely, if a general second degree polynomial is given, could we tell its type (i.e., ellipsoid, hyperboloid of one sheet, elliptic paraboloid, etc) by simply looking at their coefficients? The answer is always a "yes"; but the computation algorithm is quite complex. So, I would rather skip this algorithm. However, you can always use eigenvalues and eigenvectors to solve this problem.

Quadric Surfaces in Matrix Form

The equation of a general quadric can also be put into matrix form:

where (x, y, z) is the coordinates of a point. This form translates the general second polynomial of a quadric to the following matrix form:

Note that it is exactly identical to that of a conic. Therefore, matrices help to bring conics and quadrics into an identical form.

After knowing the matrix form of quadrics, we will be able to discuss the meaning of rank four and rank three quadrics. Consider the symmetric matrix Q that contains the coefficients of a general second degree

polynomial. The rank of a matrix is the number of non-zero eigenvalues. Thus, rank four quadrics are those quadrics whose matrix Q are of rank four. It is easy to see (from their normal forms) that ellipsoids,

hyperboloids and paraboloids are rank four quadrics, and cones and cylinders are rank three quadrics. If a general second degree polynomial factors into the product of two distinct degree one polynomials (i.e., planes), Q will have rank two.

Simple Curves and Surfaces

Quadric Surfaces in General Form 6

(16)

Tori in Normal Form

A torus can be generated by rotating a circle, the minor circle, about a line, the rotation axis or axis of

rotation. The moving circle has its center on another circle, the major circle. The radii of the major and minor circles are referred to as the major radius and minor radius, denoted by R and r, respectively.

If the rotation axis is the z-axis and the major circle lies on the xy-plane, the equation of the generated torus is the following:

If R is greater than r, the result is a commonly seen torus as shown in the middle of the following figure.

IF R is equal to r, then all moving circles are tangent to the rotation axis at the coordinate origin as shown in the right figure. If R is less than r, all moving circles intersect the rotation axis at two distinct points and the generated torus will have a olive like shape in the interior of the torus as shown in the left figure.

Simple Curves and Surfaces

Tori in Normal Form 7

(17)

Homogeneous Coordinates

One of the many purposes of using homogeneous coordinates is to capture the concept of infinity. In the Euclidean coordinate system, infinity is something that does not exist. Mathematicians have discovered that many geometric concepts and computations can be greatly simplified if the concept of infinity is used. This will become very clear when we move to curves and surfaces design. Without the use of homogeneous coordinates system, it would be difficult to design certain classes of very useful curves and surfaces in computer graphics and computer-aided design.

Let us consider two real numbers, a and w, and compute the value of a/w. Let us hold the value of a fixed and vary the value of w. As w getting smaller, the value of a/w is getting larger. If w approaches zero, a/w

approaches to infinity! Thus, to capture the concept of infinity, we use two numbers a and w to represent a value v, v=a/w. If w is not zero, the value is exactly a/w. Otherwise, we identify the infinite value with (a,0).

Therefore, the concept of infinity can be represented with a number pair like (a, w) or as a quotient a/w.

Let us apply this to the xy-coordinate plane. If we replace x and y with x/w and y/w, a function f(x,y)=0 becomes f(x/w,y/w)=0. If function f(x,y) = 0 is a polynomial, multiplying it with wn will clear all denominators, where n is the degree of the polynomial.

For example, suppose we have a line Ax + By + C = 0. Replacing x and y with x/w and y/w yields A(x/w) + B(y/w) + C = 0. Multiplying by w changes it to

Ax + By + Cw = 0.

Let the given equation be a second degree polynomial Ax2 + 2Bxy + Cy2 + 2Dx + 2Ey + F = 0. After replacing x and y with x/w and y/w and multiplying the result with w2, we have

Ax2 + 2Bxy + Cy2 + 2Dxw + 2Eyw + Fw2 = 0

If you look at these two polynomials carefully, you will see that the degrees of all terms are equal. In the case of a line, terms x, y and w are of degree one, while in the second degree polynomial, all terms (i.e., x2, xy, y2, xw, yw and w2) are of degree two.

Given a polynomial of degree n, after introducing w, all terms are of degree n. Consequently, these

polynomials are called homogeneous polynomials and the coordinates (x,y,w) the homogeneous coordinates.

Given a degree n polynomial in a homogeneous coordinate system, dividing the polynomial with wn and replacing x/w, y/w with x and y, respectively, will convert the polynomial back to a conventional one. For example, if the given degree 3 homogeneous polynomial is the following:

x3 + 3xy2 - 5y2w + 10w3 = 0 the result is

x3 + 3xy2 - 5y2 + 10 = 0

This works for three-dimension as well. One can replace a point (x, y, z) with (x/w, y/w, z/w) and multiply the result by w raised to certain power. The resulting polynomial is a homogeneous one. Converting a degree n homogeneous polynomial in x, y, z and w back to the conventional form is exactly identical to the

Homogeneous Coordinates

Homogeneous Coordinates 1

(18)

two-variable case.

An Important Notes

Given a point (x,y,w) in homogeneous coordinates, what is its corresponding point in the xy-plane? From what we discussed for converting a homogeneous polynomial back to its conventional form, you might easily guess that the answer must be (x/w,y/w). This is correct. Thus, a point (3,4,5) in homogeneous coordinates converts to point (3/5,4/5)=(0.6,0.8) in the xy-plane. Similarly, a point (x,y,z,w) in homogeneous coordinates converts to a point (x/w,y/w,z/w) in space.

Conversely, what is the homogeneous coordinates of a point (x,y) in the xy-plane? It is simply (x,y,1)! That is, let the w component be 1. In fact, this is only part of the story, because the answer is not unique. The

homogeneous coordinates of a point (x,y) in the xy-plane is (xw, yw, w) for any non-zero w. Why is this true?

Because (xw, yw, w) is converted back to (x,y). As a result, the following is important for you to memorize:

Converting from a homogeneous coordinates to a conventional one is unique; but, converting a conventional coordinates to a homogeneous one is not.

For example, a point (4,2,3) in space is convert to (4w, 2w, 3w, w) for any non-zero w.

The Dimensionality of Homogeneous Coordinates

You perhaps have discovered that homogeneous coordinates need 3 and 4 components to represent a point in the xy-plane and a point in space, respectively. Therefore, a point in space (resp., the xy-plane) in

homogeneous coordinates actually has four (resp., third) components. Adding a fourth (resp., third) component whose value is 1 to the coordinates of a point in space (resp., the xy-plane) converts it to its corresponding homogeneous coordinates.

Ideal Points or Points at Infinity

As mentioned at the very beginning of this page, homogeneous coordinates can easily capture the concept of infinity. Let a point (x,y) be fixed and converted to a homogeneous coordinate by multiplying with 1/w, (x/w,y/w,1/w). Let the value of w approach to zero, then (x/w,y/w) moves farther and farther away in the direction of (x,y). When w becomes zero, (x/w,y/w) moves to infinity. Therefore, we would say, the homogeneous coordinate (x,y,0) is the ideal point or point at infinity in the direction of (x,y).

Let us take a look at an example. Let (3,5) be a point in the xy-plane. Consider (3/w,5/w). If w is not zero, this point lies on the line y = (5/3) x. Or, if you like the vector form, (3/w,5/w) is a point on the line O + (1/w)d, where the base point O is the coordinate origin and d is the direction vector . Therefore, as w approaches zero, the point moves to infinity on the line. This is why we say (x,y,0) is the ideal point or the point at infinity in the direction of (x,y).

The story is the same for points in space, where (x,y,z,0) is the ideal point or point at infinity in the direction of (x,y,z).

Homogeneous Coordinates

An Important Notes 2

(19)

The concept of homogeneous coordinates and points at infinity in certain direction will become very important when we discuss representations of curves and surface.

A Simple Geometric Interpretation

Given a homogeneous coordinate (x,y,w) of a point in the xy-plane, let us consider (x,y,w) to be a point in space whose coordinate values are x, y and w for the x-, y- and w- axes, respectively. The line joining this point and the coordinate origin intersects the plane w = 1 at a point (x/w, y/w, 1). Please verify this fact yourself. The following figure illustrates this concept.

This transformation treats a two-dimensional homogeneous point as a point in three-dimensional space and projects (from the coordinate origin) this three-dimensional point to the plane w=1. Therefore, as a

homogeneous point moves on a curve defined by homogeneous polynomial f(x,y,w)=0, its corresponding point moves in three-dimensional space, which, in turn, is projected to the plane w=1. Of course, (x/w,y/w) moves on a curve in plane w=1.

The above figure also shows clearly that while the conversion from the conventional Euclidean coordinates to homogeneous coordinates is unique, the opposite direction is not because all points on the line joining the origin and (x,y,w) will be projected to (x/w,y/w,1). This is also an important concept to be used in later lectures.

Homogeneous Coordinates

Ideal Points or Points at Infinity 3

(20)

Geometric Transformations

When talking about geometric transformations, we have to be very careful about the object being transformed.

We have two alternatives, either the geometric objects are transformed or the coordinate system is

transformed. These two are very closely related; but, the formulae that carry out the job are different. We only cover transforming geometric objects here.

We shall start with the traditional Euclidean transformations that do not change lengths and angle measures, followed by affine transformation. Finally, we shall talk about projective transformations.

Euclidean Transformations

The Euclidean transformations are the most commonly used transformations. An Euclidean transformation is either a translation, a rotation, or a reflection. We shall discuss translations and rotations only.

Translations and Rotations on the xy-Plane

We intend to translate a point in the xy-plane to a new place by adding a vector <h, k> . It is not difficult to see that between a point (x, y) and its new place (x', y'), we have x' = x + h and y' = y + k. Let us use a form similar to the homogeneous coordinates. That is, a point becomes a column vector whose third component is 1. Thus, point (x,y) becomes the following:

Then, the relationship between (x, y) and (x', y') can be put into a matrix form like the following:

Therefore, if a line has an equation Ax + By + C = 0, after plugging the formulae for x and y, the line has a new equation Ax' + By' + (-Ah - Bk + C) = 0.

If a point (x, y) is rotated an angle a about the coordinate origin to become a new point (x', y'), the relationships can be described as follows:

Geometric Transformations

Geometric Transformations 1

(21)

Thus, rotating a line Ax + By + C = 0 about the origin a degree brings it to a new equation:

(Acosa - Bsina)x' + (Asina + Bcosa)y' + C = 0

Translations and rotations can be combined into a single equation like the following:

The above means that rotates the point (x,y) an angle a about the coordinate origin and translates the rotated result in the direction of (h,k). However, if translation (h,k) is applied first followed by a rotation of angle a (about the coordinate origin), we will have the following:

Therefore, rotation and translation are not commutative!

In the above discussion, we always present two matrices, A and B, one for transforming x to x' (i.e., x'=Ax) and the other for transforming x' to x (i.e., x=Bx'). You can verify that the product of A and B is the identity matrix. In other words, A and B are inverse matrices of each other. Therefore, if we know one of them, the other is the inverse of the given one. For example, if you know A that transforms x to x', the matrix that

Geometric Transformations

Translations and Rotations on the xy-Plane 2

(22)

transforms x' back to x is the inverse of A.

Let R be a transformation matrix sending x' to x: x=Rx'. Plugging this equation of x into a conic equation gives the following:

Rearranging terms yields

This is the new equation of the given conic after the specified transformation. Note that the new 3-by-3 symmetric matrix that represents the conic in a new position is the following:

Now you see the power of matrices in describing the concept of transformation.

Translations and Rotations in Space

Translations in space is similar to the plane version:

The above translates points by adding a vector <p, q, r>.

Rotations in space are more complex, because we can either rotate about the x-axis, the y-axis or the z-axis.

When rotating about the z-axis, only coordinates of x and y will change and the z-coordinate will be the same.

In effect, it is exactly a rotation about the origin in the xy-plane. Therefore, the rotation equation is

With this set of equations, letting a be 90 degree rotates (1,0,0) to (0,1,0) and (0,1,0) to (-1,0,0). Therefore, the x-axis rotates to the y-axis and the y-axis rotates to the negative direction of the original x-axis. This is the

Geometric Transformations

Translations and Rotations in Space 3

(23)

effect of rotating about the z-axis 90 degree.

Based on the same idea, rotating about the x-axis an angle a is the following:

Let us verify the above again with a being 90 degree. This rotates (0,1,0) to (0,0,1) and (0,0,1) to (0,-1,0).

Thus, the y-axis rotates to the z-axis and the z-axis rotates to the negative direction of the original y-axis.

But, rotating about the y-axis is different! It is because the way of measuring angles. In a right-handed system, if your right hand holds a coordinate axis with your thumb pointing in the positive direction, your other four fingers give the positive direction of angle measuring. More precisely, the positive direction for measuring angles is from the z-axis to x-axis. However, traditionally the angle measure is from the x-axis to the z-axis.

As a result, rotating an angle a about the y-axis in the sense of a right-handed system is equivalent to rotating an angle -a measuring from the x-axis to the z-axis. Therefore, the rotation equations are

Let us verify the above with rotating about the y-axis 90 degree. This rotates (1,0,0) to (0,0,-1) and (0,0,1) to (1,0,0). Therefore, the x-axis rotates to the negative direction of the z-axis and the z-axis rotates to the original x-axis.

A rotation matrix and a translation matrix can be combined into a single matrix as follows, where the r's in the upper-left 3-by-3 matrix form a rotation and p, q and r form a translation vector. This matrix represents rotations followed by a translation.

You can apply this transformation to a plane and a quadric surface just as what we did for lines and conics earlier.

Geometric Transformations

Translations and Rotations in Space 4

(24)

Affine Transformations

Euclidean transformations preserve length and angle measure. Moreover, the shape of a geometric object will not change. That is, lines transform to lines, planes transform to planes, circles transform to circles, and ellipsoids transform to ellipsoids. Only the position and orientation of the object will change. Affine transformations are generalizations of Euclidean transformations. Under affine transformations, lines transforms to lines; but, circles become ellipses. Length and angle are not preserved. In this section, we shall discuss scaling, shear and general affine transformations.

Scaling

Scaling transformations stretch or shrink a given object and, as a result, change lengths and angles. So, scaling is not an Euclidean transformation. The meaning of scaling is making the new scale of a coordinate direction p times larger. In other words, the x coordinate is "enlarged" p times. This requirement satisfies x' = p x and therefore x = x'/p.

Scaling can be applied to all axes, each with a different scaling factor. For example, if the x-, y- and z-axis are scaled with scaling factors p, q and r, respectively, the transformation matrix is:

Shear

The effect of a shear transformation looks like ``pushing'' a geometric object in a direction parallel to a coordinate plane (3D) or a coordinate axis (2D). In the following, the red cylinder is the result of applying a shear transformation to the yellow cylinder:

How far a direction is pushed is determined by a shearing factor. On the xy-plane, one can push in the x-direction, positive or negative, and keep the y-direction unchanged. Or, one can push in the y-direction and keep the x-direction fixed. The following is a shear transformation in the x-direction with shearing factor a:

Geometric Transformations

Affine Transformations 5

(25)

The shear transformation in the y-direction with shearing factor b is the following:

In space, one can push in two coordinate axis directions and keep the third one fixed. The following is the shear transformation in both x- and y-directions with shearing factors a and b, respectively, keeping the z-coordinate the same:

Let us take a look at the effect of this shear transformation. Expanding the matrix equation gives the following:

x' = x + az y' = y + bz z' = z

Thus, a point (x, y, z) in space is transformed to (x + az, y + bz, z). Therefore, the z-coordinate does not change, while (x, y) is ``pushed'' in the direction of (a, b, 0) with a factor z.

The following is the shear transformation in xz-direction:

The following is the shear transformation in yz-direction:

Geometric Transformations

Shear 6

(26)

General Affine Transformations

The general affine transformation matrix has the following form:

Comparing with all previous discussed matrices, rotations and translations included, you will see that all of them fit into this form and hence are affine transformations. Affine transformations do not alter the degree of a polynomial, parallel lines/planes are transformed to parallel lines/planes, and intersecting lines/plane are transformed to intersecting lines and planes. However, affine transformations do not preserve lengths and angle measures and as a result they will change the shape of a geometric object. The following shows the result of a affine transformation applied to a torus. A torus is described by a degree four polynomial. The red surface is still of degree four; but, its shape is changed by an affine transformation.

Note that the matrix form of an affine transformation is a 4-by-4 matrix with the fourth row 0, 0, 0 and 1.

Moreover, if the inverse of an affine transformation exists, this affine transformation is referred to as non-singular; otherwise, it is singular. We do not use singular affine transformations in this course.

Projective Transformations

Projective transformations are the most general "linear" transformations and require the use of homogeneous coordinates. Given a point in space in homogeneous coordinate (x,y,z,w) and its image under a projective transform (x',y',z',w'), a projective transform has the following form:

Geometric Transformations

General Affine Transformations 7

(27)

In the above, the 4-by-4 matrices must be non-singular (i.e., invertible). Therefore, projective transformations are more general than affine transformations because the fourth row does not have to contain 0, 0, 0 and 1.

Projective transformation can bring finite points to infinity and points at infinity to finite range. Let us take a look at an example. Consider the following projective transformation:

Obviously, this transformation sends (x,y,w)=(1,0,1) to (x',y',w') = (1,-1,0). That is, this projective

transformation sends (1,0) on the xy-plane to the point at infinity in direction . From the right-hand side of the matrix equation x=Px' we have

x = 2x' + y' y = x' + y' w = 2x' + y' + w'

Let us consider a circle x^2 + y^2 = 1. Plugging the above equations into the circle equation changes it to the following:

x2 + 2xy + y2 - 4xw - 2yw - w2 = 0

Dividing the above by w^2 to convert it back to conventional form yields x2 + 2xy + y2 - 4x - 2y - 1 = 0

This is a parabola! (Why?) Therefore, a circle that has no point at infinity is transformed to a parabola that does have point at infinity.

While projective transformations, like affine transformations, do not change the degree of a polynomial, two parallel (i.e., intersecting) lines/planes can be transformed to two intersecting (i.e., parallel) lines/planes.

Please verify this fact yourself.

Although we do not use these facts and the concept of projective transformations immediately, it will be very helpful in later lectures.

Geometric Transformations

Projective Transformations 8

(28)

Matrix Multiplication and Transformations

We have introduced to you several transformations. We always show to you two forms, one from x to x' and the other the inverse from x' to x. In many cases, one may need several transformations to bring an object to its desired position. For example, one may need a transformation in matrix form q=Ap bringing p to q, followed by a second transformation r=Bq bringing q to r, followed by yet another transformation s=Cr bringing r to s. The net effect of p -> q -> r -> s can be summarized into a single transformation represented by the product of all involved matrices. Note that the first (resp., last) transformation matrix is the right-most (resp., left-most) in the multiplication sequence.

s = Cr = C(Bq) = CBq = CB(Ap) = CBAp

Therefore, to compute the net effect, we just compute CBA and use it as a single transformation, which brings p to s.

Let us take a look at an example. We want to perform the following transformations to an object:

Scale in the x-direction using a scale factor 5 (i.e., making it five times larger).

1.

Followed by a rotation about z-axis 30 degree 2.

Followed by a shear transformation in x- and y-direction with shearing factor 2 and 3, respectively.

3.

Followed by a transformation moving the point in the direction of < 2, 1, 2 >.

4.

Let the scaling, rotation, shearing and translation matrices be A, B, C and D, respectively. With previous discussion, we have the following, where matrix H = DCBA is the net effect:

Geometric Transformations

Matrix Multiplication and Transformations 9

(29)

Therefore, the net effect of transforming a point x of the initial object to the corresponding point x' after the above four transformations is computed as x' = Hx = DCBAx.

Geometric Transformations

Matrix Multiplication and Transformations 10

(30)

Problems

Given a line B+td and a plane with base point A and normal vector n, what is the condition for the line is perpendicular to the plane? What is the condition for the line to be parallel to the plane?

1.

Problems

Problems 1

(31)

References

Most of this week's material are from Bowyer and Wookwark's little book. The example showing the bad effect of the associative law is from Colonna's paper. Finally, you can find more about floating pointing computation problems is Acton's book.

Wolfgang Boehm and Hartmut Prautzsch, Geometric Concepts for Geometric Design, AK Peters, Wellesley, MA, 1994.

Michael E. Mortenson, Computer Graphics: An Introduction to the Mathematics and Geometry, Heinemann Newnes, Oxford, UK, 1989.

References

References 1

(32)

Introduzione

La nostra prima domanda è: perché abbiamo bisogno di nuove forme di curve parametriche? Una risposta immediata è che le curve parametriche discusse in precedenza non sono molto geometriche. Più esattamente, data una tale forma parametrica non è facile conoscere la geometria che ne sta alla base senza una ulteriore analisi. I coefficienti delle equazioni non hanno alcun significato geometrico e risulta praticamente

impossibile predirre il cambiamento di una forma dovuto alla variazione di uno o più coefficienti. Pertanto disegnare una curva che segua certi schemi risulta difficoltoso.

Nella pratica i disegnatori o gli utenti non si preoccupano della matematica (e quindi delle equazioni) che sono alla base di una curva. Essi si concentrano più o meno sullo svolgimento del proprio lavoro. Pertanto un sistema che voglia essere di ausilio agli utenti nel disegnare curve deve risultare

Intuitivo:

Ci si aspetta che ogni passo ed ogni algoritmo abbia un'interpretazione intuitiva e geometrica.

1.

Flessibile:

Il sistema dovrebbe fornire agli utenti un maggiore controllo per il disegno e la modifica della forma di una curva. La creazione e modifica di una curva dovrebbero essere semplici, intuitive e

geometriche, piuttosto che avvenire manipolando equazioni.

2.

Approccio unificato:

Il modo di rappresentare, creare e modificare tipi differenti di curve (per esempio linee, coniche, sezioni di coniche e cubiche) deve essere uguale. Vale a dire non deve richiedere strumenti diversi per manipolare curve differenti (per esempio coniche e cubiche).

3.

Invariante:

La curva rappresentata non dovrà modificare la sua geometria a seguito di trasformazioni geometriche quali la traslazione, la rotazione e le trasformazioni affini.

4.

Efficienza e stabilità numerica: Un utente di un sistema di disegno può non curarsi della bellezza della geometria alla base, tuttavia sia aspetta che fornisca la curva desiderata in modo veloce ed accurato. Inoltre una grande quantità di calcoli non deve "distorcere" la forma della curva (stabilità numerica).

5.

Quest'unità si concentra su alcune tecniche per il disegno di curve in grado di soddisfare i criteri su menzionati. In questa sezione descriveremo le curve di Bézier; nelle successive due le curve B-spline e NURBS. Il tema unificante di tali tecniche presenta i seguenti vantaggi:

Un utente schematizza un insieme di punti di controllo per il sistema per generare una curva che più o meno segue l'andamento dei punti di controllo.

1.

Un utente può modificare le posizioni di alcuni punti di controllo e di altre caratteristiche per variare la forma della curva. Non è richiesta nessuna equazione, dal momento che solitamente l'equazione di una curva non viene memorizzata..

2.

Se necessario, un utente può aggiungere punti o altre informazioni vitali senza modificare la forma della curva. In questo modo l'utente ha una maggiore libertà di modificare una curva, in quanto l'aggiunta di punti di controllo aumenta i gradi di libertà della curva..

3.

Un utente può persino spezzare una curva in due parti per effettuare "micro" modifiche e poi unirli di nuovo in un'unica parte..

4.

Esistono algoritmi molto geometrici, intuitivi e stabili numericamente per individuare i punti sulla curva senza conoscere l'equazione della curva.

5.

Una volta che la teoria sulle curve è nota, la transizione alle superfici non è complicata, dal momento che ciò che si appreso per le curve si applica in modo diretto alle superfici.

6.

An Introduction

Introduzione 1

(33)

Cominceremo con le curve fondamentali della toeria: le curve di Bézier. Esse furono scoperte

contemporaneamente da Paul de Casteljau alla Citroen e Pierre E. Bézier alla Renault attorno alla fine degli anni '50 ed inizio degli anni '60. Le splines base, abbreviate come B-splines, furono conosciute e studiate da N. Lobachevsky il cui contrubuto maggiore è probabilmente la cosiddetta geometria iperbolica (non Euclidea) alla fine del XVIII secolo.. Tuttavia seguiremo una trattazione più moderna dovuta a C. de Boor, M. Cox e L.

Mansfield alla fine degli anni '70. Da notare che le curve di Bézier sono una caso speciale di B-splines..

Sia le curve di Bézier che le B-splines sono curve parametriche polinomiali. Come discusso in precedenza, le forme parametriche polinomiali non possono rappresentare alcune forme semplici quali il cerchio. Pertanto le curve di Bézier e le B-splines possono solo rappresentare quello che le forme parametriche polinomiali permettono. Introducendo coordinate omogenee che le rendono razionali, le curve di Bézier e le B-splines si generalizzano in curve razionali di Bézier e Non-Uniform Rational B-splines, or NURBS in breve.

Ovviamente le curve razionali di Bézier sono più potenti delle curve di Bézier dal momento che le prime possono rappresentare cerchi ed ellissi. Analogamente le NURBS sono più potenti delle B-splines. La relazione tra questi quattro tipi di rappresentazioni di curve è mostrata nella figura di seguito.

An Introduction

Introduzione 2

(34)

Costruzione delle Curve di Bézier

Dati n+1 punti P0, P1, P2, ..., Pn nello spazio, ipunti di controllo, lacurva di Bézier definita da questi punti di controllo è

dove i coefficienti sono definiti come segue:

Pertanto il punto che corrisponde ad u sulla cirva di Bézier è la media "pesata" di tutti i punti di controllo, dove i pesi sono i coefficienti Bn,i(u). I segmenti di linea P0P1, P1P2, ..., Pn-1Pn, chiamatilegs, unendosi in quest'ordine formano unapolilinea di controllo. Molti autori preferiscono chiamare questa polilinea di controllopoligono di controllo. Le funzioni Bn,i(u), 0 <= i <= n, vengono chiamate funzioni base di Bézier oppurepolinomi di Bernstein.

Da notare che il dominio di u è [0,1]. Come risultato, tutte le funzioni di base sono non negative. Nella formula sopra, poichè u ed i possono essere entrambi zero, così come 1 - u ed n - i, noi adottiamo la convenzione che 00 vale 1. Il grafico seguente mostra una curva di Bézier definita da 11 punti di controllo, dove il punto blu è un punto della curva corrispondente a u=0.4. Come si può vedere, la curva segue più o meno la polilinea.

Le seguenti proprietà di una curva di Bézier sono importanti:

Il grado di una curva di Bézier definita da n+1 punti di controllo è n:

1.

In ogni funzione di base l'esponente di u è i + (n - i) = n. Pertanto il grado della curva è n.

2.

C(u) passa per P0 e Pn:

Questo è evidente dalla figura. La curva passa per il primo ed ultimo punto di controllo. E' possibile verificarlo analiticamente mediante alcune manipolazioni algebriche.

3.

Non negatività:

Tutte le funzioni di base sono non negative..

4.

Costruzione delle curve di Bézier

Costruzione delle Curve di Bézier 1

(35)

Partizione dell'Unità:

La somma delle funzioni di base per un fissato u vale 1. Non è difficile verificare che le funzioni di base sono i coefficienti nell'espansione binomiale dell'espressione 1 = (u + (1 - u))n. Pertanto la loro somma è 1. Inoltre, poiché sono non negativi, concludiamo che il valore di qualunque funzione di base è compreso tra 0 e 1.

Nella figura di sinistra abbiamo una curva di Bézier definita in base a 5 punti di controllo. Le sue cinque funzioni di base sono funzioni di u come mostrato nella figura a destra. Le figure mostrano u=0.5 e le cinque funzioni di base. Le linee verticali più a destra mostrano il modo di partizionare 1 in cinque intervalli, da cui il nome di partizione dell'unità. Da notare che il colore di una partizione è identico al colore usato per tracciare la corrispondente funzione di base.

Poiché tutte le funzioni di base sono comprese tra 0 e 1 e la somma vale 1, esse possono essere considerate come pesi nel calcolo di una media pesata. Più precisamente potremmo affermare che

"per calcolare C(u) si prende il peso Bn,i(u) per ciascun punto di controllo Pi e si sommano assieme".

5.

Proprietà di HULL convesso:

Significa che la curva di Bézier definita da n + 1 punti di controllo assegnati giace completamente nell'HULL convesso formato dai punti di controllo. L'HULL convesso di un insieme di punti è il più piccolo insieme convesso che contiene tutti i punti. Nella figura seguente l'HULL convesso degli 11 punti di controllo è mostrato in grigio. Da notare che non tutti i punti di controllo giacciono sul bordo dell'HULL convesso. Ad esempio i punti di controllo 3, 4, 5, 6, 8 e 9 sono all'interno. La curva, eccetto che per i primi due punti finali, giace completamente nell'HULL convesso.

La proprietà è importante perché siamo garantiti che la curva generata giacerà un una regione capita e calcolabile e non fuoriuscirà da essa.

6.

Proprietà della Variazione Diminishing:

Se la curva giace in un piano, vuol dire che nessuna linea retta interseca una curva di Bézier un numero di volte maggiore di quello che interseca la polilinea di controllo della curva.

7.

Costruzione delle curve di Bézier

Costruzione delle Curve di Bézier 2

(36)

Nella figura sopra la linea gialla interseca la curva 3 volte e la polilinea 7 volte; la linea magenta interseca la curva 5 volte e la polilinea 7 volte; la linea ciano interseca la curva e la sua polilinea due volte. E' possibile tracciare altre linee rette per rendersi conto della proprietà..

Se la curva si trova nello spazio, sarà sufficiente sostituire "linea" con "piano". Potranno verificarsi casi speciali, tuttavia non risulta difficoltoso ricavare un apposito schema di conteggio che tenga conto anche di essi.

Qual è il significato di tale proprietà? Ci dice che la complessità della curva (vale a dire i TURNING e i TWISTING) non è maggiore di quella della polilinea di controllo. In altre parole la polilinea di controllo TWISTS e TURNS più frequentemente di quanto non faccia la curva di Bézier, poiché una linea arbitraria atraversa la polilinea di controllo più spesso di quanto non attraversi la curva. Per esempio nella figura sopra la polilinea di controllo risulta più complessa della curva che definisce..

Invarianza affine:

Se alla curva di Bézier si applica una trasformazione affine, il risultato può essere costruito dalle immagini affini dei suoi punti di controllo. Quando vogliamo applicare ad una curva di Bézier una trasformazione geometrica o anche affine, questa proprietà stabilisce che è possible applicare la trasformazione ai punti di controllo, il che è abbastanza semplice, e una volta ottenuti i punti di controllo trasformati la curva di Bézier trasformata é quella definita da questi nuovi punti. Pertanto non dobbiamo trasformare la curva..

8.

Cosa succede se il dominio di u non è [0.1]?

Talvolta il dominio di una curva di Bézier è [a,b] invece che [0,1]. Pertanto si richiede un cambiamento di variabile. Quello che andrebbe fatto è semplicemente convertire una u in [a,b] in una nuova u in [0,1] e usare questa u nelle funzioni di base. La conversione di u in [0,1] può essere fatta come segue:

Inserendo questa u nelle funzioni di base Bn,i(u) produce la seguente formula:

Costruzione delle curve di Bézier

Cosa succede se il dominio di u non è [0.1]? 3

(37)

Queste nuove funzioni di base definiscono una curva di Bézier nel dominio di [a,b].

Un breve riassunto

In definitiva, per definire una curva di Bézier di grado n, bisogna scegliere n + 1 punti di controllo nello spazio in modo che indichino approssimativamente la forma della curva richiesta. Se poi il risultato non soddisfa l'attesa, è possibile spostare i punti di controllo.Quando uno o più punti di controllo vengono spostati, la forma della curva di Bézier cambia di conseguenza. Tuttavia la curva giace nell'HULL convesso definito dai punti di controllo (proprietà dell'HULL convesso) e la forma della curva generata risulta meno complessa della polilinea di controllo (proprietà delle variazione DIMINISHING).

Costruzione delle curve di Bézier

Un breve riassunto 4

(38)

Spostare i punti di controllo

Variando la posizione di un punto di controllo sia cambia la forma della curva di Bézier risultante. La domanda è:

Come cambia la forma della curva se un punto di controllo viene spostato in una nuova posizione?

Supponiamo che un punto di controllo Pk viene spostato in una nuova posizione Pk + v, dove il vettore v fornisce sia la direzione che la lunghezza dello spostamento (vedi figura seguente).

Sia la curva di Bézier originale

Poiché la nuova curva di Bézier è definita da P0, P1. ..., Pk+v, ..., Pn, la sua equazione D(u) risulta

Nella formula sopra, poiché solo il k-mo termine usa un punto di controllo diverso Pk + v, dopo aver raggruppato i termini, osserviamo che la nuova curva risulta la somma di quella originaria più un termine extra Bn,k(u)v. Questo vuol dire che:

il corrispondente punto di u sulla nuova curva viene ottenuto traslando il corrispondente punto u sulla curva originaria nella direzione di v ad una distanza |Bn,k(u)v|.

Più precisamente, assegnata una u, abbiamo il punto C(u) sulla curva originaria e D(u) sulla nuova curva e D(u) = C(u) + Bn,k(u)v. Poiché v fornisce la direzione dello spostamento, D(u) è il risultato dello spostamento di C(u) nella stessa direzione. La lunghezza di questa traslazione è ovviamente la lunghezza del vettore Bn,k(u)v. Pertanto, quando Bn,k(u) raggiunge il massimo, la variazione da C(u) a D(u) è la più ampia.

Spostare i punti di controllo

Spostare i punti di controllo 1

(39)

La figura seguente illustra quest'effetto. Sia la curva nera che quella rossa sono curve di Bézier di grado 8 definite mediante 9 punti di controllo. Quella nera è l'originale. Se il suo punto di controllo 3 viene spostato in una nuova direzione come indicato dal vettore viola, la curva nera si modifica in quella rossa.Su ognuna delle due curve vi è il punto corrispondente a u=0.5. E' chiaro che C(0.5) si sposta nella stessa direzione verso D(0.5). La distanza tra C(0.5) e D(0.5) è la lunghezza del vettore B8,3(0.5)v = 8!/(3!(8-3)!)×0.53(1-0.5)8-3v = 0.22v. Pertanto la distanza è circa il 22% della distanza tra il punto di controllo originale 3 e il nuovo punto di controllo 3 come mostrato nella figura.

Possiamo trarre un'ulteriore importante conclusione dalla discussione sopra. Poiché Bn,k(u) è diverso da zero nell'intervallo aperto, Bn,k(u)v non è un vettore nullo in (0,1). Questo vuol dire che eccetto per i due punti finali C(0) and C(1)tutti i punti sulla curva originaria vengono spostati in nuove posizioni. Pertanto

Variando la posizione di un punto di controllo la forma della curva di Bézier cambia in ogni punto.

Spostare i punti di controllo

Spostare i punti di controllo 2

Riferimenti

Documenti correlati

Zn(II)  8.567 ± 0.185**  6.006 ± 0.604**  Zn‐t CNS  0.710 ± 0.0568*  0.510 ± 0.0258*  CNS  0.00251 ± 0.0001*  0.0245 ± 0.0008*  ASW 

What will be show and discussed in the next paragraph will be the rotor vibration amplitude of the vertical displacements, that is specifically relative displacement at the

1 a The surgical technique involves excision of the tumour by a total scapulectomy and surrounding soft tissue resection, b elevation of a latissimus dorsi (LD) vascularized flap,

The well known conjecture about exceptional almost perfect non-linear (excep- tional APN) functions, stated by Aubry, McGuire and Rodier, says that the monomials x 2 k +1 and x 2 2k

Keywords: Cubic function, Ramanujan cubic continued fraction, Theta function identities related to modular equations of degree 3.. MSC 2000 classification: Primary 33D90,

[r]

Abstract We give a survey of some recent results on the construction of numerical cubature formulas from scattered samples of small/moderate size, by using interpolation with

Error analysis and numerical tests with random points in the unit square have shown that Thin-Plate Splines and Wendland’s compactly supported RBF provide stable and reasonably