HARMONIC INTERPOLATION FOR SMOOTH CURVES AND SURFACES ALEXANDRE HARDY THESIS. submitted in fulfilment of the requirements for the degree

Size: px
Start display at page:

Download "HARMONIC INTERPOLATION FOR SMOOTH CURVES AND SURFACES ALEXANDRE HARDY THESIS. submitted in fulfilment of the requirements for the degree"

Transcription

1 HARMONIC INTERPOLATION FOR SMOOTH CURVES AND SURFACES by ALEXANDRE HARDY THESIS submitted in fulfilment of the requirements for the degree PHILOSOPHIA DOCTOR in APPLIED MATHEMATICS in the FACULTY OF SCIENCE at the UNIVERSITY OF JOHANNESBURG PROMOTER: PROF W.-H. STEEB MAY 2005

2

3 Acknowledgement i Acknowledgement I would like to thank Prof. W.-H. Steeb for giving me the opportunity to write this thesis. I would also like to thank Yorick Hardy for numerous discussions which made much of the work possible. I could not have completed the thesis without the support and patience of my wife, Anneli, for which I am eternally grateful. My parents provided the encouragement and guidance to pursue an academic career, so my thanks go to them too. But it is the spirit in a man, the breath of the Almighty, that gives him understanding. Job 32:8

4 ii Acknowledgement

5 Summary iii Summary The creation of smooth interpolating curves and surfaces is an important aspect of computer graphics. Trigonometric interpolation in the form of the Fourier transform has been a popular technique. For computer graphics, simpler curves and surfaces like the Bézier curve and B-spline curve have been more popular due to the computational efficiency. Fitting B-spline or Bézier curves or surfaces to unorganised data points has been more challenging since these curves are not naturally interpolating. Normally a system of equations needs to be solved to obtain the curves or surfaces with the added problem of identifying data points to form piecewise continuous surfaces. We solve the problem of periodic interpolating curves and surfaces using harmonic interpolation [73]. We extend harmonic interpolation to handle an even number of data points. We then show how harmonic interpolation can be applied using geometry images [29] to create smooth interpolating surfaces. We introduce algorithms to manipulate the amount of interpolated points, and the location of the interpolated points. Finally, we show how a smooth interpolating surface created by harmonic interpolation can be converted to a series of Bézier surfaces. The combination of techniques allows us to quickly create a smooth interpolating surface from a set of unorganised points that have a known spherical structure. Keywords: Interpolation, harmonic interpolation, trigonometric interpolation, Bézier curves surface fitting, tensor product surfaces.

6 iv Summary

7 Opsomming v Opsomming Die skep van gladde interpolerende kurwes en oppervlakke is n belangrike aspek in rekenaargrafika. Trigonometriese interpolasie in die vorm van die Fourier transformasie is n gewilde tegniek. Vir rekenaargrafika is eenvoudige kurwes en oppervlakke, soos Bézier en B-spline kurwes, gewilder as gevolg van die doeltreffendheid van die berekening van hierdie funksies. Die passing van B-spline en Bézier kurwes en oppervlakke op ongeorganiseerde datapunte is moeiliker omdat hierdie kurwes nie natuurlik interpoleer nie. Gewoonlik moet n stelsel vergelykings opgelos word om die kurwes of oppervlakke te bepaal. Om data punte te identifiseer wat gebruik kan word om stuksgewys kontinue oppervlakke te skep, is ook n moeilike taak. Die probleem van periodiese kurwes en oppervlakke wat interpoleer word opgelos met behulp van harmonies interpolasie [73]. Daar word op die harmoniese interpolasiekurwes uitgebrei sodat n ewe aantal punte ondersteun word. Meetkundige beelde [29] word dan gebruik om gladde interpolerende oppervlakke te skep. Nuwe algoritmes word beskryf om die aantal punte wat geïnterpoleer word te verander, of rond te skuif. Laastens word aangetoon hoe om n gladde interpolerende oppervlak, wat deur harmoniese interpolasie geskep is, na n verskeidenheid Bézier oppervlakke om te skakel. Wanneer hierdie tegnieke saam gebruik word, kan n gladde interpolerende oppervlak vinnig uit n stel ongeorganiseerde punte, wat n bekende sferiese struktuur het, gevorm word. Sleutelwoorde: Interpolasie, harmoniese interpolasie, trigonometriese interpolasie, Bézier kurwes, oppervlakpassing, tensorprodukoppervlakke

8 vi Opsomming

9 Contents List of Figures List of Tables Notation xi xv xvii 1 Introduction Problem Pleasing curves Contributions Layout of Thesis Background Vector Spaces Points and Vectors Affine Transformations Introduction and Definitions Affine Invariance Lagrange Interpolation Bézier Curves Affine Invariance Convex Hull Derivative at Edges Piecewise Continuous Bézier Curves Rendering Rational Bézier Curves Bézier Curves: Conic Sections Catmull-Rom Splines Bessel-Overhauser Splines Tension-Continuity-Bias Splines Uniform B-Splines vii

10 viii Contents Affine Invariance Convex Hull Cox-de Boor Formula Non-Uniform B-Splines Interpolating with B-Splines Periodic Interpolation Non-Uniform Rational B-Splines Trigonometric Interpolation METAPOST and Bézier Curves Curvature and Torsion Conclusion Harmonic Interpolation Interpolation Odd Case Even Case Examples Curvature plots Numerical Stability Affine Invariance Convex Hull Property Chebyshev Polynomials Odd case Even case Non-Uniform Harmonic Interpolation Conclusion Surfaces Parametric Surfaces Tensor Product Surfaces Bézier Surfaces Tensor Product Bézier Surfaces Triangular Bézier Surfaces Rational Bézier Surfaces Bézier Surface Interpolation B-Spline Tensor Product Surfaces B-Spline Surface Interpolation Subdivision Surfaces Loop Subdivision Modified Butterfly Subdivision Subdivision

11 Contents ix Interpolating 3 Subdivision Catmull-Clark Subdivision Doo-Sabin Subdivision Comparison Interpolation with Subdivision Surfaces Curvature of Surfaces Conclusion Harmonic Surfaces Tensor Product Surface Subdivision Surface Fitting - Interpolation Algorithm Algorithm Surface Fitting - Approximation Rendering Ray tracing Interval arithmetic Interval Root Finding Bisection Interval Root Finding Newton-Raphson Raytracing Harmonic Surfaces Approximating Basis Functions Combined results Curvature Conclusion Conclusion Contributions Conclusions Bibliography 193 Index 201

12 x Contents

13 List of Figures 1.1 An example of a polygonal object A Bézier curve does not interpolate all of its control points An unorganised set of points provided by Hoppe [35] Basis functions for uniform Lagrange interpolation of degree Uniform Lagrange interpolation of 4 points Basis functions for Bézier curves of degree A Bézier curve and its convex hull Piecewise continuous Bézier curves de Casteljau s method Subdivision of figure 2.4 into two Bézier curves Section of a circle, drawn with a rational Bézier curve The basis functions of B-splines of degree The blending functions of B-splines of degree A Bézier curve of degree A B-spline curve of degree 3, using the same control points as figure Interpolation using B-splines Periodic interpolation using B-splines Interpolation using METAPOST Periodic interpolation using METAPOST The catenary and its curvature A spiral curve The σ(t) function for n = The σ k (t) basis functions for n = The σ(t) function for n = The σ k (t) basis functions for n = The σ(t) function for n = The σ(t) function for n = A circle drawn by METAPOST and harmonic interpolation xi

14 xii List of figures 3.8 A circle drawn by B-spline and harmonic interpolation A 7 sided polygon drawn by METAPOST and harmonic interpolation A 7 sided polygon drawn by B-spline and harmonic interpolation A 5 sided polygon drawn by METAPOST and harmonic interpolation A 5 sided polygon drawn by B-spline and harmonic interpolation A 4 point polygon drawn with trigonometric and harmonic interpolation D curves drawn with trigonometric and harmonic interpolation Curvature plot of figure Curvature plot of figure Curvature plot of figure Curvature plot of an eight sided figure Stability of harmonic interpolation Nonuniform harmonic interpolation of seven points A 7 sided polygon drawn by non-uniform and uniform harmonic interpolation A 5 sided polygon drawn by non-uniform and uniform harmonic interpolation An 8 sided polygon drawn by non-uniform and uniform harmonic interpolation Example parametric surfaces Example Bézier surface patches A surface constructed from piecewise continuous Bézier patches [13] A Bézier triangle control mesh B-spline surface fitting: curve network (after [90]) Stages in subdivision using Chaikin s scheme Stages in interpolatory subdivision using the 4-point scheme Notation for Loop subdivision Triangle subdivision for Loop subdivision (after [45]) Masks for Loop subdivision First four steps of a cube subdivided with Loop subdivision First four steps of a star shape subdivided with Loop subdivision Limit surfaces (Loop subdivision) Masks for modified butterfly subdivision (after [1]) First four steps of a cube subdivided with modified butterfly subdivision

15 List of figures xiii 4.16 First four steps of a star shape subdivided with modified butterfly subdivision Limit surfaces (Modified butterfly subdivision) Masks for 3 subdivision (after [1]) Triangle subdivision for 3 subdivision (after [45]) First four steps of a cube subdivided with 3 subdivision First four steps of a star shape subdivided with 3 subdivision Limit surfaces ( 3 subdivision) Masks for interpolating 3 subdivision Subdivision for the Catmull-Clark scheme (after [1]) First four steps of a triangulated cube subdivided with Catmull- Clark subdivision First four steps of a cube subdivided with Catmull-Clark subdivision First four steps of a triangulated star shape subdivided with Catmull-Clark subdivision First four steps of a star shape subdivided with Catmull-Clark subdivision Limit surfaces (Catmull-Clark subdivision) First four steps of a triangulated cube subdivided with Doo- Sabin subdivision First four steps of a cube subdivided with Doo-Sabin subdivision First four steps of a triangulated star shape subdivided with Doo-Sabin subdivision First four steps of a star shape subdivided with Doo-Sabin subdivision Limit surfaces (Doo-Sabin subdivision) Subdivision of the mannequin head Tensor product harmonic surfaces Stages in harmonic subdivision Stages in subdivision to produce a torus Stages in subdivision to produce a deformed torus Stages in subdivision to produce a stretched Application of theorems 5.1 and 5.3 (with m = 1) Sphere fitting using algorithm Failed sphere fitting using algorithm Failed surface fitting using algorithm Surface fitting using harmonic tensor product surfaces (mannequin) Surface fitting using harmonic tensor product surfaces (Spock). 153

16 xiv List of figures 5.12 Surface fitting using harmonic tensor product surfaces (sphere) Geometry image (Spock) Surface produced by spherical geometry image (mannequin) Surface produced by harmonic interpolation (mannequin) Surface produced by geometry image after smoothing (mannequin) Surface produced by harmonic interpolation after smoothing (mannequin) Octahedron geometry image Harmonic surface produced using octahedron geometry image (mannequin) Flattened octahedron geometry image (one side only) Surface fitting using harmonic tensor product surfaces Surface fitting using harmonic tensor product surfaces Surface fitting using harmonic tensor product surfaces Surface fitting using harmonic tensor product surfaces of resampled data set A scanline-rendered harmonic surface (torus) A raytraced harmonic surface (torus) Approximation of harmonic tensor product surface Bézier patches used to approximate figure Final rendering of mannequin head formed from Bézier patches Final rendering of Spock formed from Bézier patches Comparison of plane and harmonic surface Comparison of partial sphere and harmonic surface Comparison of torus and harmonic surface Comparison of sphere and harmonic surface Comparison of Moëbius strip and harmonic surface Comparison of surface of revolution and harmonic surface Comparison of shell and harmonic surface Comparison of another shell and harmonic surface Comparison of partial Klein bottle and harmonic surface Comparison of overhand knot and harmonic surface Comparison of Solomon s Seal knot and harmonic surface Comparison of Solomon s Seal knot (higher sampling rate) and harmonic surface Comparison of periodic surface of revolution and harmonic surface

17 List of Tables 4.1 Comparison of subdivision schemes Performance of surface fitting algorithm. GI=Time for geometry image, HI=Time for harmonic interpolation xv

18 xvi List of tables

19 Notation xvii Notation N Z R R n C the set of natural numbers the set of integers numbers the set of real numbers the Cartesian product space, i.e. R n = { (x 0, x 1,..., x n 1 ) x j R } j = 0, 1,..., n 1 the set of complex numbers (of the form a + bi) i = 1, an imaginary number i M T transpose of the matrix M. M determinant of the matrix M. c complex conjugate of c C. x = ( x 0 x 1... ) T x n 1 column vector x R n x T row vector x R n x the norm of x, x = x, x x, y The inner product of x and y x y The dot product, an inner product defined by n 1 x ky k, where x, y R n x y The cross product of x R 3 and y R 3, x y is perpendicular to both x and y [0, 1] unit interval δ jk Kronecker delta, 1 if j = k, 0 otherwise I n n n identity matrix t curve parameter u, v surface parameters C k continuity of a curve or surface G k geometric continuity of a curve or surface

20 xviii Notation

21 Chapter 1 Introduction The representation of objects in computer graphics influences many aspects of the rendered image. The choice of representation can influence the speed of rendering. storage size. accuracy of surfaces to be represented. ease of modelling. Polygons are commonly used for rendering when high speed is needed, but require extensive time and effort to model objects. Polygonal objects, such as the example in figure 1.1, do not exhibit the smooth qualities we associate with many objects. In many situations smooth surfaces are more desirable, since smooth surfaces are more common in the objects we wish to model. Parametric surfaces such as Bézier patches provide smooth surfaces and provide flexible operations on these surfaces. The surface can be stored in a compact representation in comparison to the amount of data required to store a smooth surface in polygonal form. The choice of smooth surface representation also influences which objects can be represented, and how easily a surface can be constructed to fit a set of data points. The problem of finding a surface that interpolates or fits a set of data is a well known problem. However, few curves or surfaces are designed to interpolate a set of data. For example, the Bézier curve in figure 1.2 does not interpolate all of the points that describe the curve. For most representations we have to solve the problem of finding a curve or surface that interpolates the data when it would not normally do so. Being able to interpolate data is valuable for a number of applications, one of the most prominent applications in computer graphics is surface fitting of a scanned model. Using 3D-scanning, we would hope to 1

22 2 Chapter 1. Introduction Figure 1.1: An example of a polygonal object. x 1 x 0 x 3 x 2 Figure 1.2: A Bézier curve does not interpolate all of its control points.

23 1.1. Problem 3 Figure 1.3: An unorganised set of points provided by Hoppe [35]. be able to reconstruct surfaces quickly. This problem has been solved, for example Hoppe discussed a solution in his PhD thesis [35]. Being able to reconstruct the surface from unorganised points such as those illustrated in figure 1.3 is an important technique required for reverse engineering, namely to reconstruct a physical object in the computer given a set of points on the surface. 1.1 Problem The problem that we wish to address in this thesis, is how to construct a periodic curve to interpolate a set of data points without solving a system of equations numerically. In other words, we need to find a curve that passes through the provided points in a pleasing fashion, by the very nature of the curve. Harmonic interpolation [71] solves this problem by applying the Fourier transform to permutation matrices to obtain periodic interpolation. This thesis investigates the properties of harmonic curves. In particular we consider problems of harmonic interpolation, the quality of the curves and surfaces produced, and the performance of harmonic interpolation. The problem of interpolation is well studied and we compare our results to some of the previous results in computer graphics. To do this we discuss existing representations of curves, and transforms on these curves. The material discussed includes the Fourier transform and Bézier curves. Since Bézier curves and B-splines are a popular representation, we concentrate our

24 4 Chapter 1. Introduction efforts in the comparison to these types of curves. Furthermore, we would like to extend our algorithm to interpolation of data points to produce a surface. We do not attempt to solve the surface fitting problem for surfaces of arbitrary topological type, but instead use some of the prior work for transforming surfaces to an alternative representation [29] that we can easily use. We discuss existing techniques and how they relate to our algorithm. In addition, we need an algorithm for representing such surfaces on a computer screen. We thus investigate different strategies for rendering these surfaces on the computer screen. 1.2 Pleasing curves Defining a pleasing curve is a difficult thing to do. There are many ways that we may judge curves as pleasing, but we need a suitable mathematical tool to quantify pleasing. In this thesis, we define pleasing curves to be curves that are continuous, have low curvature (see section 2.15), and preferably a minimum of oscillation. Continuity and curvature can be measured analytically and oscillation is sometimes visible on the curvature plot of a curve. 1.3 Contributions The contributions of this thesis are: An extension of the work of Schuster [73] for the production of curves that interpolate an even number of data points. The curve produced is known as a harmonic interpolation of the data points. Proof of the affine invariance property of harmonic interpolation for the even case. Comparison to Bézier curves and B-spline curves. Algorithms to change the position and / or number of interpolation points, while still interpolating the original points. Construction of tensor product harmonic surfaces from unorganised points, assuming a topological structure. An approximation of harmonic tensor product surfaces with Bézier tensor product surfaces.

25 1.4. Layout of Thesis 5 To our knowledge, this work has not been done before. The contributions allow us to quickly construct an interpolating surface from a set of points in terms of Bézier patches, so that most computer graphics software will be able to import the surface. The link to geometry images [29] allows a wide variety of surfaces to be represented. 1.4 Layout of Thesis We will begin by discussing the background necessary for producing curves in chapter 2. This chapter will also discuss common curve representations with an emphasis on periodic interpolation. We also discuss important properties of curves. In chapter 3 we introduce harmonic interpolation [71] as a technique to interpolate points in a periodic fashion. We then show how an equivalent technique can be developed for an even number of points. Important properties of harmonic interpolation in both the even and odd cases are proved. We also include a comparison of B-splines and Bézier curves to harmonic interpolation. We turn our attention to surfaces and surface fitting in chapter 4. We discuss existing smooth surface construction techniques, but do not provide an exhaustive list. The techniques selected are chosen to illustrate some of the techniques available for surface fitting, in particular we introduce the techniques of tensor product surfaces and subdivision surfaces and determine if these techniques can be applied to harmonic interpolation. A few select algorithms are provided in each case to try to illustrate the difficulties encountered with these techniques and whether harmonic interpolation suffers from similar problems. We proceed to discuss surfaces produced by harmonic interpolation in chapter 5. We then produce a simple (and restricted) yet quick algorithm to produce harmonic surfaces from unorganised points, assuming a topology for the data. Finally we discuss rendering and an approximate representation of harmonic surfaces in terms of Bézier surfaces. Chapter 6 summarises the results and illustrates the techniques discussed. Colour pictures for many of the figures are provided at the end of the thesis in the Colour Plates section.

26 6 Chapter 1. Introduction

27 Chapter 2 Background In this chapter we discuss existing curves and interpolation techniques. A few of the important properties that we desire for curves are introduced and proven where necessary. In particular we examine continuity and affine invariance. Affine invariance is of particular importance for the simple manipulation of curves and surfaces. Many of the results are required for later discussions in chapter 3. The discussion is by no means meant to be exhaustive, we discuss primarily curves that will be of interest to us later on, and variations of these curves. Refer to the books by Buss [6] and Watt & Watt [90] for a more comprehensive treatment. In the next section we introduce transformations for manipulating curves, and then we proceed to discuss some of the more popular curves and splines in computer graphics. Before we do that, we discuss some issues of notation. 2.1 Vector Spaces A vector space V is a set on which the operations of addition and scalar multiplication are defined. The set V associated with the operations of addition and scalar multiplication is said to form a vector space if the following axioms are satisfied: If x V and y V then x + y V. x + y = y + x. x + (y + z) = (x + y) + z. There is a zero vector (0) in V such that 0 + x = x + 0 = x for all x V. 7

28 8 Chapter 2. Background For each x V, there is a x V, called the negative of x such that x + ( x) = ( x) + x = 0. if α is any scalar and x V, then αx V. α(x + y) = αx + αy. (α + β)x = αx + βx. α(βx) = (αβ)(x). 1x = x. Here we consider the vector space V = R n, in particular for n = 2 and n = 3. We consider the vectors as column vectors. Thus x T denotes a row vector, where T is the transpose. We can define a scalar product in R n as x, y := x y = x T y = x i y i. We will also use the vector norm defined as the Euclidean distance x = x, x. We will typically work with the vector spaces R 2 and R 3. The operators in R 2 (the extension to R 3 is similar) are i=0 ( x 0 x 1 ) T + ( y0 y 1 ) T := ( x0 + y 0 x 1 + y 1 ) T, α ( x 0 x 1 ) T := ( αx0 αx 1 ) T, where x = ( x 0 x 1 ) T and y = ( y0 y 1 ) T are vectors in R 2 and α R. 2.2 Points and Vectors In the following, we will be referring to points and vectors in R 2 and R 3. Vectors and points differ. Vectors are quantities with magnitude and direction. Points are locations in the Cartesian space. The points can be represented by vectors, indicating the direction and distance from the origin of the Cartesian plane. However, we will often use points as if they were vectors, and vectors as if they were points. To represent a point in R 3 we will use the

29 2.3. Affine Transformations 9 format ( ) T x 0 x 1 x 2 which is the vector representing the location of the point relative to the origin. Similar notations will be used for points in other dimensions, for example in R 2 we write a vector as ( ) T x 0 x 1. We will need to multiply by matrices, so we use the column vector form. The column vector form of the vector x R 3 is given by x 0 x = x 1 = ( ) T x 0 x 1 x 2. x 2 Thus we consider x as a column vector. Thus x T is a row vector. Then x = ( ) T x 0 x 1 x 2, where T denotes the transpose. Line segments can now be defined by two points. The line segment is the portion of the line passing through the two points that is between the two points. Applying n n matrices to vectors in R n leads us to affine transformations. 2.3 Affine Transformations Introduction and Definitions We would like to be able to transform a curve or surface and not be forced to manually calculate the new curve or surface. For example, during an animation sequence, we would like to be able to rotate an object, continuously changing the camera angles and render the object accordingly. Affine transformations will allow us to do this. We first introduce transformations, and in particular affine transformations, and then proceed to show one of the properties of a parametric curve that is very useful to have. A transformation on R n is any mapping A : R n R n. That is, each point x R n is mapped to a unique point, A(x), also in R n. We are interested in certain kinds of transformations, the first of which is linear transformations. Definition 2.1. Let A : R n R n be a transformation. A is a linear transformation if and only if (a) For all α R and all x R n, A(αx) = αa(x). (b) For all x, y R n, A(x + y) = A(x) + A(y). This implies that A(0) = 0 since A(0 x) = 0 A(x). An example of a linear transformation is the identity transformation given by I(x) = x. It is easy to verify that the identity transformation satisfies requirements (a) and (b). Another transformation that is important to us, is translation.

30 10 Chapter 2. Background Definition 2.2. A transformation A is a translation if there exists u R n so that for all x R n, A(x) = x + u. A translation moves all vectors or points by a fixed distance, in a fixed direction. We can now proceed to define an affine transformation. Definition 2.3. An affine transformation is a transformation that can be written as A(x) = T (L(x)) where L is a linear transformation and T is a translation. This can also be written as A = T u L A(x) = L(x) + u. If A is an affine transformation then u and L are uniquely determined by A. From this point on, we discuss points in R 3 because these are the most common points that we are interested in. Most of the discussion is equally relevant to other dimensions. A linear transformation can be written in matrix form. For example, scaling is given by s 0 0 S = 0 s s for points in R 3. To scale a point we apply the matrix to the point u R 3, u = ( u 0 u 1 u 2 ) T to get u 0 s 0 0 u 0 su 0 Su = S u 1 = 0 s 0 u 1 = su 1. u s u 2 su 2 Translations cannot be written as 3 3 matrices, however. To allow a single representation (matrices) for affine transformations, we introduce the homogeneous coordinate system. Definition 2.4. If u 0, u 1, u 2, w R and w 0, then ( u 0 u 1 u 2 w ) T a homogeneous coordinate representation of the point ( u 0 /w u 1 /w u 2 /w ) T. ( u0 u 1 u 2 0 ) T, are so called points at infinity, and are often used to represent vectors. We now have separate representations for points and vectors. Points have the form ( u 0 u 1 u 2 w ) T with w 0. Vectors have the form ( u0 u 1 u 2 0 ) T. The homogeneous representation allows us to represent an affine transformation is

31 2.3. Affine Transformations 11 as a matrix. For example, to rotate by an angle θ around an arbitrary axis specified by the unit vector u = ( u 0 u 1 u 2 ) T we can apply the transformation (1 c)u c (1 c)u 0 u 1 su 2 (1 c)u 0 u 2 + su 1 0 R θ,u := (1 c)u 0 u 1 + su 2 (1 c)u c (1 c)u 1 u 2 su 0 0 (1 c)u 0 u 2 su 1 (1 c)u 1 u 2 + su 0 (1 c)u c with c = cos θ and s = sin θ. Translations can also be applied with homogeneous coordinates, a translation by u = ( u 0 u 1 u 2 ) T is given by u 0 T u = u u It is clear that points will be translated by T, but T v = v where v is a vector of the form ( v 0 v 1 v 2 0 ) T. Any linear transformation can be represented by a matrix of the form [6] a b c 0 L = d e f 0 g h i Rotation is clearly a linear transformation. Affine transformations can be represented as a combination of a linear transformation and a translation. Any affine transformation can be represented by A = T L. Now that affine transformations have been introduced, we can discuss an important property of smooth curves, namely affine invariance Affine Invariance Given a curve defined by f k (t)x k, t [0, 1] we would like to investigate what happens when an affine transformation is applied to the curve. It would be desirable if the affine transformation applied to points generated by the curve, produces precisely the same curve

32 12 Chapter 2. Background as transforming the points x k and then calculating the resulting curve. If the curve has this property, that is A f k (t)x k = f k (t)ax k, then the curve is said to be affine invariant [90]. If the basis functions f k (t) of the curve satisfy the property n 1 f k(t) = 1 for t [0, 1] then the curve is affine invariant. Theorem 2.1. Let C be a curve defined by f k (t)x k, t [0, 1] with the basis functions f k (t) a partition of unity, that is f k (t) = 1, t [0, 1], then C is affine invariant. That is, for any affine transformation A = T L where L is a linear transform and T is a translation by u we have A f k (t)x k = f k (t)ax k. Proof. We provide the proof by Buss [6]. We begin with the affine transformation applied to each point of the curve: A f k (t)x k = L = = ( n 1 ) f k (t)x k + u ( n 1 ) Lf k (t)x k + u, by definition 2.1(b) ( n 1 ) f k (t)lx k + u, by definition 2.1(a)

33 2.4. Lagrange Interpolation 13 Using the property n 1 f k(t) = 1 of the basis functions we get ( n 1 ) A f k (t)x k = f k (t)lx k + f k (t) u as required. n 1 = (f k (t)lx k + f k (t)u) n 1 = f k (t) (Lx k + u) n 1 = f k (t)ax k We now have one of the most significant properties for parametric curves at our disposal, so we will discuss some common parametric curves and indicate if this property holds or not. Another property, relating to the convex hull of a curve, will be presented in a later section. 2.4 Lagrange Interpolation Perhaps the simplest form of interpolation is Lagrange interpolation [68]. Lagrange interpolation is given by n q(t) = L n k(t)x k, with L n k(t) = n j=0 j k (t t j ) (t k t j ), where t j are the parameter values at which the values x k should be interpolated. The basis functions L n k (t) are cardinal. That is L n k(t j ) = δ j,k, where δ j,k is the Kronecker delta given by { 0, j k δ j,k = 1, j = k.

34 14 Chapter 2. Background y 1 L 1 L u L 2 L 3 Figure 2.1: Basis functions for uniform Lagrange interpolation of degree 3. The functions L n k (t) are a partition of unity. Thus curves produced by Lagrange interpolation are affine invariant. However, Lagrange interpolation does not satisfy the convex hull property, described later. If t j = j, j Z, then we have uniform Lagrange interpolation. The uniform Lagrange interpolation basis functions are shown in figure 2.1. Points on the curve can be efficiently calculated using Neville s algorithm [68]. Example 2.1. An example of Lagrange interpolation is shown in figure 2.2. The coordinates for interpolation are given by x 0 = ( 1 1 ) T x 1 = ( 2 3 ) T x 2 = ( 4 1 ) T x 3 = ( ) T t 0 = 0 t 1 = 1 t 2 = 2 t 3 = 3 A significant problem with Lagrange interpolation, is oscillation. Figure 2.2 begins to show this behaviour, we see that the curve extends a fair distance beyond x 1 and x 2. Typically we would like the curve to be more confined. By confined, we mean that the area of the convex hull of the curve should not be much greater than the area of the convex hull of the control points. In the next sections we discuss some of the more popular curves and how they may be used to interpolate points.

35 2.5. Bézier Curves 15 x 1 x 0 x 3 x 2 Figure 2.2: Uniform Lagrange interpolation of 4 points. 2.5 Bézier Curves Bézier curves [3] are one of the most popular representations for curves. Most of the common curves can be represented as Bézier curves. A Bézier curve of degree n is given by n q(t) = Bk n (t)x k, (2.1) where the functions Bk n (t) are the Bernstein polynomials defined by ( ) n Bk n (t) := t k (1 t) n k. (2.2) k The most popular Bézier curves, are Bézier curves of degree 3. The basis functions for degree 3 Bézier curves are displayed in figure 2.3. Bézier curves interpolate the end points x 0 and x n. The Bernstein polynomials have a number of useful properties. These properties are discussed in the following sections Affine Invariance The Bernstein polynomials are a partition of unity, in other words n Bk n (t) = 1. This is easily seen by application of the Binomial theorem [86]: n n ( ) n Bk n (t) = t k (1 t) n k = (t + (1 t)) k = 1. k

36 16 Chapter 2. Background y 1 B 0 B 3 B 1 B t Figure 2.3: Basis functions for Bézier curves of degree 3. x 1 x 1 x 3 x 0 x 3 x 0 x 2 (a) The curve x 2 (b) The convex hull Figure 2.4: A Bézier curve and its convex hull From theorem 2.1 it is clear that Bézier curves are affine invariant. Figure 2.4(a) shows an example of a Bézier curve Convex Hull To describe a convex hull, we need the definition of a weighted average, a weighted average of a set of points x k is given by n α k x k, with n α k = 1 and α k 0. It is easy to see from figure 2.3, and in general, that 0 Bk n (t) 1 for t [0, 1]. A point on the Bézier curve

37 2.5. Bézier Curves 17 q(t) = n Bn k (t)x k is thus a weighted average [6] of the points x k. The convex hull of the curve q(t) is the set of all weighted averages of x k. The Bézier curve thus lies in the convex hull of the points x k. The convex hull is easily defined by a polygon created from the points x k (not necessarily in order). This will prove useful when considering how to draw Bézier curves and surfaces. The convex hull of the Bézier curve illustrated in figure 2.4(a) is illustrated in figure 2.4(b) Derivative at Edges The derivative with respect to the parameter t of equation 2.1 is q (t) = = = = n B k(t)x k n ( ( d n dt k n ( n n )t k (1 t) n k ) x k ) (kt k 1 (1 t) n k t k (n k)(1 t) n k 1 )x k k ( ) n kt k 1 (1 t) n k x k k n ( ) n t k (n k)(1 t) n k 1 x k. k In the sum on the right hand side, the term given by k = n is 0, q (t) = n ( ) n ( ) n kt k 1 (1 t) n k x k t k (n k)(1 t) n k 1 x k k k and once again on the left hand side, the term given by k = 0 is 0. Thus q (t) = k=1 n ( ) n ( ) n ku k 1 (1 t) n k x k t k (n k)(1 t) n k 1 x k. k k We alter the index in the left hand sum to begin at zero, ( ) n q (t) = (k + 1)t k (1 t) n k 1 x k+1 k + 1 ( ) n t k (n k)(1 t) n k 1 x k. k

38 18 Chapter 2. Background To simplify the expression we note that ( ) ( ) n n 1 (k + 1) n k + 1 k and so that ( ) ( ) n n 1 (n k) n k k ( ) n 1 q (t) = n t k (1 t) n k 1 x k+1 k ( ) n 1 n t k (1 t) n k 1 x k k ( ) n 1 = n t k (1 t) n k 1 (x k+1 x k ) k n 1 = n B n 1 k (t)(x k+1 x k ). (2.3) Hence the derivative of a Bézier curve is also a Bézier curve. Furthermore, we have q (0) = n(x 1 x 0 ) and q (1) = n(x n x n 1 ). (2.4) Thus we have an immediate form for the derivative at the end points. This will prove to be useful in defining curves that are piecewise continuous Piecewise Continuous Bézier Curves We can construct Bézier curves of arbitrary degree. However, it becomes more difficult to control the curve since the Bézier curve is only guaranteed to interpolate the end points. Instead, it is often sufficient to create several Bézier curves that are piecewise continuous. That is, the curves are continuous, and at the points where they join, there is continuity. There are different kinds of continuity that can be considered. Definition 2.5. Let k 0. A function f(u) is C k continuous if f has the k th derivative defined and continuous everywhere in the domain of f. C 0 continuity is simply the usual definition of continuity. f is C continuous if f is C k continuous for all k 0.

39 2.5. Bézier Curves 19 Definition 2.6. A function f(u) is G 1 continuous provided f is continuous and there is a function t = t(u) that is continuous and strictly increasing such that the function g(u) = f(t(u)) has continuous, nonzero first derivative everywhere in its domain. Usually we will use C 1 continuity, but G 1 continuity sometimes offers better control. It is easy to see that we can obtain C 1 continuity between two Bézier curves q(t) and r(t) defined as q(t) = n Bk n (t)q k and r(t) = n Bk n (t)r k by noting that q (1) = r (0) for C 1 continuity. Using equation 2.4, we require that q n q n 1 = r 1 r 0. For G 1 continuity we can require that q n q n 1 = s(r 1 r 0 ). We have assumed that q(t) will occur before r(t), as is demonstrated by our choice of control points. This example is easily adapted to Bézier curves of different degree. We can now construct a piecewise smooth curve (C 1 ) from m Bézier curves q j (t), j = 1,..., m, of degree n, by requiring that q j n q j n 1 = q j+1 1 q j+1 0, for j = 1,..., m 1. (2.5) The continuous curve can then be defined by q 1 (t m), t [0, 1 ) m q 2 (t m 1), t [ 1 Q(t) =, 2 ) m m. q m (t m (m 1)), t [ m 1, 1]. m The control points of Q(t) are simply the control points of q j (t), j = 1,..., m, with the restriction 2.5. A C 1 piecewise smooth Bézier curve is illustrated in figure 2.5(a), and a G 1 piecewise smooth Bézier curve is illustrated in figure 2.5(b) with s = 0.6.

40 20 Chapter 2. Background p 2 s 2 p 2 s 2 p 1 p 1 p 3 /s 0 p 3 /s 0 p 0 p 0 s 1 s 1 s 3 (a) C 1 (b) G 1 s Rendering Figure 2.5: Piecewise continuous Bézier curves To render a Bézier curve q(t) we can simply choose a number of values t j [0, 1], j = 0,..., m, so that t j < t j+1 and render line segments from q(t j ) to q(t j+1 ). We usually select equally spaced t j. As m we get closer to the correct Bézier curve. Repeated evaluation of the Bernstein polynomial (equation 2.2) can be expensive. The next result can increase the speed at which points on Bézier curves can be evaluated. de Casteljau s Method de Casteljau s method [90] allows us to evaluate the points on a Bézier curve by repeated linear interpolation. If the control points of the curve are p i for i = 0, 1,..., n, which defines a Bézier curve of degree n, then we define p r i (t) := (1 t)p r 1 i with r = 1,..., n, i = 0,..., n r, and p 0 i (t) = p i. (t) + tp r 1 (t), (2.6) The Bézier curve is then given by q(t) = p n 0(t). The repeated linear interpolation as demonstrated in figure 2.6 is an efficient technique to draw Bézier curves. The figure illustrates a degree 3 Bézier curve, where de Casteljau s algorithm is used to calculate the point for t = 0.3. Dashed lines show the control polygon, and dark dashed lines connect the points between which repeated linear interpolation took place. Although de Casteljau s method can increase speed, we still do not know at how many points the Bézier curve need be evaluated to obtain acceptable results. The next section discusses how Bézier curves may be subdivided until a desired level of accuracy is obtained. i+1

41 2.5. Bézier Curves 21 p 1 p 2 p 0 p 3 Figure 2.6: de Casteljau s method Recursive Subdivision We now investigate a technique that allows us to break Bézier curves down into sub-portions until we have a curve that can be approximated by a line for the desired level of accuracy. If we have a Bézier curve q(t) of degree n, then q 1 (t) = q(t/2) and q 2 ((t + 1)/2) are both Bézier curves of degree n. We have then successfully divided the curve in two. Drawing a Bézier curve can now be achieved by recursively subdividing the Bézier curve in two until the portions of the Bézier curves are as close to a straight line as we need. One way to determine if the curve is close enough to a straight line, is to define an error value δ. If q(0.5) 1 2 (p 0 + p n ) < δ, (2.7) then we assume the distance from the curve to the line will be less than δ pixels, and can thus be approximated by a straight line segment. This test may fail on occasion, another test that can be used is to determine how far the interior points of the control polygon are from the line connecting the first and last control point. Now we prove that the two portions of the curve are indeed Bézier curves (from [6]). Theorem 2.2. Let q 1 (t) = q(t 0 t) and q 2 (t) = q(t 0 + (1 t 0 )t), where t 0 determines the parameter value at which the curve should be split. If t 0 = 0.5 then the curve is split in two in such a way that the parameter values are divided equally between the curves. If the curve is defined over t [0, 1] then

42 22 Chapter 2. Background the subdivided curve q 1 will be q defined over t [0, 0.5], and q 2 will be q defined over t [0.5, 1]. a) The curve q 1 (t) is equal to the degree n Bézier curve with control points p 0 0, p 1 0, p 2 0,..., p n 0. b) The curve q 2 (t) is equal to the degree n Bézier curve with control points p n 0, p n 1 1, p n 2 2,..., p 0 n. We use p j i as defined in equation 2.6. Proof. Only part (a) will be proven. We provide the proof by Buss [6]. We want to show that n q(t 0 t) = Bj n (t)p j 0(t 0 ). This is equivalent to showing that n Bi n (t 0 t)p i = i=0 = = j=0 n Bj n (t) j=0 n j=0 n i=0 j B j i (t 0)p i i=0 j Bj n (t)b j i (t 0)p i i=0 n Bj n (t)b j i (t 0)p i. In the last step, we just swapped the order of the summation as described in [44]. The coefficients of p i should be equal, so we must show that n Bi n (t 0 t) = Bj n (t)b j i (t 0). j=i Using the definition of the Bernstein polynomials (equation 2.2) we get ( ) n (t 0 t) i (1 t 0 t) n i = i n j=i ( n j j=i )( j i ) t j t i 0(1 t) n j (1 t 0 ) j i. We have the identity ( n j ( j)( i) n )( n i ( i j i) and dividing by n i) (t0 t) i on both sides gives n ( ) n i (1 t 0 t) n i = t j i (1 t) n j (1 t 0 ) j i. j i j=i

43 2.5. Bézier Curves 23 x 1 0 x 2 0 x 3 0 x 0 3 x 0 0 x 3 0 x 2 1 x 1 2 Figure 2.7: Subdivision of figure 2.4 into two Bézier curves. Thus we find n ( ) n i n i ( ) n i t j i (1 t) n j (1 t 0 ) j i = t j (1 t) n j i (1 t 0 ) j j i j j=i j=0 n i ( ) n i = (1 t) n j i (t t 0 t) j j using the binomial theorem. j=0 = ((t t 0 t) + (1 t)) n i = (1 t 0 t) n i This theorem provides us with the ability to subdivide a Bézier curve into two Bézier curves of the same degree. Furthermore, the parameter values for the two curves produced are still between 0 and 1. In addition, we can compute the new control points for these curves. Using the convex hull property or equation 2.7, we can subdivide the Bézier curves until the terminating criteria is satisfied. In this case we can draw a line from p 0 to p n. Figure 2.7 shows the result when figure 2.4 is subdivided. We now have an efficient technique for drawing Bézier curves. In the next section, we consider the effect of homogeneous coordinates on Bézier curves Rational Bézier Curves A Bézier curve is rational if its control points are specified by homogeneous coordinates. If we define the Bézier curve in terms of homogeneous coordinates, then each control point x k becomes ( ) T w k x k w k. The Bézier curve is then given by n q(t) = Bk n (t) ( ) T w k x k w k.

44 24 Chapter 2. Background x 0 = (0, 1) w 0 = 1 x 1 = (2, 1) w 1 = 1 3 x 3 = (0, 1) w 3 = 1 x 2 = (2, 1) w 2 = 1 3 Figure 2.8: Section of a circle, drawn with a rational Bézier curve. The point q(t) is also a homogeneous coordinate. The point that q(t) represents is given by n w kbk n(t)x k n w kbk n(t). The w k terms act as weighting factors, and specify how much influence a point has on the curve. The extra weighting factors allows us to draw conic sections, which we are unable to do with conventional Bézier curves. The books by Farin [24] and Lasser [38] provide more details regarding rational Bézier curves Bézier Curves: Conic Sections Rational Bézier curves can be used to draw conic sections. In this section we briefly illustrate how a segment of a circle can be drawn using a rational Bézier curve of degree 3. Figure 2.8 shows the right side of a circle and the control points required to draw the curve. 2.6 Catmull-Rom Splines Catmull-Rom splines [9] interpolate the control points x 1,..., x n 1 using piecewise degree 3 Bézier curves. For Catmull-Rom splines the parameter values are chosen so that t [0, n] and q(i) = x i for i = 1,..., n 1. The interpolation points are placed at parameter values t i = i. The derivatives of the curve at each point are approximated by the line joining the previous and next point. We define l i := 1 2 (x i+1 x i 1 ). (2.8)

45 2.7. Bessel-Overhauser Splines 25 We then define x + i := x i l i and x i := x i 1 3 l i. The segment of the curve is defined by a Bézier curve of degree 3 with control points x i, x + i, x i+1, and x i+1. The curve is piecewise continuous by construction. 2.7 Bessel-Overhauser Splines If the control points for a Catmull-Rom spline are not placed uniformly then curves are not always as smooth as we would expect. This is because equation 2.8 does not take into account the distance between the control points. So, the larger the distance between the control points, the greater the velocity, causing apparent overshoots to occur. If we place the control points at nonuniform parameter values t i, then this effect can be reduced. We define v i+ 1 2 := x i+1 x i t i+1 t i, and v i := (t i+1 t i )v i 1 + (t i t i 1 )v 2 i t i+1 t i 1 The interpolation points are defined much the same as with Catmull-Rom splines except we change the definition of x + i and x i to x + i := x i (t i+1 t i )v i and x i := x i 1 3 (t i t i 1 )v i. With suitable choices for t i, the resulting curve is pleasing even when control point distance varies. 2.8 Tension-Continuity-Bias Splines Catmull-Rom splines don t give much control over the curvature at interpolation points. To improve the control we can introduce tension, continuity and bias controls to affect the tangents and the x + i and x i control points. We introduce left and right first derivatives for an interpolation point x i as follows: Dx i Dx + i := lim t t i := lim t t + i q(t i ) q(t) t i t = 3(x i x i ), q(t) q(t i ) t t i = 3(x + i x i ).

46 26 Chapter 2. Background We can now determine values for x + i and x i using the above equations to get x + i = x i Dx+ i and x i = x i 1 3 Dx i. For Catmull-Rom splines Dx and Dx + are defined by Dx + i := 1 2 (v i 1 + v 2 i+ 1 ) 2 Dx i := Dx + i, where v i 1 = p i p i 1 and v 2 i+ 1 = p i+1 p i. To obtain more control we 2 add a parameter t to control the tension, or tightness of the curve. We also introduce a continuity parameter c. If c = 1 then the curve is continuous. Lastly, we introduce a bias parameter b. The bias parameter weights v i 1 2 differently to cause overshoot or undershoot. The final formula for and v i+ 1 2 tension-continuity-bias splines is then Dx (1 t)(1 c)(1 + b) (1 t)(1 + c)(1 b) i = v 2 i 1 + v 2 2 i+ 1 2 Dx + (1 t)(1 + c)(1 + b) (1 t)(1 c)(1 b) i = v 2 i 1 + v 2 2 i These parameters can be applied globally to the entire curve, or locally to certain interpolation points. We have discussed a variety of piecewise continuous curves that are G 1 or C 1. Next we consider cubic curves that are piecewise continuous (C 2 ) by design. 2.9 Uniform B-Splines Piecewise continuous Bézier curves have C 1 continuity as we have defined them. We now investigate piecewise continuous cubic curves, since these are the most common. It is possible to follow a similar process to derive B-splines of higher degree. We aim to produce curves that are C 2. The ith segment in the cubic B-spline will be denoted by q i. Four control points specify the curve. The control points are x i, x i+1, x i+2 and x i+3. We have assumed that the cubic spline will share control points. We begin by considering the curve q i with basis functions B k (t) and control points x i, x i+1, x i+2 and x i+3. The curve is given by 3 q i (t) = B k (t)x i+k.

47 2.9. Uniform B-Splines 27 The curve q i+1 (t) is defined similarly. We want to define the basis functions B k (t) so that we have C 0, C 1 and C 2 continuity between adjacent curves. For C 0 continuity we require that It follows that q i (1) = q i+1 (0). 3 B k (1)x i+k = 3 B k (0)x i+k+1. The control points can take on arbitrary values so the coefficients of the control points should be equal. Requiring C 1 and C 2 continuity we get B 0 (1) = 0 B 0(1) = 0 B 0(1) = 0 B 1 (1) = B 0 (0) B 1(1) = B 0(0) B 1(1) = B 0(0) B 2 (1) = B 1 (0) B 2(1) = B 1(0) B 2(1) = B 1(0) B 3 (1) = B 2 (0) B 3(1) = B 2(0) B 3(1) = B 2(0) 0 = B 3 (0) 0 = B 3(0) 0 = B 3(0). So we have 15 equations in 16 unknowns. We need an extra constraint to solve the system of equations. Since the affine invariance property is useful, we require that 3 B k(0) = 1. Solving the system of equations yields B 0 (t) = 1 (1 t)3 6 B 1 (t) = 1 6 (3t3 6t 2 + 4) B 2 (t) = 1 6 ( 3t3 + 3t 2 + 3t + 1) B 3 (t) = 1 6 t3. The basis functions for each curve segment is shown in figure 2.9. This is the definition for one segment. We will have several segments placed in sequence and use a parameter T to define the curve globally, and t will be used to determine the local parameter for a segment. We thus have T [0, n 2], where there are n control points, and t = T i for a particular segment. We can now define the blending functions that will be used throughout the

48 28 Chapter 2. Background curve: B 3 (t 0 ), i 3 T < i 2 B 2 (t 1 ), i 2 T < i 1 N i (T ) = B 1 (t 2 ), i 1 T < i B 0 (t 3 ), i T < i + 1 0, otherwise. We have to select an appropriate t j for the basis functions. t j is calculated from the global parameter T by t j = T i+3 j. We can see that the correct basis functions are selected by noting that N 0 (t) = B 0 (t 3 ) for t [0, 1], and N 1 (t) = B 1 (t 2 ), and so forth. The entire curve can now be defined as q(t) = n N i (t)x i, t [0, n 2]. i=0 The maximum parameter is clearly n 2 since each segment i is defined by the control points x i, x i+1, x i+2 and x i+3. So the last segment is segment n 3, and the last value of T with nonzero value for N n 3 (T ) is the maximum T such that n 3 T < n so that T < n 2. The blending functions are illustrated in figure It is interesting to note that the support of each of the functions N i is (i, i + 4). We only need to calculate the contribution of the blending functions with nonzero value for a particular value of t. The curve can then be defined by j+3 q(t) = N i (t)x i, t [j, j + 1], 0 j n 3. i=j This indicates that there is a large degree of local control. In other words, it is possible to edit one portion of a curve without influencing remote portions of the curve. Figure 2.12 illustrates a cubic B-spline. The usefulness of B- splines is apparent in comparison to the Bézier curve of high degree (using the same control points) illustrated in figure We now turn our attention to the properties of the blending functions Affine Invariance For B-splines to be affine invariant, we need the blending functions to be a partition of unity. That is n N i (t) = 1. i=0

49 2.9. Uniform B-Splines 29 We note that the blending functions are translates of each other. This means N i (t) = N 0 (t i). We also note, once again, the local support of the functions N i (t). So, for a particular value of t, there are only four blending functions that are (possibly) nonzero. These functions are translates of each other, and therefore, they must be the four basis functions. We expect this because of the construction of the curve from piecewise continuous segments. We simply compute the sum of the basis functions to find B 0 (t) + B 1 (t) + B 2 (t) + B 3 (t) = 1 6 (1 t) (3t3 6t 2 + 4) ( 3t3 + 3t 2 + 3t + 1) (t3 ) = 1 6 (1 3t + 3t2 t 3 ) (3t3 6t 2 + 4) ( 3t3 + 3t 2 + 3t + 1) t3 = Convex Hull It is clear from figure 2.10, that the blending functions are such that N i (t) 0. All points on the curve are weighted averages of the control points. Thus the control points form the convex hull for the curve Cox-de Boor Formula For Bézier curves we have the de Casteljau method to evaluate points on the curve without the need to evaluate the expensive Bernstein polynomials. In the case of B-splines the Cox-de Boor formula provides an efficient means to evaluate points on a B-spline. The Cox-de Boor formula is given by { 1, if t i t t i+1 N i,1 (t) = 0, otherwise. N i,k (t) = t t i N i,k 1 (t) + t i+k t N i+1,k 1 (t), t i+k 1 t i t i+k t i+1 for i = 0,..., n k and k = 2,..., d, where d is one more than the degree of the curve. The de Boor algorithm in [6] allows us to determine the points on a B-spline using repeated linear interpolation. The Cox-de Boor formula also applies to nonuniform B-splines. For uniform cubic B-splines we have t i = i, i Z and N i = N i,4 and the curve n 4 N i (t)x i. i=0

50 30 Chapter 2. Background y 2 3 B 1 B 2 B 0 B u Figure 2.9: The basis functions of B-splines of degree Non-Uniform B-Splines The distance between parametric values in a non-uniform B-spline differ from one parameter to the next. For nonuniform splines we create the knot-vector (t 0, t 1,..., t k ) which is used in the Cox-de Boor formula. We define 0/0 := 0 for the Cox-de Boor formula so that we can have knots with the same value. The support of N i,k is then (t i, t i+k ), where k 1 is the degree of the curve. Since n q(t) = N i (t)x i, t [0, n 2] i=0 and N i,k has support (t i, t i+k ), we need n + k + 1 knots in the knot vector. Each curve segment is defined by k control points: x i, x i+1,..., x i+k 1. The first segment is defined by x 0, x 1,..., x k 1 and the last segment is defined by x n k+1, x n k+2,..., x n. We thus have n k + 2 segments. We define n k +3 knots since we have n k +2 segments. However, there are n+k +1 knots in the knot vector. The remaining 2k 2 knots are usually obtained by repeating the first and last knot k 1 times each. The first and last knot then appear k times. Any knot with multiplicity k is interpolated. As a result, the spline interpolates the first and last control points. That is q(t k 1 ) = x 0 and q(t n+1 ) = x n. We thus define the curve for t [t k 1, t n+1 ]. If any knot values (other than the first or last) are duplicated, then continuity is reduced. This adds further power to the non-uniform B-spline representation.

51 2.10. Non-Uniform B-Splines 31 y u Figure 2.10: The blending functions of B-splines of degree 3. x 1 x 2 x 5 x 7 x 0 x 3 x 4 x 6 x 8 Figure 2.11: A Bézier curve of degree 8. x 1 x 2 x 5 x 7 x 0 x 3 x 4 x 6 x 8 Figure 2.12: A B-spline curve of degree 3, using the same control points as figure 2.11.

52 32 Chapter 2. Background 2.11 Interpolating with B-Splines Although B-splines do not interpolate their control points, it is possible to find a B-spline that interpolates the desired set of points. We will use a non-uniform cubic B-spline to interpolate the first and last points. We will assume uniform distribution of the remaining knots. Assume that we will use n + 1 control points. We know that multiplicity 4 is required at the end points. Since we are using cubic splines the curve is defined over [t 3, t n+1 ]. There is thus n 2 intervals (and thus n 2 segments that we will work with). We can thus interpolate a maximum of n 1 points. Interpolation will occur at the knot values t i. We need to solve for the control points x i, i = 0,..., n, of a B-spline curve, given the points to interpolate p i, i = 0,..., n 2. Since there are n 2 distinct segments, we have n 1 parameter values to work with to solve for n + 1 values. For the remaining constraints, we choose to make the first two, and last two, control points coincident, that is x 0 = x 1 and x n = x n 1. (2.9) We know that the support of the blending function N i,4 is (t i, t i+4 ). We can thus determine for a parameter value t i which functions contribute a nonzero value to the final point on the curve. We thus have q(t i ) = N i 3,4 (t i )x i 3 + N i 2,4 (t i )x i 2 + N i 1,4 (t i )x i 1, since N i 4,4 (t i ) = 0 and N i,4 (t i ) = 0. Rewriting this equation using i i + 3 we get q(t i+3 ) = N i,4 (t i+3 )x i + N i+1,4 (t i+3 )x i+1 + N i+2,4 (t i+3 )x i+2. We want the curve to interpolate the points p i at parameter values t i+3. Thus with p i = q(t i+3 ) = α i x i + β i x i+1 + γ i x i+2, α i = N i,4 (t i+3 ), β i = N i+1,4 (t i+3 ), γ i = N i+2,4 (t i+3 ). Since we are going to require multiplicity 4 at the end points so that the B-spline curve interpolates the end points, we have x 0 = x 1 = p 0 and x n = x n 1 = p n 2,

53 2.11. Interpolating with B-Splines 33 p 1 p 2 p 5 p 7 p 0 p 3 p 4 p 6 p 8 Figure 2.13: Interpolation using B-splines. taking into account the constraints 2.9. We rewrite the equations into matrix form to get 1 x 1 p 0 α 1 β 1 γ 1 x 2 p =.. α n 3 β n 3 γ n 3 x n 2 p n 3 1 x n 1 p n 2 All empty entries are 0. The matrix is tridiagonal so we can efficiently solve the equations [83]. Watt & Watt [90] explain the algorithm for efficient solving in detail. Figure 2.13 illustrates this technique for interpolating points. Interpolation using chord length parameterisation often provides better results. Watt & Watt [90] provide a heuristic that can be used to approximate chord length parameterisation, that is t i+4 t i+3 t i+5 t i+4 = x i+1 x i x i+2 x i+1. Another simpler heuristic is provided by Epstein [23], namely t i t i 1 = x i x i 1. Further heuristics are discussed by Farin [24].

54 34 Chapter 2. Background x 1 x 2 x 0 x 3 x 4 Figure 2.14: Periodic interpolation using B-splines Periodic Interpolation Periodic interpolation with cubic B-splines is in many ways simpler than non-periodic interpolation. In this case we will use a uniform cubic B-spline to interpolate the n + 1 points p 0,..., p n. We need n + 1 control points to interpolate periodically. As in the non-periodic case, we determine the functions that contribute a nonzero value to the curve to get with p i = q(t i+3 ) = α i x i + β i x i+1 + γ i x i+2, (2.10) α i = N i,4 (t i+3 ), β i = N i+1,4 (t i+3 ), γ i = N i+2,4 (t i+3 ), so that the curve interpolates at the knot values t i. The curve is usually defined over the range t [0, n 1]. However, this will not make the curve periodic. Since the interpolation is periodic, we need an extra segment to join the first and last point of the curve. The curve is thus defined over the range t [0, n]. The equations 2.10 must be applied in a periodic fashion, that is the subscripts are calculated modulo n + 1. The two equations that are influenced are given by and p n 1 = α n 1 x n 1 + β n 1 x n + γ n 1 x 0, p n = α n x n + β n x 0 + γ n x 1.

55 2.12. Non-Uniform Rational B-Splines 35 We rewrite the equations into matrix form to get α 0 β 0 γ 0 α 1 β 1 γ 1... α n 2 β n 2 γ n 2 γ n 1 α n 1 β n 1 β n γ n α n x 0 x 1. x n 2 x n 1 x n = p 0 p 1. p n 2 p n 1 p n. This matrix is not tridiagonal. We rewrite this equation into the form β n γ n α n x n p n α 0 β 0 γ 0 x 0 p 0 α 1 β 1 γ 1 x 1 p 1.. =.... α n 2 β n 2 γ n 2 x n 2 p n 2 γ n 1 α n 1 β n 1 x n 1 p n 1 Since the control points are periodic, the control points can be renumbered with no change in the curve produced. The above matrix is also not tridiagonal, but the equations can still be solved efficiently by using the techniques described by Watt & Watt[90]. We thus have periodic control points and the curve defined over t [nk, n + nk], k N, is the same as the curve defined over t [0, n]. An example of a periodic B-spline interpolating curve is shown in figure Non-Uniform Rational B-Splines Non-uniform rational B-splines (NURBS [25]) are non-uniform B-splines applied to control points specified by homogeneous coordinates. The curve is thus defined by q(t) = n N i,k (t) ( ) T w i x i w i, t [0, n 2]. i=0 The point that is represented by q(t) is then n i=0 w in i,k (t)x i n i=0 w in i,k (t) = n R i,k (t)x i, i=0

56 36 Chapter 2. Background with R i,k (t) = w i N i,k (t) n j=0 w jn j,k (t). The extra coordinate w i adds further flexibility to the curve and allows B- splines to represent conic sections. Razdan and Farin [69] describe interpolation with NURBS Trigonometric Interpolation In the previous sections, we discussed interpolating points using polynomial functions of a fixed degree. Now we consider trigonometric functions. As we will see later, harmonic interpolation is also a form of trigonometric interpolation. For standard trigonometric interpolation [32], we wish to find a function q(t) = (a k cos kt + b k sin kt), (2.11) such that q(t k ) = x k for k = 0,..., n 1. For simplicity we assume that t k is equally spaced on [0, 2π] (uniform interpolation) so that t k = 2πk/n. We can express this equation in terms of a single coefficient using the exponential form of complex numbers e it cos t + i sin t, and adding the constraint b k = ia k. The equivalent problem is then to find a function q(t) = c k e ikt, such that q(t k ) = x k for k = 0,..., n. Since e i(t+2π) = e it e 2πi = e it we have periodic interpolation. We now determine the coefficients c k. Let w := e 2πi/n so that e it k = w k. We now have x k = q(t k ) = c 0 + c 1 w k + c 2 w 2k + + c n 1 w (n 1)k. These equations hold for k = 0,..., n 1 so that we have n equations in n unknowns. Written in matrix form we have c 0 x 0 1 w w 2... w n 1 c 1 x 1 1 w 2 w 4... w 2(n 1) c 2 = x 2, w n 1 w 2(n 1)... w (n 1)2 c n 1 x n 1

57 2.13. Trigonometric Interpolation 37 or simply Ac = x. The components of A are A lm = w lm. To solve for c we calculate A 1 so that c = A 1 x. The inverse of A is given by which is easily seen by If i = j then If i j then (A 1 ) ij = 1 n w ij, (A 1 A) ij = (A 1 ) ik A kj = 1 w ik w kj = 1 w (j i)k. n n (A 1 A) ij = 1. (A 1 A) ij = 1 n 1 w(j i)n 1 w (j i) = 0, since w n = 1. Thus A 1 A = I. We have c k = 1 n m=0 w km x m = 1 n m=0 e 2πikm/n x m, which is the discrete Fourier transform of the points x k. If n = 2 m, then we can use the fast Fourier transform to determine c k quickly. Examining equation 2.11, we see that there are 2n unknowns. By using the exponential form of complex numbers we introduced further constraints. To avoid the use of complex numbers we can reduce the number of unknowns. If n is odd then equation 2.11 can be written as m q(t) = a 0 + (a k cos kt + b k sin kt), k=1 with n = 2m + 1. There are thus ((n 1)/2) = n unknowns and n equations if we require that q(t k ) = x k for k = 0,..., n 1. Once again we assume t j := 2πj. Jiaxing [39] shows that the solution to these equations is n a 0 = a k = b k = 1 2m m m + 1 2m j=0 2m j=0 2m j=0 x j, x j cos(kt j ), x j sin(kt j ), (2.12)

58 38 Chapter 2. Background so that q(t) = = = 1 2m m m + 1 ( 2m x j + 2 j=0 ( 2m x j + 2 j=0 2m j=0 x j (1 + 2 ( m 2m x j cos(kt j ) cos(kt) + k=1 2m j=0 j=0 k=1 ) m x j cos k(t t j ) 2m j=0 x j sin(kt j ) sin(kt) ) m cos k(t t j ). (2.13) k=1 We use the trigonometric identity (shown later in 3.12) m cos kt sin(m + 1)t 2 sin 1t, 2 and find that q(t) = = 1 n = 1 n k=1 1 2m + 1 j=0 j=0 2m sin ( (m )(t t j) ) sin 1(t t j=0 2 j) sin ( ( n 1 + 1)(t t 2 2 j) ) sin 1(t t 2 j) sin n 2 (t t j) sin 1 2 (t t j) x j, which is known as Lagrange trigonometric interpolation. We can also change the parameter to 2πu = t, u [0, 1], so that q(u) = j=0 x j sin πn(u j/n) n sin π(u j/n) x j. To see that 2.13 does interpolate the desired points (and thus that the expansion coefficients a k and b k are in fact the solution we are looking for), we note that if t = t j then m cos k(t j t j ) = 2m + 1, k=1 and if t t j (and t = t k, t j = 2πj n ) then sin n 2 (t k t j ) sin 1 2 (t k t j ) x j sin π(k j) sin π(l) = sin π = (k j) sin π = 0, (l) n n ))

59 2.14. METAPOST and Bézier Curves 39 where l = k j Z. Thus q(t j ) = x j. Newberry [63] discusses trigonometric interpolation for curve fitting and minimal degree trigonometric polynomials for interpolation in [62]. Newberry also shows how trigonometric polynomials can be used for curves in a general fashion, including approximation METAPOST and Bézier Curves METAPOST [34] is a useful tool for drawing diagrams. METAPOST will be used to draw many of the Bézier curves for comparison to harmonic interpolation. A significant reason for the choice of METAPOST, is that METAPOST uses piecewise cubic Bézier curves to interpolate the specified points. META- POST is also a programming language, and so harmonic interpolation is implemented in METAPOST to provide an accurate comparison. The details of how the Bézier control points are selected are given in [33] and [43], we give a brief overview here. Since cubic Bézier curves interpolate their end points, we simply have to discuss how the remaining two control points are selected to create a piecewise continuous Bézier curve. There are many parameters that influence how these control points are selected. We will primarily be interested in how the points are selected automatically without extra parameters being specified, since this is the technique that harmonic interpolation will use. The following discussion is based on the paper by Hobby [33]. We begin by examining a curve segment q i (t), that must interpolate z i and z i+1 R 2. To simplify notation we will use the convention z i = ( x i y i ) T. We are given the unit direction vectors w i and w i+1 for the end points. q i (t) must be defined by q i (0) = z i, q i (1) = z i+1, q i(0) = αw i, q i(1) = βw i+1. Hobby [33] includes tension parameters τ i and τ i+1. We will accept that the default value of 1 is used as described in [43]. First we consider a function ˆq i (t) defined by ( ) 0 ˆq i (0) = ˆq i(0) = 1 τ i ρ(θ, φ) 0 ( cos θ sin θ ( ) 1, 0, ˆq i (1) = ), ˆq i(1) = 1 σ(θ, φ) τ i+1 ( ) cos φ, sin φ

60 40 Chapter 2. Background where θ = arg(w i ) arg(z i+1 z i ) and φ = arg(z i+1 z i ) arg(w i+1 ). The function arg(w i ) maps w i to the angle that w i makes with the unit vector ( ) ( T (1 ) ) T 1 0. For example, arg 1 is π. The functions ρ and σ will be 4 determined later. q i (t) is then given by ( ) xi+1 x q i (t) = z i + i y i y i+1 ˆq(t). y i+1 y i x i+1 x i The Bézier curve that satisfies the requirements for ˆq t has control points ( ) ( ) ( 0 ρ(θ, φ) cos θ 1 σ,, τ ) ( ) 3 i+1 cos φ 1 σ 0 3τ i sin θ τ and. 3 i+1 sin φ 0 The curve ˆq(t) is then given by ˆq(t) = ρ(θ, φ) τ i t(1 t) 2 ( ) cos θ + t 2 (1 t) sin θ ( ) 3 σ ( ) τ i+1 1 σ + t 3. τ i+1 0 Now we must choose the functions ρ(θ, φ) and σ(θ, φ) so that ρ(θ, φ) = σ(φ, θ) = ρ( θ, φ). The functions selected for METAPOST are: ρ(θ, φ) = where 2 + α 1 + (1 c) cos θ + c cos φ, σ(θ, φ) = 2 α 1 + (1 c) cos φ + c cos θ, α := a(sin θ b sin φ)(sin φ b sin θ)(cos θ cos φ). The constants a, b and c selected are a = 2, b = 1 16 and c = (3 5)/2. At this point we have the tools to create a Bézier curve using the direction specifiers and points to interpolate. We now turn our attention to the entire curve. The goal is to interpolate the points specified, without needing extra information (although extra information can be provided). Thus only the points to interpolate are given, and not the direction vectors. So we need an algorithm to determine the directions of the curve at each point so that the above formulas can be applied. For this, Hobby [33] introduces mock curvature. We omit the details, and simply state the techniques used, as explained in [43]. First we note that at each interpolation point, two directions may be specified. One for the incoming curve, and one for the exiting curve. If one of the directions are specified, then the other is simply a duplicate. For our purposes these directions are not specified and must be determined. We consider each of the points z i, i = 0,..., n and direction vectors w i, i = 0,..., n.

61 2.14. METAPOST and Bézier Curves 41 Let d j be the Euclidean distance between z i+1 z i for i = 0,..., n 1. We further define θ i := arg(w i ) arg(z i+1 z i ), i = 0,..., n 1, φ i := arg(z i z i 1 ) arg(w i ), i = 1,..., n, ψ i := arg(z i+1 z i ) arg(z i z i 1 ), i = 1,..., n, with n = n for periodic interpolation and n = n 1 for non-periodic interpolation. We have the relation θ i + φ i + ψ i = 0, i = 1,..., n 1. For periodic interpolation, all directions can be determined. For non-periodic interpolation the directions at the end points are specified. These are specified by curl values. The default value is 1 for the curl at the end points, and this is the value we will use. For the inner control points the following equations should hold τ 2 i d i ( ) θi 1 + φ i 3φ i τ i 1 = τ ( ) i 2 θi + φ i+1 3θ i. (2.14) d i+1 τ i+1 For non-periodic interpolation we have further constraints. If we have the first direction vector, θ 0 is determined, otherwise the curl γ 0 is used in the following equation τ 2 0 ( 1 τ 1 (θ 0 + φ 1 ) 3θ 0 ) = γ 0 τ 1 2 ( ) 1 (θ 0 + φ 1 ) 3φ 1, (2.15) τ 0 and in a similar fashion, if the last direction vector is specified, then φ n, otherwise we use the curl γ n to get τ 2 n ( ) ( ) 1 1 (θ n 1 + φ n ) 3φ n = γ n τn 1 2 (θ n 1 + φ n ) 3θ n 1. (2.16) τ n 1 τ n 1 The equations 2.14 (and in the non-periodic case equations 2.15 and 2.16) are linear equations. If τ i 3/4, τ i 3/4 and γ i 0, then there is a unique solution. We now know how metapost draws its diagrams, we next proceed to look at a few examples. The examples used for interpolation using B-splines are duplicated for metapost in figures 2.15 and B-splines and META- POST curves are both piecewise cubic polynomial curves (as we will be using them). The same is true of Catmull-Rom splines and many of the others we

62 42 Chapter 2. Background x 1 x 2 x 5 x 7 x 0 x 3 x 4 x 6 x 8 Figure 2.15: Interpolation using METAPOST. x 1 x 2 x 0 x 3 x 4 Figure 2.16: Periodic interpolation using METAPOST. have discussed. Each curve can thus be represented exactly by one of the other curves. We simply have to find a set of control points that produces the desired curve. The key differences in the curves, especially in terms of interpolation, is how the control points are chosen, and what effect the control points have on the curve. The results produced by METAPOST are thus of relevance to the other cubic curves as well Curvature and Torsion We consider the curvature of curves in R 2 and R 3. A parameterised curve in R n is a smooth function x : I R n, where I is some interval in R.

63 2.15. Curvature and Torsion 43 By smoothness of such a function we mean that x is of the form x(t) = ( x0 (t) x 1 (t)... x n 1 (t) ) T where each xi is a smooth real valued function on I. The arc length of the curve is given by (t [a, b]) b (dx0 ) 2 ( ) 2 dx1 l = dt dt a ( dxn 1 dt ) 2 dt. We can thus compute the arc length of the curve x(t ) = ( x 0 (t ) x 1 (t )... x n 1 (t ) ) T from an initial parameter value t 0 by t (dx0 ) 2 ( ) 2 ( ) 2 dx1 dxn 1 s(t) = dt, dt dt dt t 0 for any value of t. The velocity vector at a time t I of the parameterised curve x : I R n is defined as ẋ := dx(t) ( dx0 (t) dx = 1 (t)... dx ) T n 1(t). dt dt dt dt We need to develop further tools to determine in some fashion if one smooth curve is better than another. Curvature is a metric that can be used to determine how quickly a curve changes direction. Curves that change direction slowly are preferable to curves that change direction quickly or discontinuously. We begin by examining the curvature for curves in the plane (R 2 ). Let t(s) be the tangent vector to the curve x(s) at arc length s. We will thus be using arc length parameterisation. The tangent vector t(s) is a unit vector by virtue of the arc length parameterisation. We define ψ(s) to be the angle between the tangent t(s) and the positive x-axis. The curvature measures the rate of curving, and is thus defined as κ(s) = dψ(s) ds Now we can introduce the curvature plot in terms of a parametrically defined curve. A curvature plot displays curvature verse arc length, or the parameter of the curve. Curvature is nonnegative by definition, but we will primarily be interested in signed curvature κ of a parametric curve x(t) = ( x 0 (t) x 1 (t) ) T defined as [24] κ(t) = x 0(t)ẍ 1 (t) x 1 (t)ẍ 0 (t) [( x 0 (t)) 2 + ( x 1 (t)) 2 ], 3/2.

64 44 Chapter 2. Background where x 0 (t) = dx 0(t) and likewise for ẍ dt 0, x 1 and ẍ 1. parameterisation we obtain Using the arc length κ(s) = x 0 (s)ẍ 1 (s) x 1 (s)ẍ 0 (s), where x 0 (s) = dx 0(s) and so forth. The curvature plot shows points of inflection quite clearly by κ = 0. We can now define fair curves. A curve is ds fair if its curvature plot is continuous and consists of only a few monotone pieces [24]. Curvature plots will provide us with an additional measure of the quality of curves. Example. We determine the curvature of the catenary curve given in parameter form ( ) ( ) x0 (t) t x(t) = =. x 1 (t) cosh t Thus x 1 = cosh x 0. We find the curvature κ(t) using cosh t 1 2 (et + e t ), κ(t) = x 1 0(t)ẍ 1 (t) x 1 (t)ẍ 0 (t) [( x 0 (t)) 2 + ( x 1 (t)) 2 ] = 2 (et + e t ) 0 3/2 [ (et e t ) 2 ] 3/2 = = = 1 2 (et + e t 1 ) [ (e2t 2 + e 2t )] = 2 (et + e t ) 3/2 [ 1 4 (e2t e 2t )] 3/2 1 2 (et + e t 1 ) [ 1 4 (et + e t ) 2 ] = 2 (et + e t ) 3/2 1 8 (et + e t ) (et + e t ) = 1 2 cosh 2 t. Figure 2.17(a) shows the catenary, and the tangent to the curve at parameter value u = Figure 2.17(b) shows the curvature plot obtained using the curvature derived above for the parameter values t [0, 1]. We now turn our attention to curvature of smooth curves defined in R 3. A curve in R 3 can be defined by (parametric form) x(t) = ( x 0 (t) x 1 (t) x 2 (t) ) T. For a curve in R 3, the arc length for parameter value t is given by t (dx0 ) 2 ( ) 2 ( ) 2 t dx1 dx2 s(t) = + + dt = dx dt dt dt dt dt. t 0 t 0

65 2.15. Curvature and Torsion 45 x 1 t (0, 0) (a) Catenary x (b) Curvature Figure 2.17: The catenary and its curvature. When analysing curvature, the arc length parameterisation is often better. The tangent to a curve x(s) parameterised by arc length in R 3 is defined as t(s) := dx(s) ds The tangent is a unit vector as a result of the arc length parameterisation. If we consider three points on the curve defined by parameter values s ɛ, s and s + ɛ, we can form a plane from these points. The plane obtained when we take the limit ɛ 0 is known as the osculating plane. The tangent vector lies entirely in the osculating plane. There are an infinite number of normals to the curve at arc length parameter value s. The principal normal n is the line that is perpendicular to the tangent in the osculating plane. We now define the curvature vector [24] as k(s) := dt(s) ds. = κn(s). The value κ is the curvature of the curve in R 3. If we consider the prior three points again (s ɛ, s and s+ɛ) we can find a circle that passes through these points. The circle obtained as we take the limit ɛ 0 is known as the osculating circle. The centre of the osculating circle for a point x on the curve is a distance κ 1 in the direction of the principal normal from the point x. The value κ 1 is known as the radius of curvature. Curvature measures the rate of change of the tangent vector. Torsion measures the rate of change of the osculating plane. To define the rate of change we need the binormal, the curve normal that is orthogonal to the osculating plane. The torsion is then defined as the rate of change of the binormal

66 46 Chapter 2. Background b := t n [24], db ds = τn. The curvature vector, principal normal and binormal can be calculated from the parametric curve t(t) = ẋ(t) ẋ(t) ẍ(t), b(t) =, n(t) = b(t) t(t). ẋ(t) ẋ(t) ẍ(t) The frame described by t, n and b is known as the Frenet frame. Once t, n, and b have been computed we compute κ and τ. The curvature vector can then be expressed as k(t) = κn(t) = ẍ(t) t(t)(ẍ(t) t(t)), ẋ(t) ẋ(t) so that the curvature κ is given by κ(t) = ẍ(t) n(t) ẋ(t) ẋ(t) The torsion can be computed using τ(t) = ẋ(t) ẍ(t) ẋ(t) 3. (ẋ(t) ẍ(t))... x(t) ẋ(t) ẍ(t) 2. Using the arc length parameterisation we obtain k(s) = κ(s) n(s) = dt(s) ds. We thus have κ(s) = dt(s) ds = (d2 ) 2 x 0 + ds 2 ( ) 2 d2 x 1 + ds 2 ( ) 2 d2 x 2. ds 2 Likewise the torsion in terms of arc length parameterisation is given by τ(s) = ẋ(s) ẍ(s)... x(s). ẍ(s) ẍ(s)... where ẋ(s) ẍ(s) x(s) denotes the determinant of the matrix which is constructed from the three column vectors ẋ(s), ẍ(s), and... x(s).

67 2.15. Curvature and Torsion 47 y z x Figure 2.18: A spiral curve. Example. We examine the curvature of the spiral (illustrated in figure 2.18) a cos(t) x(t) = a sin(t), bt where a > 0 and b < 0 or b > 0. The arc length is then t (dx0 ) 2 ( ) 2 ( ) 2 dx1 dx2 s(t) = + + dt = t a dt dt dt 2 + b 2. 0 The arc length parameterisation of x is thus ( ) ( ) s s x 0 (s) = a cos x 1 (s) = a sin a2 + b 2 a2 + b 2 x 2 (s) = bs a2 + b 2. Consequently κ(s) = (d2 ) 2 x 0 + ds 2 ( ) 2 d2 x 1 + ds 2 ( ) 2 d2 x 2 = ds 2 a a 2 + b 2. Thus the curvature is independent of s, i.e. constant. The torsion is given by τ(s) = ẋ(s) ẍ(s)... x(s) b = ẍ(s) ẍ(s) a 2 + b, 2 and is also constant.

68 48 Chapter 2. Background 2.16 Conclusion This chapter discussed existing work on curves and interpolation. In particular, the most prominent curve in computer graphics, Bézier curves, was introduced and discussed. Bézier curves are particularly important because of the convex hull property. This property is very important for the rendering of curves and surfaces. Bézier curves are quite useful for constructing piecewise continuous curves, a few of which were discussed, including the curves produced by METAPOST. The curves produced by METAPOST provide much of the control of other piecewise continuous Bézier curves, but do not require all of the parameters to be specified. We will thus use the Bézier curves of METAPOST for comparison later. Commonly used curves such as B-splines were also introduced. We have also shown the relationship between these curves and Bézier curves. Trigonometric interpolation, which interpolates data points using trigonometric functions, is also discussed. We will see that harmonic interpolation is a form of trigonometric interpolation. A measure of the quality of curves, namely curvature and torsion, was introduced. We will use curvature later to compare various curves. This provides the framework for comparison to harmonic interpolation in the next chapter. Several important properties of curves were also introduced, including affine invariance and the convex hull property. This will allow us to evaluate curves created by harmonic interpolation. The next chapter introduces harmonic interpolation and discusses the properties of curves produced by harmonic interpolation.

69 Chapter 3 Harmonic Interpolation In this chapter we discuss a technique for producing periodic interpolating curves without numerical solution of systems of interpolation. To do so we introduce harmonic interpolation. The well known Fourier transform can be used for analysis of periodic functions. Harmonic interpolation is based on an interesting application of the Fourier transform, which produces periodic interpolation of data points. We show how the basis functions for harmonic interpolation are derived and how harmonic interpolation can be extended to an even number of points. The technique for an odd number of points was discussed by Schuster [71, 72, 73]. 3.1 Interpolation To begin the derivation, we consider an n-tuple X = (x 0, x 1,..., x n 1 ) of vectors describing a polygon. The derivation proceeds in the same way as that of Schuster [73]. We would like to interpolate smoothly between the points of the polygon in the order specified. The n n permutation matrix J = (3.1) can be used to iterate through the vertices of the polygon. We note that the matrices J, J 2,..., J n I n form a commutative group under matrix multiplication. This is a subgroup of the n n permutation matrices. Iteration is performed by (J k X) 0 = x k. The eigenvalues of J are λ j, j = 0,..., n 1 49

70 50 Chapter 3. Harmonic Interpolation where λ = e (2πi)/n. The corresponding eigenvectors are s j = ( 1 λ j λ 2j... λ (n 1)j) T. Using the spectral representation [82] of J we get J = λ j P j, (3.2) j=0 where P j are projection matrices. We have P j P k = 0 for j k and Pj 2 = P j, and thus also Pj k = P j for k = 1,..., n. We now consider J k = λ jk P j, k = 1,..., n. (3.3) j=0 For k = n we have J n = I, so that I = P j, j=0 where I is the identity matrix. We also have J 0 = I. Equation 3.3 forms a system of equations of the form (J k ) = (λ jk )(P j ). Solving for P j using the inverse of the matrix ( λ jk) (, given by ) 1 n λ jk gives P j = 1 λ jk J k, j = 0,..., n 1. (3.4) n We define P j := P n j and note that P j can be determined using equation 3.4 because P j = 1 λ jk J k n n 1 = 1 e (2πi)(jk)/n J k n n 1 = 1 e (2πi)(jk)/n k2πi J k n n 1 = 1 e (2πi)(jk kn)/n J k n n 1 = 1 e (2πi)( (n j)k)/n J k n = P n j. (3.5)

71 3.2. Odd Case 51 We can identify two possibilities, n is even (n = 2m) and J k = P 0 + ( 1) k P m + m 1 j=1 ( λ jk P j + λ jk P j ), (3.6) with λ (n j)k = λ jk, or n is odd (n = 2m + 1) and m ( ) J k = P 0 + λ jk P j + λ jk P j. (3.7) j=1 We will investigate what happens if the discrete iteration using k Z is replaced with continuous t R. In the odd case, if k Z is replaced by t R then J t R. For the even case ( 1) t C so J t C. In the next section we look at each of these cases in turn and derive a simpler formula for J t X. 3.2 Odd Case Once again we follow the derivation of Schuster [73]. When n is odd (n = 2m + 1) we have m ( ) J k = P 0 + λ jk P j + λ jk P j, (3.8) with J 0 =J n = I. By replacing k Z with u R we have m ( ) J u = P 0 + λ ju P j + λ ju P j J u = P 0 + j=1 j=1 m ( ) e (2πi(ju))/n P j + e (2πi( ju))/n P j. (3.9) j=1 We would prefer to work with a parameter in the range [0, 1], so we perform the mapping t = u (or u = tn) and define J t := J nt = J u with J 0 = J 1 = I. n J t is thus 1 periodic so that J t+1 = J t. Substituting the value for u = nt into the equation we get m ( ) J t = P 0 + e (2πi(jnt))/n P j + e (2πi( jnt))/n P j = P 0 + j=1 m ( ) e 2πijt P j + e 2πijt P j. (3.10) j=1

72 52 Chapter 3. Harmonic Interpolation We now substitute the values for the projection matrices given in equation 3.4 into the above equation to obtain m ( ) J t = P 0 + e 2πijt P j + e 2πijt P j. j=1 ( ) J t = 1 m J k + e 2πijt 1 λ jk J k + e 2πijt 1 λ jk J k n n n j=1 ( ) J t = 1 m J k + e 2πijt 1 e 2πijk/n J k + e 2πijt 1 e 2πijk/n J k n n n j=1 ( ) J t = 1 m 1 + e 2πij(t k/n) + e 2πij(t k/n) J k. (3.11) n j=1 The inner sum has the form σ = 1 + m j=1 (xj + x j ) with x := e 2πi(t k/n). We calculate the sum of the geometric series x j and x j and add 1 to get m ( σ = 1 + x j + x j) We define σ(t) := sin(nπt) n sin(πt) j=1 = 1 + xm+1 x x 1 = 1 + xm+1 x x 1 + x 1 x m 1 1 x 1 x x + 1 x m x 1 = xm+1 x m, with m = n 1 2 x 1 = x n+1 2 x n 1 2 x 1 = x n 2 x n 2 x 1 2 x 1 2 x 1 2 x 1 2 = eπi(t k/n)n e πi(t k/n)( n) e πi(t k/n) e πi(t k/n) 2i sin(π(t k/n)n) = 2i sin(π(t k/n)) sin(nπ(t k/n)) = sin(π(t k/n)). (3.12) and σ k (t) := sin(nπ(t k/n)) n sin(π(t k/n)) (3.13)

73 3.3. Even Case 53 and note that σ k (t) = σ(t k/n). Equation 3.11 becomes J t = σ k (t)j k. (3.14) To permutate the polygon given by X we multiply by J k. To interpolate the points of the polygon continuously we calculate ˆX(t) = J t X = σ k (t)j k X. (3.15) We consider element l of the polygon given by ˆX(t): ˆX l (t) = σ k (t)x k+l n 1 = σ(t k/n)x k+l n 1 = σ(t + l/n (k + l)/n)x k+l n 1 = σ k+l (t + l/n)x k+l = ˆX 0 (t + l/n), (3.16) where k +l is calculated modulo n. Thus we get the same curve for any value of l. We define the harmonic interpolation by X(t) := ˆX 0 (t). X(t) is known as the Lagrange trigonometric interpolation of X [39]. The σ(t) function is known as the periodic Dirichlet kernel. This is only the case for when n is odd, in the next section we see how a similar derivation can be applied for the even case. 3.3 Even Case In the even case, equation 3.17 is continuous in the complex domain. The definition of continuity [49] implies that the real portion should also be continuous. Our contribution is to derive a similar formula to equation 3.15 for

74 54 Chapter 3. Harmonic Interpolation the even case. The results have been published in [32] and [31]. Here we fill in the details and prove certain properties. For the continuous case we replace k Z with u R, 0 u n. In the continuous even case (n = 2m) we thus have J u = P 0 + ( 1) u P m + m 1 j=1 ( λ ju P j + λ ju P j ), (3.17) which is in the complex domain since ( 1) u = e πiu. We derive the formulas for the complex domain, and then examine the real portion at the end of the derivation. We begin by substituting the values for the projection matrices P j into equation 3.17: J u = P 0 + ( 1) u P m + m 1 j=1 ( λ ju P j + λ ju P j ) = 1 J k + ( 1) u 1 λ mk J k n n ( ) m 1 + λ ju 1 λ jk J k + λ ju 1 λ jk J k n n j=1 ( = ( 1) u λ mk n ( )) m 1 + λ ju λ jk + λ ju λ jk J k j=1 ( = 1 ( 1 + e πiu e 2πimk/n) n n 1 m 1 ( + e 2πiju/n e 2πijk/n + e 2πiju/n e 2πijk/n)) J k. j=1 (3.18) Once again we replace u by t [0, 1] to get a 1-periodic function J t using the substitution u = nt ( J t = 1 ( 1 + e πint e (2πimk)/n) m 1 ( + e 2πijt e (2πijk)/n + e 2πijt e (2πijk)/n)) J k n ( ( J t = 1 (e 1 + ) πi(nt k) + n m 1 j=1 j=1 ( e 2πij(t k/n) + e 2πij(t k/n)))) J k. (3.19)

75 3.3. Even Case 55 As in the odd case, the inner sum has the form φ = 1 + m 1 j=1 (xj + x j ) with x := e 2πi(t k/n). We calculate the sum of the geometric series x j and x j and add 1 to get We define φ = 1 + m 1 j=1 ( x j + x j) = 1 + xm x x 1 + x 1 x m x 1 x 1 x = 1 + xm x x x m+1 x 1 = xm x m+1, with m = n 2 x 1 = x n 2 x n 2 2 x 1 2 x 1 x 1 2 = x n 1 2 x n 1 2 x 1 2 x 1 2 = eπi(t k/n)(n 1) e πi(t k/n)(n 1) e πi(t k/n) e πi(t k/n) 2i sin(π(t k/n)(n 1)) = 2i sin(π(t k/n)) sin(π(t k/n)(n 1)) =. (3.20) sin(π(t k/n)) φ(t) := sin((n 1)πt) n sin(πt) and φ k (t) := sin((n 1)π(t k/n)) n sin(π(t k/n)) (3.21) and note that φ k (t) = φ(t k/n). At this point we can substitute φ k (t) back into equation 3.19, so that ( ) 1 J t = n eπi(nt k) + φ k (t) n 1 J t = J k ( 1 n cos(π(nt k)) + i n sin(π(nt k)) + φ k(t) ) J k.

76 56 Chapter 3. Harmonic Interpolation We can rewrite J t in terms of σ k (t) by noting that and sin((n 1)π(t k/n)) = sin((n + ( 1))π(t k/n)) = sin(nπ(t k/n)) cos(π(t k/n)) cos(nπ(t k/n)) sin(π(t k/n)) = sin(π(nt k)) cos(π(t k/n)) cos(π(nt k)) sin(π(t k/n)), 1 n cos(π(nt k)) + φ k(t) = 1 sin((n 1)π(t k/n)) cos(π(nt k)) + n n sin(π(t k/n)) cos(π(nt k)) sin(π(t k/n)) = n sin(π(t k/n)) sin((n 1)π(t k/n)) + n sin(π(t k/n)) sin(π(nt k)) cos(π(t k/n)) = n sin(π(t k/n)) sin(nπ(t k/n)) cos(π(t k/n)) = n sin(π(t k/n)) = cos(π(t k/n))σ k (t). (3.22) To simplify further discussions we define ϕ(t) := cos(πt)σ(t). The definition ϕ k (t) := ϕ(t k/n) follows naturally. We now have ( ) i J t = n sin(π(nt k)) + cos(π(t k/n))σ k(t) J k. (3.23) We are only interested in the real portion of J t, so we define Ĵ t := ϕ k (t)j k. (3.24) To permutate the polygon given by X we multiply by J k. To interpolate the points of the polygon continuously we calculate ˆX(t) = Ĵ t X = ϕ k (t)j k X.

77 3.4. Examples 57 We consider element l of the polygon given by ˆX(t): ˆX l (t) = ϕ k (t)x k+l n 1 = ϕ(t k/n)x k+l n 1 = ϕ(t + l/n (k + l)/n)x k+l n 1 = ϕ k+l (t + l/n)x k+l = ˆX 0 (t + l/n), (3.25) where k + l is calculated modulo n. Thus we get the same curve for any value of l. We define the harmonic interpolation by X(t) := ˆX 0 (t). We now have a formula for drawing a curve that interpolates the points of a polygon for both an even number and and odd number of points. In the following section we look at some examples of harmonic interpolation. 3.4 Examples From this point onwards, we use the σ function defined as sin(nπt) σ(t) := n sin(πt), if n is odd cos(πt) sin(nπt) (3.26) n sin(πt), if n is even and σ k (t) := σ(t k/n). Harmonic interpolation can now be applied in both even and odd cases as X(t) = σ k (t)x k. (3.27) Harmonic interpolation can be applied to points of any dimension. In this section we examine some examples of harmonic interpolation and compare the examples to some of the techniques presented in chapter 2. First we graph the basis functions. Figure 3.1 and 3.3 show σ(t) for n = 3 and n = 4. Figure 3.2 and 3.4 show all of the basis functions for n = 3 and n = 4.

78 58 Chapter 3. Harmonic Interpolation σ(t) Figure 3.1: The σ(t) function for n = σ 0 (t) σ 1 (t) σ 2 (t) Figure 3.2: The σ k (t) basis functions for n = 3.

79 3.4. Examples σ(t) Figure 3.3: The σ(t) function for n = σ 0 (t) σ 1 (t) σ 2 (t) σ 3 (t) Figure 3.4: The σ k (t) basis functions for n = 4.

80 60 Chapter 3. Harmonic Interpolation σ(t) Figure 3.5: The σ(t) function for n = 7. Of particular interest is the fact that σ(t) = 1 when t Z. In particular, at the beginning of the curve (t = 0) and at the end of the curve (t = 1) σ(t) = 1. In addition, when one of the basis functions has value 1, all the other basis functions have value 0. Harmonic interpolation thus interpolates the points of the control polygon. Figures 3.5 and 3.6 show the behaviour of σ(t) for larger values of n. We now compare a few piecewise continuous curves produced by METAPOST [34], trigonometric interpolation, and harmonic interpolation. We chose METAPOST, since METAPOST interpolates a set of control points using cubic Bézier curves. Comparing directly to Bézier curves would be meaningless, since Bézier curves only interpolate the end control points. Figure 3.7 illustrates a circle drawn with Bézier curves in METAPOSTand harmonic interpolation. The dashed line indicates the control polygon. The feint line indicates the control polygon selected by METAPOST for piecewise continuity. Bézier curves cannot be used to draw a circle. Although there is no noticeable error in the circle drawn by META- POST, it is not a circle. METAPOST uses several curves to draw the circle. Harmonic interpolation generates a circle precisely. Figure 3.9 illustrates the smooth curve generated by harmonic interpolation when seven control points are used. Figure 3.11 shows another comparison with five control points. The curve produced by harmonic interpolation seems more representative of the polygon. However a cusp is produced, which is not desirable. Figures 3.8, 3.10 and 3.12 compare B-spline curves to harmonic interpolation. We

81 3.4. Examples σ(t) Figure 3.6: The σ(t) function for n = 16. x 1 x 1 x 2 x 0 x 2 x 0 x 3 (a) METAPOST x 3 (b) Harmonic interpolation Figure 3.7: A circle drawn by METAPOST and harmonic interpolation.

82 62 Chapter 3. Harmonic Interpolation x 1 x 1 x 2 x 0 x 2 x 0 x 3 (a) B-spline x 3 (b) Harmonic interpolation Figure 3.8: A circle drawn by B-spline and harmonic interpolation. x 0 x 6 x 0 x 6 x x 5 4 x 3 x x 5 4 x 3 x 1 x 2 (a) METAPOST x 1 x 2 (b) Harmonic interpolation Figure 3.9: A 7 sided polygon drawn by METAPOST and harmonic interpolation. x 0 x 6 x 0 x 6 x x 5 4 x 3 x x 5 4 x 3 x 1 x 2 (a) B-spline x 1 x 2 (b) Harmonic interpolation Figure 3.10: A 7 sided polygon drawn by B-spline and harmonic interpolation.

83 3.4. Examples 63 x 0 x 3 x 4 x 2 x 0 x 3 x 4 x 2 x 1 (a) METAPOST x 1 (b) Harmonic interpolation Figure 3.11: A 5 sided polygon drawn by METAPOST and harmonic interpolation. x 0 x 3 x 4 x 0 x 2 x 4 x 3 x 2 x 1 (a) B-spline x 1 (b) Harmonic interpolation Figure 3.12: A 5 sided polygon drawn by B-spline and harmonic interpolation.

84 64 Chapter 3. Harmonic Interpolation x 1 x 1 x 2 x 0 x 2 x 0 x 3 (a) Trigonometric interpolation x 3 (b) Harmonic interpolation Figure 3.13: A 4 point polygon drawn with trigonometric and harmonic interpolation. p 4 p 7 p 0 p 4 p 7 p 0 p 3 p 3 p 5 p 6 p 5 p 6 p 1 p 2 (a) Trigonometric interpolation p 1 p 2 (b) Harmonic interpolation Figure 3.14: 3D curves drawn with trigonometric and harmonic interpolation. discuss the results further in the next section. Since harmonic interpolation is based on trigonometric functions, it is instructive to compare harmonic interpolation to trigonometric interpolation. Figure 3.13 shows that, although trigonometric interpolation is smooth, harmonic interpolation provides a far better result for use in computer graphics. The same is true for curves in 3D. Figure 3.14 shows the result of harmonic interpolation and trigonometric interpolation through the points of a cube. 3.5 Curvature plots In this section we compare the curvature plots of some of the previous figures. We have chosen to compare B-splines and harmonic interpolation, since B-splines are a common primitive in most modelling applications.

85 3.5. Curvature plots 65 x 1 x 1 x 2 x 0 x 2 x 0 x 3 x (a) Harmonic interpolation 0.00 (b) B-spline Figure 3.15: Curvature plot of figure 3.8. x 0 x 6 x 0 x 6 x x 5 4 x 3 x x 5 4 x 3 x 1 x 2 x 1 x (a) Harmonic interpolation 4.68 (b) B-spline Figure 3.16: Curvature plot of figure 3.10.

86 66 Chapter 3. Harmonic Interpolation x 0 x 0 x 4 x 3 x 4 x 2 x 3 x 2 x 1 x (a) Harmonic interpolation 2.94 (b) B-spline Figure 3.17: Curvature plot of figure x 0 x 7 x 0 x 7 x 5 x 6 x 5 x 6 x 4 x 3 x 4 x 3 x 1 x 2 x 1 x (a) Harmonic interpolation 0.40 (b) B-spline Figure 3.18: Curvature plot of an eight sided figure.

87 3.5. Curvature plots 67 For each curvature plot, we display the curve and corresponding curvature plot of harmonic interpolation and periodic B-splines for comparison. The vertical axis of the curvature plot is the measured curvature value. The axis has been scaled to try to provide the most information possible. The vertical axis is labelled to indicate the minimum and maximum curvature values. The horizontal axis is unmarked, and represents the parameter value of the curve. The parameter values are not marked, since harmonic interpolation and B-splines are defined over different parameter values. The graph depicts curvature from the start of the curve to the end of the curve. The curvature plots coincide roughly. The curvature measures the rate of curving, so a high rate of curving creates a relatively sharp point on the curve. We prefer to see low absolute values of curvature on the curvature plot. This normally indicates a smoother transition between control points. A cusp is typically indicated by a high absolute curvature value. In figure 3.15 the curvature plot indicates that harmonic interpolation is superior. In fact, the curvature for harmonic interpolation is constant, since the curve produced is a perfect circle. We look at further curves to see if harmonic interpolation maintains these properties. Figure 3.16 indicates that the curvature of harmonic interpolation is better in this case. In particular, the point of inflection at x 4 is clearly marked, and we can see that the change in curvature is more severe in the case of the B-spline. The maximum absolute curvature value for harmonic interpolation is far less than that of the B-spline. Harmonic interpolation has some issues with cusps, as illustrated in figure The cusp has a marked effect on the curvature plot. We see that the scale of figure 3.17(a) and 3.17(b) differ greatly. The B-spline appears to better in this case, although it is difficult to say how the curves compare further away from the cusp. Finally in figure 3.18 it appears that harmonic interpolation produces a better curve in the sense that there are fewer monotone pieces in the curvature plot. This would indicate that the harmonic interpolation is fairer (as defined in section 2.15) in this case. It appears that harmonic interpolation produces curves with fair qualities, although there is a danger of oscillation and cusps.

88 68 Chapter 3. Harmonic Interpolation x 1 x 1 x 0 x 3 x 0 x 3 x 2 (a) x 2 (b) Figure 3.19: Stability of harmonic interpolation. 3.6 Numerical Stability Figure 3.19 shows how a small change in the points which are interpolated influence the curve generated by harmonic interpolation. In figure 3.19(b), the point p 3 is moved slightly to the right of its position in figure 3.19(a). The change in the curve is minimal, showing that harmonic interpolation is quite stable. There is, however, potential numerical instability near t = 0 and t = 1. We can compute the limit as t 0, but there is another alternative. We define ς n (t) := sin(nπt) sin(πt). We can now recursively expand ς n (t) as follows ς n (t) = sin(nπt) sin(πt) cos((n 1)πt) sin(πt) + sin((n 1)πt) cos(πt) = sin(πt) sin((n 1)πt) = cos((n 1)πt) + cos(πt) sin(πt) = cos((n 1)πt) + cos(πt)ς n 1 (t), for n = 2, 3,... and note that ς 1 (t) = 1. We also note that the potential instability of dividing by a small real number is no longer an issue. This approach has the advantage that we don t have to have an accurate idea of exactly when numerical stability becomes a problem. The formula is always

89 3.7. Affine Invariance 69 correct. Other approaches are only valid if t is small enough. For small values of t (or when t is near an integer value) we can use σ(t) := { 1 n ς n(t), if n is odd 1 cos(πt)ς n n(t), if n is even. If we refer to equations 3.11 and 3.19 we see that an alternative is ( ) m n j=1 σ(t) := cos(2πjt), if n is odd ( cos(πnt) + 2 ) m 1 j=1 cos(2πjt), if n is even n (3.28) (3.29) with n = 2m + 1 in the odd case, and n = 2m in the even case. 3.7 Affine Invariance As shown in chapter 2, an important property of curves (and surfaces) is affine invariance. If a curve is affine invariant, then we can apply an affine transformation to the control points, and the curve that is produced will be identical to the curve produced by first generating the curve and then applying the affine transformation. A curve is affine invariant if the basis functions are a partition of unity as stated in theorem 2.1. Schuster [73] states that σ k (t) = 1 and σk(t) 2 = 1 when n is odd. We show that this is indeed the case, and that n 1 σ k(t) = 1 when n is even also. Theorem 3.1. The σ function (equation 3.26) is a partition of unity: σ k (t) = 1. Proof. We split the proof into two parts. The first part examines the case where n is odd, and the second part examines the case where n is even.

90 70 Chapter 3. Harmonic Interpolation n odd (n = 2m+1) We refer back to equation 3.11 and compare the result to the σ function. ( ) J t = 1 m 1 + e 2πij(t k/n) + e 2πij(t k/n) J k, n j=1 ˆX(t) = J t X = σ k (t)j k X, ( σ k (t) = n ) m e 2πij(t k/n) + e 2πij(t k/n). j=1 This form of the σ function will be useful to prove the desired result. We split the sum to find an alternative condition to prove, the sum then becomes ( ) σ k (t) = 1 m 1 + e 2πij(t k/n) + e 2πij(t k/n) n j=1 ( ) = 1 m cos (2πj(t k/n)) n j=1 ( ) 1 = n + 2 m cos (2πj(t k/n)) n = n = n So it suffices to show that j=1 j=1 m cos (2πj(t k/n)) m cos (2πj(t k/n)). j=1 cos(2πj(t k/n)) = 0 for all n > 2, 0 < j < n, t R, j Z, n N, n odd. The proof follows: cos(2πj(t k/n)) = 1 e i2πj(t k/n) e i2πj(t k/n) = 1 2 ei2πjt e i2πj( k/n) e i2πjt e i2πj(k/n).

91 3.7. Affine Invariance 71 At this point we note that n 1 ei2πj( k/n) and n 1 ei2πj(k/n) are geometric series so that ( cos(2πj(t k/n)) = 1 ( ) ) ( 1 e i2πj/n n 2 ei2πjt + 12 ( ) ) 1 e i2πj/n n 1 e i2πj/n e i2πjt 1 e i2πj/n = 1 ( ) 1 e i2πj 2 ei2πjt + 12 ( ) 1 e i2πj 1 e i2πj/n e i2πjt 1 e i2πj/n = 1 ( ) ei2πjt + 1 ( ) e i2πj/n 2 e i2πjt 1 e i2πj/n as required. = 0 n even (n = 2m) Now we consider the even case. We refer back to equation 3.19 and compare the result to the σ function ( J t = 1 ( 1 + ) m 1 ( e πi(nt k) + e 2πij(t k/n) + e 2πij(t k/n))) J k n ˆX(t) = J t X = σ k (t)j k X ( σ k (t) = 1 ( 1 + ) e πi(nt k) + n j=1 m 1 j=1 ( e 2πij(t k/n) + e 2πij(t k/n))). We are only interested in the real part, however we will show that the σ function including the imaginary part is still a partition of unity. The real part of σ k (t) is ( ) σ k (t) = 1 m cos(π(nt k)) + 2 cos(2πj(t k/n)) n j=1 ( ) 1 = n + 2 m 1 cos(2πj(t k/n)) + 1 cos(π(nt k)) n n = n = n m 1 j=1 m 1 n 1 j=1 j=1 cos(2πj(t k/n)) + 1 cos(π(nt k)) n cos(2πj(t k/n)) + 1 cos(π(nt k)). n

92 72 Chapter 3. Harmonic Interpolation Thus it suffices to show that cos(2πj(t k/n)) = 0 which we have already done in the odd case, and cos(π(nt k)) = 0, which is clearly the above sum with j = n. The imaginary part can also be 2 shown to add to zero i sin(π(nt k)) = 0 n by noting that i sin(2πj(t k/n)) = 1 e i2πj(t k/n) 1 e i2πj(t k/n). 2 2 This equation is almost identical to the even case (except for a change in sign), so we can simplify to get i sin(2πj(t k/n)) = 1 ( ) ei2πjt 1 ( ) e i2πj/n 2 e i2πjt 1 e i2πj/n We note that = 0. i sin(π(nt k)) = 0 is simply the above sum with j = n. Thus, for both the even and the odd 2 case σ k (t) = 1. The theorem shows that harmonic curves (and later surfaces) are affine invariant according to theorem 2.1. We now examine other properties of curves produced by harmonic interpolation.

93 3.8. Convex Hull Property Convex Hull Property After examining figures 3.1 to 3.6 we note that the function σ k (t) is sometimes less than zero. Points on the curve are thus not always a weighted average of the control points. As a result we encounter some difficulties when rendering harmonic surfaces in chapter 4. In chapter 4 we will discuss techniques that enable efficient rendering of harmonic surfaces and address the problem of the convex hull. Next, we find that curves produced by harmonic interpolation are algebraic curves. 3.9 Chebyshev Polynomials The Chebyshev polynomial [81] of degree n (of the first kind) is given by T n (x) := cos(n arccos(x)). (3.30) Although the functions T n appear to be trigonometric, they are in fact algebraic. If we examine a few expansions of T n (x), using various trigonometric identities to simplify, we can verify the algebraic nature of T n : T 0 (x) = 1 T 1 (x) = x T 2 (x) = 2x 2 1 T 3 (x) = 4x 3 3x. T n+1 (x) = 2xT n (x) T n 1 (x), n 1. The Chebyshev polynomial of degree n (of the second kind) is given by U n (x) := sin ((n + 1) arccos(x)), (3.31) sin (arccos(x)) where n = 0, 1, 2,.... Once again we have an algebraic polynomial U 0 (x) = 1 U 1 (x) = 2x U 2 (x) = 4x 2 1 U 3 (x) = 8x 3 4x. U n+1 (x) = 2xU n (x) U n 1 (x), n 1.

94 74 Chapter 3. Harmonic Interpolation For details of these derivations we refer the reader to [40]. We now examine the relationship between Chebyshev polynomials and the basis functions for harmonic interpolation Odd case We follow a similar argument in the odd case as the one presented by Schuster [71]. In the odd case (n = 2m + 1), the curve produced by harmonic interpolation that interpolates the points x k is given by with X(t) = σ k (t)x k, σ k (t) = sin(nπ(t k/n)) n sin(π(t k/n)). The function σ k (t) can be represented by Chebyshev polynomials of the second kind by noting that 1 n U n 1(cos(π(t k/n)) = sin(nπ(t k/n) n sin(π(t k/n)) = σ k(t). We thus make the substitution s = cos(πt). Then we have cos(π(t k/n)) = cos(πt) cos(πk/n) + sin(πt) sin(πk/n) = s cos(πk/n) + 1 s 2 sin(πk/n). The curve X(t) can thus be written in terms of Chebyshev polynomials of the second kind. The curve X(t) is then with X(s) = 1 U n 1 (φ(s))x k, 1 s 1 n φ(s) = s cos(πk/n) + 1 s 2 sin(πk/n) Even case In the even case (n = 2m), the curve produced by harmonic interpolation that interpolates the points x k is given by X(t) = cos(π(t k/n))σ k (t)x k,

95 3.10. Non-Uniform Harmonic Interpolation 75 with σ k (t) = sin(nπ(t k/n)) n sin(π(t k/n)). We can rewrite σ k (t) in terms of Chebyshev polynomials of the second kind as in the odd case. We note that T 1 (cos(π(t k/n))) = cos(π(t k/n)). Once again we can use the substitution s = cos(πt) to rewrite harmonic interpolation in the even case in terms of Chebyshev polynomials of the first and second kind as with X(s) = 1 T 1 (φ(s))u n 1 (φ(s))x k, 1 s 1 n φ(s) = s cos(πk/n) + 1 s 2 sin(πk/n). We thus find that harmonic interpolation, in both the even and odd cases, are algebraic curves. Furthermore, we can evaluate the Chebyshev polynomials quite quickly [47] (O(log n)) in comparison to equations 3.28 and 3.29 (O(n)) without the numerical instability of σ k (t) as t 0 in equation Non-Uniform Harmonic Interpolation In the uniform case we have equation 3.4, P j = 1 λ jk J k, j = 0,..., n 1 n n 1 = 1 e 2πijk/n J k, n which is the spectral projection or Fourier transform of J k, k = 0,..., n 1. The P j s are the Fourier coefficients obtained from solving the system of equations 3.3 J k = e 2πijk/n P j, k = 0,..., n. j=0

96 76 Chapter 3. Harmonic Interpolation For the non-uniform case, points are not sampled with the uniform spacing t j = j/n but rather at arbitrary points t j with t j < t j+1. We also require 0 t j 1. We thus need to solve the system of equations J k = e 2πikt j P j, k = 0,..., n 1. (3.32) j=0 We thus have n equations in n unknowns. With the assumption t j < t j+1, which implies that t j t k, k j, the system of linear equations takes the form J k = a k j P j, k = 0,..., n 1. j=0 The inverse Fourier transform is then given by with and J = ( J 0 J 1... J n 1) T, J = AP, A k,j = a k j = e 2πikt j. P = ( P0 P 1... P n 1 ) T The forward Fourier transform (non-uniform) is given by P = A 1 J. The matrix A has the form a 0 a 1 a 2 a 3... a n 1 a 2 0 a 2 1 a 2 2 a a 2 n 1 A = a 3 0 a 3 1 a 3 2 a a 3, n a n 1 0 a n 1 1 a n 1 2 a3 n 1... a n 1 n 1 with a j := e 2πit j. This matrix is known as a Vandermonde matrix [68], and is related to the problem of moments. The inverse of the matrix is closely related to Lagrange interpolation. Let p k (x) := n 1 j=0 j k x a j = a k a j j=0 B k,j x j.

97 3.10. Non-Uniform Harmonic Interpolation 77 We thus have p k (a l ) = n 1 j=0 j k a l a j = δ l,k = a k a j j=0 B k,j a j l, so that B = A 1. The coefficients of the polynomial produced by Lagrange interpolation are the elements of the inverse of A. We can compute the elements of A 1 efficiently by defining Consequently n 1 p(x) := (x a j ). p k (x) = j=0 p(x) (x a k )p (a k ), where p denotes the derivative of p. We thus need only compute the coefficients of p(x) and then for each p k (x), the coefficients are found by division by a simple polynomial and a constant. For each of the n polynomials a division calculation of order O(n) is performed. The order of the calculation is thus O(n 2 ). To calculate the coefficients of p(x) = n j=0 c jx j we note that where f j (i) = f j (i) = 0, c j = f j (0), j a l f j+1 (l + 1), i 0 l=i i > j f n (i) = 1 0 < i < n. The function f j (i) uses a combinatorial approach to computing the coefficient of x j. The parameter i determines which (x a i ) terms in the product are under consideration. For each term, we may either include the term, or exclude the term. If we include the term, then a i forms part of the coefficient, otherwise x contributes to the factor x j. If i > j then there aren t enough factors left to construct x j and thus this term must be 0. The formula f j (i) = j l=i a lf j+1 (l + 1) considers the terms i up to j. The sum simply selects each term in the product (in turn) to be included and determines what the contribution this particular a l makes to the coefficient. Any further values must come from later terms in the product since we have elected not

98 78 Chapter 3. Harmonic Interpolation to include the previous terms a i values. We have the recursive relationship f j (i) f j (i + 1) = a i f j+1 (i + 1). f j (i) = f j (i + 1) a i f j+1 (i + 1) Thus, if we have all f j+1 we can compute f j starting with f j (n 1) and working down to f j (0). We would thus have to store both f j and f j+1. We can avoid the extra storage requirements by starting with f n 1 (n 1), we have Since f n (i) = 1 it follows that Now we have f n 1 (i) = a l f n (l + 1). l=i f n 1 (i) = a l. f n 1 (n 1) = In the next iteration we have l=n 1 l=i a l = a n 1 f n 2 (n 2) = f n 2 (n 1) a n 2 f n 1 (n 1). f 0 (n 2) = f 0 (n 1) a n 2 f 1 (n 1). f n 1 (n 2) = l=n 2 a l = f n 1 (n 1) a n 2 f n 2 (n 3) = f n 2 (n 2) a n 3 f n 1 (n 2). f 0 (n 3) = f 0 (n 2) a n 3 f 1 (n 2). Since we only wish to calculate f j (0) it is unnecessary to store f j (i), i > 0. The calculation can thus proceed with the iterations, only storing f j (i) for successively decreasing values of i, until i = 0. We thus have n iterations

99 3.10. Non-Uniform Harmonic Interpolation 79 computing n function values. The calculation of coefficients is thus O(n 2 ). Now we can apply P = A 1 J to calculate P j = The continuous transform is then given by J u = e 2πiut j P j j=0 J u = j=0 e 2πiut j A 1 j,k J k. A 1 j,k J k, with 0 u n. To interpolate we apply the substitution nt = u to obtain X(t) = J nt X = The first element is then given by X 0 (t) = j=0 j=0 e 2πintt j e 2πintt j A 1 j,k J k X. A 1 j,k x k. The set of equations 3.32 can be solved efficiently using the unequally spaced fast Fourier transform (USFFT [2]). Alternatives are discussed in [19] and [20]. Another technique suggested by Pohlman ([5]), represents the inverse Fourier transform (non-uniform) as J = AˆP, with J = ( J 0 J 1... J n 1) T, and A k,j = e 2πikt j. The problem is thus to find ˆP to solve these equations. The forward Fourier transform (non-uniform) is given by P = 1 n A J,

100 80 Chapter 3. Harmonic Interpolation with P = ( P 0 P 1... P n 1 ) T, and A = ĀT where x is the complex conjugate of x. Although it is not (necessarily) true that P = ˆP, the transform is similar to the Fourier transform. We try to use this relationship to find a solution. We then have A J = A AˆP, with the matrix A A Hermitian and Toeplitz, so we can solve for ˆP efficiently. The algorithm by Pohlman and the USFFT are more efficient (O(n log n)) and can usually be evaluated to a required degree of accuracy. A matrix A is Hermitian if A = A ĀT. An n n Toeplitz matrix is specified by 2n 1 numbers R k, k = n + 1,..., n 1. A Toeplitz matrix has the form R 0 R 1 R 2 R (n 2) R (n 1) R 1 R 0 R 1 R (n 3) R (n 2) R 2 R 1 R 0 R (n 4) R (n 3).. R n 2 R n 3 R n 4 R 0 R 1 R n 1 R n 2 R n 3 R 1 R 0 The non-uniform Fourier transform does not yield the same results as harmonic interpolation when applied to points with parametric values t j = j n. Harmonic interpolation was identified as Lagrange trigonometric interpolation, and we can see that it does not correspond to (Fourier) trigonometric interpolation, identified in section This becomes obvious when we note that λ (n j)k = λ jk in equation 3.7, but λ (n j)u λ ju in equation 3.9. A variation of the Fourier transform applied to an odd set of points (n = 2m+1) is given by We note that P j = 1 e 2πijk/n J k, n j = m,..., m m J k = e 2πijk/n P j, k = 0,..., n. (3.33) J k = j= m m j= m = P 0 + e 2πijk/n P j, k = 0,..., n m ( e 2πijk/n + e 2πijk/n) P j, j=1

101 3.10. Non-Uniform Harmonic Interpolation 81 which is simply harmonic interpolation. harmonic interpolation as We might then try non-uniform X(t) = m j= m e 2πintt j A 1 j+m,k x k. However t k, k < 0, has not been defined. And if we define t k so that 0 t k 1 (for k < 0) then this does not differ from the non-uniform Fourier transform. Instead we rewrite 3.33 as P j = 1 e 2πijk/n J k, n n 1 J k = e 2πik(j m)/n P j, j=0 = e 2πik(j/n m/n) P j. j=0 j = m,..., m k = 0,..., n Taking, J k = n 1 j=0 e2πik(j/n m/n) P j we then obtain X(t) = j=0 n 1 e 2πint(t j m/n) = e 2πint(tj m/n) f j j=0 A 1 j,k x k as the interpolation formula. The calculation of A 1 j,k should be adjusted accordingly. This equation corresponds with harmonic interpolation in the case where t k = k/n. We also note that non-uniform harmonic interpolation is not guaranteed to be periodic. The last segment is usually not very pleasing as illustrated in figure We thus only interpolate up to the last point provided and the interpolation formula becomes X(t) = j=0 n 1 e 2πi(n 1)t(t j m/n) = e 2πi(n 1)t(tj m/n) f j. j=0 A 1 j,k x k

102 82 Chapter 3. Harmonic Interpolation x 0 x 6 x x 5 4 x 3 x 1 x 2 Figure 3.20: Nonuniform harmonic interpolation of seven points. We illustrate some of the previous figures using non-uniform harmonic interpolation. In each figure uniform harmonic interpolation is compared to the non-uniform case. Note that the non-uniform curve ends before the uniform curve does. For the non-uniform case, we have selected t j as t j = 1 l j x k+1 x k, where n 2 l = x 0 x n 1 + x k+1 x k. The previous diagrams with seven and five points are illustrated in figures 3.21 and The non-uniform interpolation algorithm is applied for both the uniform and non-uniform interpolation. An example of the even case is illustrated in figure Conclusion In this chapter we have introduced harmonic interpolation for the drawing of curves. We have shown the reasoning behind harmonic interpolation and derived formulas for both an odd and even number of control points. We then proved the affine invariance property for harmonic interpolation. We also discovered that the convex hull property does not hold for harmonic interpolation. The relationship between Chebyshev polynomials and harmonic interpolation for both even and odd cases was investigated. The result

103 3.11. Conclusion 83 x 0 x 6 x 0 x 6 x x 5 4 x 3 x x 5 4 x 3 x 1 x 2 (a) Nonuniform harmonic interpolation x 1 x 2 (b) Harmonic interpolation Figure 3.21: A 7 sided polygon drawn by non-uniform and uniform harmonic interpolation. x 0 x 0 x 3 x 4 x 2 x 3 x 4 x 2 x 1 (a) Nonuniform harmonic interpolation x 1 (b) Harmonic interpolation Figure 3.22: A 5 sided polygon drawn by non-uniform and uniform harmonic interpolation. x 0 x 7 x 0 x 7 x 4 x 5 x 6 x 5 x 6 x 3 x 4 x 3 x 1 x 2 (a) Nonuniform harmonic interpolation x 1 x 2 (b) Harmonic interpolation Figure 3.23: An 8 sided polygon drawn by non-uniform and uniform harmonic interpolation.

104 84 Chapter 3. Harmonic Interpolation showed that harmonic interpolation in the even and odd cases are algebraic curves. We also obtained a fast way to evaluate points on a curve created by harmonic interpolation. Finally we discussed non-uniform trigonometric interpolation, and the potential techniques that can be used to achieve nonuniform harmonic interpolation. Results indicated that non-uniform harmonic interpolation tends to be less satisfactory, and we lose the periodicity. In this chapter we only discussed curves in 2D. In the next chapter we examine harmonic interpolation for surfaces and how some of the shortcomings may be addressed.

105 Chapter 4 Surfaces In chapter 2 and 3 we discussed existing curve drawing algorithms and harmonic interpolation for drawing curves. We now extend these algorithms to draw surfaces. The ability to interpolate surfaces is important for a variety of disciplines in computer graphics, models may be digitised so that they may be used and manipulated in digital form for animation purposes. In our discussions concerning surfaces, we will try to show how the techniques may be used to interpolate such data points. As in chapter 2, we do not try to produce an exhaustive list of techniques, but try to discuss the techniques that we will refer to. In so doing we try to discover a relationship between these surfaces and harmonic surfaces, although these relationships are not extensively analysed. We begin in the next section with a description of surfaces in the form we will work with, namely parametric surfaces. 4.1 Parametric Surfaces A surface is a set of points (usually in R 3 ), such that the surface can be described by a smooth function. A surface in R 2 is called a plane curve. We studied these curves in chapter 2. We refer to a surface in R 3 simply as a surface. We call a surface in R n, n > 3, a hypersurface. The function that we use to describe surfaces in R 3 is often of the form x 0 (u, v) f(u, v) = x 1 (u, v). x 2 (u, v) The surface is thus described by two parameters u and v. We thus call the surface a parametric surface. Other options are also possible, but parametric surfaces described by two parameters are quite common. An example of such 85

106 86 Chapter 4. Surfaces y z y z (0, 0) x (0, 0) x (a) Sphere (b) Torus Figure 4.1: Example parametric surfaces. a parametric surface is the sphere: sin u cos v f(u, v) = sin u sin v, (4.1) cos u with 0 u π and 0 v 2π. Another example of a parametric surface is the torus: (r 1 + r 2 cos v) cos u f(u, v) = (r 1 + r 2 cos v) sin u, (4.2) r 2 sin v with 0 u 2π and 0 v 2π. The sphere is shown in figure 4.1(a), and the torus in 4.1(b). Curves of constant u or v (isocurves) have been drawn as dashed lines to provide a better idea of the shape of the surface. Now that surfaces have been defined, we can introduce a specific form of parametric surfaces, namely tensor product surfaces. 4.2 Tensor Product Surfaces Suppose we can define a curve with control (or interpolation) points x k as q(v) := fk n (v)x k, where fk n (v) are the basis functions for the curve, and suppose further that we have defined m such curves q j (v) so that curve q j (v) is defined by the

107 4.2. Tensor Product Surfaces 87 points x j,k. Then each curve is defined as q j (v) := fk n (v)x j,k. If we choose a particular value for v on each of these curves, we then have m points which we can use to create another curve p. The curve p is then defined by p(u, v) := m 1 j=0 f m j (u)q j (v) = m 1 j=0 fj m (u) fk n (v)x j,k. The surface defined by all such curves is known as a tensor product surface and the curve of constant v is known as an isocurve. We can also choose to define n curves of m points each from the points x j,k. Defining a curve from points (defined by parameter u) on each of these curves will define precisely the same surface. So we can simply write the surface as p(u, v) = m 1 j=0 fj m (u)fk n (v)x j,k. In most cases we will choose n = m, but this is not required. If the functions fk n are such that the curves are affine invariant, then so is the surface. Likewise, if the curves produced using fk n have the convex hull property, then so does the surface. If the curve is affine invariant then j=0 fk n (t) = 1. For a surface we have ( m 1 ) fk n (v) fj m (u) = m 1 j=0 1 f m j (u) = 1, so that the surface is affine invariant. This is only one way to define a surface, in the next section we examine a few examples of Bézier tensor product surfaces. Thereafter we will discuss some surfaces not produced by tensor products.

108 88 Chapter 4. Surfaces 4.3 Bézier Surfaces Figure 4.2: Example Bézier surface patches. Since all the polynomial curves presented in chapter 2 can be represented as Bézier curves, it is sufficient to discuss Bézier surfaces. Algorithms to obtain control points so that the surfaces interpolate a data set is another problem that will be discussed separately Tensor Product Bézier Surfaces The tensor product Bézier surface is given by m n p(u, v) = Bj m (u)bk n (v)x j,k, j=0 where Bk n are the Bernstein polynomials introduced in chapter 2 in equation 2.2. The Bézier surface produced is known as a Bézier patch. Due to the properties of the Bernstein polynomials the surface is affine invariant and lies within the convex hull of the control points. An example of a Bézier surface is illustrated in figure 4.2. The surface is displayed in yellow, and the control polygon is displayed in blue. Bézier patches interpolate the corner points, but not necessarily the other points. We note that each boundary of the Bézier patch is a Bézier curve. The derivatives are given by m 1 p(u, v) n = m B m 1 j (u)bk n (v)(x j+1,k x j,k ), u p(u, v) v = n j=0 m j=0 B m j (u)b n 1 k (v)(x j,k+1 x j,k ).

109 4.3. Bézier Surfaces 89 Figure 4.3: A surface constructed from piecewise continuous Bézier patches [13]. Once the partial derivatives have been calculated the normal to the surface is given by p(u, v) p(u, v) n(u, v) :=, u v where denotes the cross product. Using the normals, we can define piecewise continuous Bézier surfaces. An example of such a surface is illustrated in figure 4.3. The surface consists of 32 Bézier patches [13]. de Casteljau s algorithm can be applied to efficiently render these surfaces. Tensor product Bézier surfaces are not the only possibility, next we consider a triangular Bézier surface Triangular Bézier Surfaces Instead of arranging the initial configuration of the control points in a rectangular fashion as with tensor product Bézier surfaces. We can arrange the control points in a triangle [1] as in figure 4.4. If the degree of the Bézier surface is n, then there are n + 1 control points on each side. The control points are x ijk, with i+j +k = n and i, j, k 0. The total number of control points is then n+1 (n + 1)(n + 2) k =. 2 k=1 Bézier triangles can be efficiently rendered using a variation of de Casteljau s method [1]. However, instead of the usual parameters, we must use barycentric coordinates. A triangle with vertices x 0, x 1 and x 2 can be described with

110 90 Chapter 4. Surfaces x 300 x 201 x 210 x 102 x 111 x120 x 003 x 012 x 021 x 030 barycentric coordinates as where Figure 4.4: A Bézier triangle control mesh. p(u, v) = x 0 + u(x 1 x 0 ) + v(x 2 x 0 ) = (1 u v)x 0 + ux 1 + vx 2, u, v 0, u + v 1. In terms of Bernstein polynomials the Bézier triangle is written as n p(u, v) = Bijk(u, n v)p ijk, i,j, i+j+k=n with the Bernstein polynomials defined by B n ijk(u, v) := n! i!j!k! ui v j (1 u v) k, i + j + k = n. The partial derivatives are given by p(u, v) = u p(u, v) v = i+j+k=n 1 i+j+k=n 1 B n 1 ijk (u, v)p i+1,j,k, B n 1 ijk (u, v)p i,j+1,k. The Bézier triangle has many of the same properties as Bézier patches. Bézier triangles are affine invariant, the surface interpolates the three corner control points and the surface lies within the convex hull of the control points. Bézier surfaces have been used effectively in N-patches or PN triangles [87]. The Bézier surfaces can be generalised to form so called S-patches, details can be found in [56].

111 4.4. B-Spline Tensor Product Surfaces Rational Bézier Surfaces In the same way that Bézier curves can be extended to rational Bézier curves, we can extend Bézier surfaces to rational Bézier surfaces to obtain further control of the surface. The surface is then given by (tensor product surface) p(u, v) = m j=0 m j=0 n Bm j (u)bk n(v)w j,kx j,k n Bm j (u)bn k (v)w. j,k Bézier Surface Interpolation Bézier surfaces are relatively easy to work with when designing an object. However, we often want to fit a Bézier surface to a set of points. To do so the Bézier surface must interpolate those points. This problem is addressed by Shirman in [76] and [77]. In the next section we will see an example of how B-splines can be used to interpolate data points. The B-splines are then used to produce Bézier patches that interpolate the data points. 4.4 B-Spline Tensor Product Surfaces With tensor products we can express the surface generated with B-splines as m n p(u, v) = N j (u)n k (v)x j,k, t [0, n 2]. j=0 B-spline surfaces are slightly easier to work with than Bézier surfaces, since continuity is automatically maintained. The question once again is how to interpolate with B-spline surfaces. We examine the answer to this question in the next section. As in the case of rational Bézier curves, NURBS surfaces can also be constructed as a tensor product surface. We omit the details. To interpolate a surface with NURBS, we have the problem of finding the control points, the weights associated with each point and the knot vector to use. We omit the details of such an algorithm here and refer the reader to [58] and [66]. In the next section we examine a simple algorithm by Watt & Watt [90] for B-spline surface fitting B-Spline Surface Interpolation Fitting a B-spline tensor product surface to a set of data points is a nontrivial task. The literature has a few pointers to how this can be done. Cheng

112 92 Chapter 4. Surfaces [12] discusses a parallel implementation of surface fitting. In their algorithm, they fit a B-spline tensor product surface to points on a regular grid. To do so, a system of equations must be satisfied. These equations are solved in parallel to improve performance. Greiner et al. [28] and [51] discuss hierarchical B-spline fitting. In the case of [28] the data set is assumed to be homeomorphic to a plane. This places some restrictions on the data which can be reconstructed. Under these assumptions the surface to be fit can be expressed by f(u i, v i ) = z i. First a spring model is used to determine the values u i and v i for each point. Once the parameterisation has been determined a system of equations is produced and solved to obtain the interpolating surface. Lee et al. [51] also create an initial parameterisation that is used to produce the B-spline surface. Hierarchies are created to improve performance of evaluating the B-spline approximation of the data. Optimisation is performed to find a surface that interpolates or approximates the data points at each level of the hierarchy. Wiley et al. [91] discuss hierarchical B-splines for approximation. In their approach, an initial course triangulation is generated, and a corresponding set of B-splines for the triangulation. An error metric is measured, and the triangle with highest error is subdivided. This approach builds a hierarchical set of B-splines that approximate the surface with different levels of detail. At each subdivision step the spline surface must be refitted. This involves solving a system of equations. Eck [22] discusses another approach based on the work of Hoppe [35]. The construction of the surface follows several steps: Construct an initial surface approximation using the algorithm of Hoppe [35]. This yields a dense mesh. Reparameterise over a simple triangular mesh, using harmonic maps. Merge triangles to produce a quadrilateral mesh. Fit a B-spline patch to each quadrilateral using the scheme of Peters [65]. This step involves optimisation of the control points. Adaptively refine the faces (B-spline patches) until a user specified tolerance is met. In all of the above algorithms, a set of equations must be solved or some optimisation must be performed. In the next example, we must also solve

113 4.4. B-Spline Tensor Product Surfaces 93 (a) (b) (c) (d) (e) Figure 4.5: B-spline surface fitting: curve network (after [90]). a system of equations. Here we will discuss the algorithm of Watt & Watt [90]. The algorithm consists of several steps, enumerated here. 1. The data points are separated into groups. Each group may have a different number of data points and a different knot vector. Taking slices of the data, may be one option. A curve is interpolated through each separate group, using the techniques listed in chapter 2. Each curve is parameterised using chord length parameterisation. Chord length parameterisation uses a heuristic to approximate arc length parameterisation, so that the parameter spacing coincides roughly with arc length. Chord length [24] is given by S = i x i = i x i t t, where x i = x i+1 x i. These curves will be known as the U-curves. This first stage is illustrated in figure 4.5(a). 2. A single knot vector must now be chosen for all the curves. The union of the distinct knot vectors will produce the desired knot vector the U-knot vector. 3. Each of the U-curves is updated so that the knot vector coincides with the U-knot vector as in figure 4.5(b). 4. The V -curves are obtained by selecting a knot from the U-knot vector and constructing a curve that interpolates the data points of each of the U-curves. Once again, chord length parameterisation is used. The V -curves thus intersect the U curves at points of constant u. The V -curves are illustrated in figure 4.5(c). 5. The V -curves do not intersect U-curves at points of constant v, so the knot vectors will differ. The knot vectors from the V -curves are

114 94 Chapter 4. Surfaces merged to form the V -knot vector. Each of the V -curves knot vectors are updated to coincide with the V -knot vector as illustrated in figure 4.5(d). The curve network has now been set up, the final result is illustrated in figure 4.5(e). The figure only illustrates curves of constant u or v. The network thus represents a B-spline tensor product surface. Watt & Watt [90] proceed to create Bézier patches from these curves as follows: 1. Each curve in the curve network is converted to cubic Bézier curves by multiple knot insertion. We thus have a series of parametrically discontinuous Bézier curve segments. The control points of the Bézier curves are uniquely determined by this process (since every cubic curve can be represented as a cubic Bézier curve). 2. Each rectangular region bounded by (u i, v j ), (u i+1, v j+1 ) is bounded by four Bézier curves from the previous step. These four curves are then converted into a Bézier patch. Once the Bézier boundary curves for each patch have been obtained, the interior control points must be determined. The Bézier patch is a tensor product surface given by p(u, v) = 3 3 Bj 3 (u)bk(v)x 3 j,k, j=0 where x 0,k, x 3,k, x j,0, and x j,3 have already been determined. The remaining interior points depend on the partial derivatives in both u and v of p(u, v), denoted by p uv (u, v). The vector p uv (u, v) is known as the twist vector. In the following we set p u = p u, p v = p v, p uv = 2 p u v. The derivative vectors of the Bézier patch at u = 0, v = 0 are given by [90] p u (0, 0) = 3(x 1,0 x 0,0 ), p v (0, 0) = 3(x 0,1 x 0,0 ), p uv (0, 0) = 9(x 0,0 x 0,1 x 1,0 + x 1,1 ).

115 4.5. Subdivision Surfaces 95 We can compute some of the points x j,k from these equations to get x 0,0 = p(0, 0) x 0,1 = p v(0, 0) 3 x 1,0 = p u(0, 0) 3 x 1,1 = p uv(0, 0) 9 + p(0, 0) + p(0, 0) + p u(0, 0) + p v (0, 0) 3 + p(0, 0). Let x be the point that makes x 0,0, x 0,1, x 1,0 and x a parallelogram. Then We thus have x = x 1,0 + x 0,1 x 0,0. x 1,1 x = (x 1,1 x 1,0 ) (x 0,1 x 0,0 ) = 9p uv. The vector x 1,1 x measures the deviation of the patch from the quadrilateral. If p uv (u, v) = 0 then there is no deviation and the Bézier patch is a planar surface. If we set p uv (u, v) = 0 at the patch corners then the patch is locally flat and produces pseudo-flats. To avoid these pseudo-flats Watt & Watt [90] suggest the use of Adini s method which considers the patch as part of a larger surface and computes the twist vector accordingly. The twist vector at a corner is computed from the four patches adjacent to this corner. The complete surface has a well defined twist given by p UV (U i, V j ) = p V (U i+1, V j ) p V (U i 1, V j ) + p U(U i, V j+1 ) p U (U i, V j 1 ) U i+1 U i 1 V j+1 V j 1 p(u i+1, V j+1 ) p(u i 1, V j+1 ) p(u i+1, V j 1 ) + p(u i 1, V j 1 ), (U i+1 U i 1 )(V j+1 V j 1 ) where U i and V j are surface level parameters and u and v are patch level parameters. The patch parameters u, v and surface level parameters U i, V j are related by u = U U i, v = V V j. U i+1 U i V j+1 V j Using the chain rule for differentiation we get p uv = (U i+1 U i )(V j+1 V j )p UV.

116 96 Chapter 4. Surfaces x 0 x 6 x 0 x 6 x x 5 4 x 3 x x 5 4 x 3 x 1 x 2 x 1 x 2 (a) P 0 (b) P 1 x 0 x 6 x 0 x 6 x x 5 4 x 3 x x 5 4 x 3 x 1 x 2 (c) P 2 x 1 x 2 (d) P Figure 4.6: Stages in subdivision using Chaikin s scheme. x 0 x 6 x 0 x 6 x x 5 4 x 3 x x 5 4 x 3 x 1 x 2 x 1 x 2 (a) P 0 (b) P 1 x 0 x 6 x 0 x 6 x x 5 4 x 3 x x 5 4 x 3 x 1 x 2 (c) P 2 x 1 x 2 (d) P Figure 4.7: Stages in interpolatory subdivision using the 4-point scheme.

117 4.5. Subdivision Surfaces Subdivision Surfaces In section we saw how to subdivide a Bézier curve using de Casteljau s method. With sufficient subdivision, the Bézier curve segments can be approximated by lines. If we proceed to subdivide an infinite number of times, the limit curve is the Bézier curve. Naturally we could then ask, are there other subdivision methods that can be used? Two such schemes are illustrated in figures 4.6 and 4.7. In figure 4.6 we use the initial control points for a seven sided polygon that has been used in the examples through out. We begin with the points x 0 i = x i, and proceed to subdivide the line segments using the formula x k+1 2i = 3 4 xk i xk i+1, x k+1 2i+1 = 1 4 xk i xk i+1. At each stage we have a polygon P k defined by the points x k i. In the limit we have a curve P. The scheme presented here is known as Chaikin s scheme [11]. Chaikin s scheme is an approximating curve. An alternative that interpolates the points of the curve is given by the 4-point scheme [21] x k+1 2i = x k i, x k+1 2i+1 = (1 2 + w)(xk i + x k i+1) + w(x k i 1 + x k i+2), where w R. The weight w is known as the tension parameter. When w = 0, we have linear interpolation. If 0 < w < 1/8, then the curve has C 1 continuity. Since we are examining periodic curves, the points x k i are calculated modulo (k + 1)n where n is the number of control or interpolation points. This scheme is illustrated in figure 4.7. In the same way that curves can be recursively subdivided, we can subdivide a surface control mesh. The tensor product Bézier surfaces can be modelled in this fashion, but subdivision is not limited to rectangular meshes. Subdivision curves and surfaces can be thought of as a two phase process [45]. The refinement phase creates new vertices and new polygons from the control mesh, and the smoothing phase computes new positions for some or all of the vertices in the new control mesh. A subdivision scheme can be categorised as stationary if the same subdivision rules are used at every subdivision step. A non-stationary scheme changes the rules according to the subdivision step.

118 98 Chapter 4. Surfaces A uniform scheme uses the same rules for every vertex or edge, while nonuniform may use different rules for each vertex or edge. Often, the rule selected may depend on the valence of the vertex. The valence of a vertex x on the subdivision surface is the number of neighbouring vertices, that is the number of vertices connected to x by an edge. In the next sections we discuss some of the subdivision algorithms described in the literature [1]. For a more comprehensive treatment refer to the SIG- GRAPH 2000 course notes [92] Loop Subdivision Loop s [55] subdivision scheme works on triangles. The surface is an approximating surface. A new vertex is added for each edge, at each subdivision step. A vertex with valence 6 is known as regular or ordinary, otherwise it is known as irregular or extraordinary. At each subdivision step, the existing point x k is updated with the scheme x k+1 = (1 nβ)x k + β yi k, where yi k are the n neighbouring vertices, and β is a constant determined by x k (shown later). For each edge connecting x k to a neighbour, a new vertex is created via x k+1 i=0 i = 3xk + 3yi k + yi 1 k + yi+1 k, i = 0,..., n 1. 8 The subscripts i are calculated modulo n. The arrangement of the neighbouring vertices and notation is illustrated in figure 4.8. Once the new vertices have been determined, each triangle is subdivided into four triangles as in figure 4.9. Figure 4.9(a) shows the original mesh, 4.9(b) adds the new points and 4.9(c) illustrates the mesh after triangle subdivision. Often a mask or stencil is used to visualise the subdivision. The entries in the mask are the weights for the contributing points. The masks for Loop subdivision are illustrated in figure We note that the sum of the weights is 1 for both the vertex and edge mask. The mask consists of edges and vertices. The vertices are connected by lines (edges). The entry at the vertex is the weight which is multiplied by the vertex to obtain the contribution of that vertex. The edges are not arbitrary, if three edges form a triangle, then that triangle must be a face of the object.

119 4.5. Subdivision Surfaces 99 y k 1 y k 0 y k n 1 y k 4 x k y k 3 y k 2 subdivision x k+1 0 x k+1 n 1 x k+1 4 x k+1 1 x k+1 x k+1 2 x k+1 3 Figure 4.8: Notation for Loop subdivision. (a) (b) (c) Figure 4.9: Triangle subdivision for Loop subdivision (after [45]). β 3/8 β β 1 nβ β 1/8 1/8 β β 3/8 (a) Vertex mask (b) Edge mask Figure 4.10: Masks for Loop subdivision.

120 100 Chapter 4. Surfaces (a) (b) (c) (d) Figure 4.11: First four steps of a cube subdivided with Loop subdivision.

121 4.5. Subdivision Surfaces 101 (a) (b) (c) (d) Figure 4.12: First four steps of a star shape subdivided with Loop subdivision. (a) Cube mesh (b) Star mesh Figure 4.13: Limit surfaces (Loop subdivision).

122 102 Chapter 4. Surfaces The constant β is actually a function of n, the number of neighbouring vertices. Loop [55] suggests the function β(n) = 1 ( ) 5 (3 + 2 cos(2π/n))2. n 8 64 Möller and Haines [1] suggests the alternative by Warren and Weimer [89] β(n) = 3 n(n + 2). In both cases the surface is C 2 at vertices of regular valence, and C 1 otherwise. The scheme listed so far can only work on closed surfaces. The scheme needs to be adjusted for open surfaces. We refer the reader to Loop [55] for a discussion of these boundary problems. The surface generated is affine invariant and lies entirely in the convex hull of its control points (see section for the definition of the complex hull). Two limit tangents can be computed by a weighted sum of the immediate control points or 1-ring, or 1-neighbourhood of a point x k. The tangents are t u = cos(2πi/n)yi k, t v = sin(2πi/n)yi k. i=0 The normal vector is then given by n = t u t v. The resulting surface is quite fair [61]. Informally that means the surface bends quite smoothly. Figure 4.13 illustrates the limit surfaces of the examples provided in this section. i= Modified Butterfly Subdivision The modified butterfly scheme [93] is an interpolating scheme which operates on triangles. Since the surface is interpolating, none of the existing vertices are modified. The scheme is nonuniform in the sense that different rules are used according to the valence of the vertices (and for boundaries). New vertices are created for each edge, and faces are created in the same way as the loop subdivision scheme (figure 4.9). The rules selected for new vertices, depending on the valence, are as follows Regular: When two vertices x i and x j are connected by an edge and both x i and x j have regular valence (6 neighbours), then we call this setting regular. The mask used to construct the new edge point is illustrated in figure 4.14(a).

123 4.5. Subdivision Surfaces 103 1/16 1/8 1/16 w 1 1 w i 1/2 1/2 w 0 w 2 w n 1 1/16 1/8 1/16 w4 w 3 (a) Regular setting (b) Semiregular setting Figure 4.14: Masks for modified butterfly subdivision (after [1]). Semiregular: We have a semiregular setting if one of the vertices of the edge is regular (6 neighbours), and the other is irregular (valence 6). In this case we compute the new vertex using a set of weights calculated from the valence n of the irregular vertex. The weights are given by n = 3 : w 0 = 5/12, w 1 = 1/12, w 2 = 1/12. n = 4 : w 0 = 3/8, w 1 = 0, w 2 = 1/8, w 3 = 0. n 5 : w j = cos(2πj/n) cos(4πj/n), n where j = 0, 1,..., n 1. The calculation of the new vertex is illustrated in figure 4.14(b). Irregular: If both vertices of an edge are irregular (valence 6), then the semiregular approach is used with each vertex taking the role of the regular vertex in turn. The two points created are then averaged to provide the final new edge point. From figure 4.14(a) we can see that the modified butterfly scheme uses the 2-ring or 2-neighbourhood of the vertex to be created. For boundary cases we refer the reader to [92]. Examples of the modified butterfly scheme are illustrated in figures 4.15 and The limit surfaces are illustrated in figure Subdivision The previous subdivision schemes split each triangle into four new triangles. Kobbelt s 3 subdivision scheme creates only three new triangles for each triangle. The scheme thus has a lower triangle growth rate than the previous

124 104 Chapter 4. Surfaces (a) (b) (c) (d) Figure 4.15: First four steps of a cube subdivided with modified butterfly subdivision.

125 4.5. Subdivision Surfaces 105 (a) (b) (c) (d) Figure 4.16: First four steps of a star shape subdivided with modified butterfly subdivision. (a) Cube mesh (b) Star mesh Figure 4.17: Limit surfaces (Modified butterfly subdivision).

126 106 Chapter 4. Surfaces schemes. The lower growth rate implies that more levels of detail are available when applying the subdivision algorithm. In this scheme a new vertex is created in the middle of each triangle, instead of each edge. New points are added for each face by x k+1 m = 1 3 (xk a + x k b + x k c), where x k+1 m is the new point and x k a, x k b and xk c are the vertices of the triangle for which the new point is created. Existing points are updated with the rule x k+1 = (1 nβ)x k + β yi k, where β is a positive constant determined by x k. β is a function of the valence n of the point x k. This subdivision scheme is thus an approximating scheme. Kobbelt [45] suggests the following choice for β(n) i=0 β(n) = 4 2 cos(2π/n) 9n This choice generates a surface that is C 2 continuous except at irregular vertices (n 6). At the irregular vertices the continuity is at least C 1. Masks for the update of vertices and addition of new vertices are shown in figure One final detail of the subdivision scheme must be mentioned. After new triangles are created, the old edges are flipped so that the subdivision is similar to the original triangle mesh. The process is illustrated in figure Figure 4.19(a) shows the initial triangle mesh, figure 4.19(b) illustrates the addition of new vertices, figure 4.19(c) performs the subdivision step (creating new triangles) and figure 4.19(d) illustrates the mesh after the old edges are flipped. After two subdivision steps, a triangle is divided into 9 triangles, and an edge is split into 3 edges. Hence the name 3 subdivision. The surface produced has the convex hull property, and is affine invariant. Open surfaces must be dealt with differently. We refer the reader to Kobbelt [45] for a discussion of the algorithm dealing with boundaries. Figure 4.22 illustrates the limit surfaces for the examples given in this section Interpolating 3 Subdivision Labsik and Greiner [50] have applied the 3 subdivision approach to interpolation. The resulting interpolating 3 subdivision uses the same triangle subdivision as illustrated in figure Since the scheme interpolates, all.

127 4.5. Subdivision Surfaces 107 β 1/3 β β 1 nβ β 1/3 β β 1/3 (a) Vertex mask (b) Face mask Figure 4.18: Masks for 3 subdivision (after [1]). (a) (b) (c) (d) Figure 4.19: Triangle subdivision for 3 subdivision (after [45]).

128 108 Chapter 4. Surfaces (a) (b) (c) (d) Figure 4.20: First four steps of a cube subdivided with 3 subdivision.

129 4.5. Subdivision Surfaces 109 (a) (b) (c) (d) Figure 4.21: First four steps of a star shape subdivided with 3 subdivision. (a) Cube mesh (b) Star mesh Figure 4.22: Limit surfaces ( 3 subdivision).

130 110 Chapter 4. Surfaces 2/81 2/81 1/81 32/81 1/81 w 1 w 2/81 32/81 32/81 2/81 w 0 w 2 w n 1 2/81 1/81 2/81 (a) Regular setting w4 w 3 (b) Semiregular setting Figure 4.23: Masks for interpolating 3 subdivision. existing vertices are left unchanged. A new vertex is created for each triangle. It is clear from the mask for a new point (illustrated in figure 4.23(a)) that we need the 2-ring or 2-neighbourhood to compute the new vertex. As in the previous cases, we will only consider closed surfaces. Boundaries are discussed by Labsik and Greiner [50]. The mask illustrated is only applicable for vertices of valence 6. Thus, as in the modified butterfly scheme, several different rules are necessary. The rules determine weights that are used as in figure 4.23 when irregular vertices are present in the triangle considered. We will not discuss the weights further here, as they are not trivially obtained, instead we refer the reader to [50]. We thus have three cases Regular: If all vertices have regular valence, the mask in figure 4.23(a) is applied. Semiregular: If one vertex is irregular, then the mask in figure 4.23(b) is used for the irregular vertex. Irregular: If two or more vertices are irregular, then the mask in figure 4.23(b) is applied for each irregular vertex and the average of these points is taken as the new vertex Catmull-Clark Subdivision Catmull-Clark subdivision [8] is not restricted to triangle meshes but can divide polygonal meshes too. DeRose [15] has shown how Catmull-Clark subdivision surfaces have been used effectively in the making of animated films, and how sharp edges may be produced with Catmull-Clark surfaces,

131 4.5. Subdivision Surfaces 111 as illustrated by Hoppe [36]. Catmull-Clark surfaces are also affine invariant and lie within the complex hull of the control mesh that generates the surface. Also, since we are no longer restricted to triangles, many of the surfaces generated are more symmetrical. Compare figure 4.25 to figure 4.26, simply using quadrilaterals for the cube faces causes a definite improvement in the symmetry. For Catmull-Clark surfaces new points are created on the edges and faces. Our previous notation is no longer entirely adequate for the algorithm so we vary the notation slightly so that it corresponds to that of Halstead [30]. New face points are created with the rule f k+1 j = 1 vi k, n where v i are the vertices of the j th face, and n is the number of vertices for that face. The level of subdivision is indicated by k. Existing vertices are updated with the rule i=0 v k+1 = n 2 n vk + 1 e k n 2 i + 1 f k+1 n 2 i, where n is the valence of this vertex, e k i are the neighbours (vertices in the 1-ring) of v k, and f k+1 i are the new face points created. In this case only the new face points of the faces to which this vertex belongs is considered. New edge points are created with the rule i=0 i=0 e k+1 i = 1 4 (vk + e k i + f k+1 i 1 + f k+1 j ), where v k and e k i are the endpoints of the considered edge, f k+1 i 1 and f k+1 j are the new face points of the faces adjacent to the considered edge (of which the edge is a part). One these vertices are created, new polygons are created as in figure Figure 4.24(a) shows the original mesh, figure 4.24(b) shows the addition of new points and figure 4.24(c) illustrates how the points are connected to form new polygons. After the first subdivision, all polygons are quadrilaterals. Catmull-Clark surfaces are important because of their modelling capabilities and the existence of an efficient evaluation algorithm (by Bolz and Schröder [4]). Figures 4.25, 4.26, 4.27 and 4.28 illustrate the application of the Catmull-Clark scheme for triangular and quadrilateral meshes. The limit surfaces are shown in figure Doo-Sabin Subdivision Doo-Sabin subdivision surfaces [18] are also not restricted to triangles. The resulting surface is affine invariant and lies within the convex hull of the

132 112 Chapter 4. Surfaces (a) (b) (c) Figure 4.24: Subdivision for the Catmull-Clark scheme (after [1]). (a) (b) (c) (d) Figure 4.25: First four steps of a triangulated cube subdivided with Catmull-Clark subdivision.

133 4.5. Subdivision Surfaces 113 (a) (b) (c) (d) Figure 4.26: First four steps of a cube subdivided with Catmull-Clark subdivision.

134 114 Chapter 4. Surfaces (a) (b) (c) (d) Figure 4.27: First four steps of a triangulated star shape subdivided with Catmull- Clark subdivision. (a) (b) (c) (d) Figure 4.28: First four steps of a star shape subdivided with Catmull-Clark subdivision.

135 4.5. Subdivision Surfaces 115 (a) Cube mesh (b) Star mesh (a) Cube mesh (quadrilaterals) (b) Star mesh (quadrilaterals) Figure 4.29: Limit surfaces (Catmull-Clark subdivision).

136 116 Chapter 4. Surfaces control polygon. For each face f we create new vertices x f i = α ij x j, where x j are the vertices of the face. The constants α ij are given by j=0 α ii = n + 5 4n cos(2π(i j)/n) α ij =, j i. 4n Once the new vertices are created the faces for the next step of the subdivision surface can be determined. Faces are obtained in three different ways: 1. By creating a polygon from the vertices x f 0, x f 1,..., for a face f. 2. If x i and x j form an edge of the original surface, then a polygon is created from the vertices x f i, xg i, xf j and x g j, where f and g are the faces sharing the edge. 3. By creating a polygon from the vertices x f m, x g m,..., for a vertex x m. Examples of the Doo-Sabin algorithm are illustrated in figures 4.30, 4.31, 4.32 and As is the case with Catmull-Clark surfaces, we find that Doo- Sabin surfaces are more symmetrical if quadrilaterals are used. The limit surfaces are illustrated in figure Comparison The subdivision schemes do not interpolate the control points (except the modified butterfly scheme), however, when the mesh has sufficient detail the limit surface is quite close to the original shape. To compare the subdivision surfaces we have rendered the mannequin head introduced in Hoppe s PhD thesis [35] with the various subdivision schemes. The results are illustrated in figure Triangles were used for all the subdivision schemes. We note that the modified butterfly scheme seems more erratic at the edges, but maintains more of the original mesh character. Table 4.1 compares the subdivision scheme in terms of the primitives supported for subdivision, whether the scheme is interpolating and the smoothness of the limit surfaces for regular meshes.

137 4.5. Subdivision Surfaces 117 (a) (b) (c) (d) Figure 4.30: First four steps of a triangulated cube subdivided with Doo-Sabin subdivision. Scheme Triangles Polygonal Interpolating Continuity Loop yes no no C 2 Modified butterfly yes no yes C 1 3 yes no no C 2 Catmull-Clark yes yes no C 2 Doo-Sabin yes yes no C 1 Table 4.1: Comparison of subdivision schemes.

138 118 Chapter 4. Surfaces (a) (b) (c) (d) Figure 4.31: First four steps of a cube subdivided with Doo-Sabin subdivision.

139 4.5. Subdivision Surfaces 119 (a) (b) (c) (d) Figure 4.32: First four steps of a triangulated star shape subdivided with Doo- Sabin subdivision.

140 120 Chapter 4. Surfaces (a) (b) (c) (d) Figure 4.33: First four steps of a star shape subdivided with Doo-Sabin subdivision Interpolation with Subdivision Surfaces In this section we mention a few techniques that have been employed to obtain interpolating surfaces from subdivision surfaces that do not naturally interpolate. Hoppe et al. [36] discuss how to construct an interpolating Loop subdivision surface. The surface is constructed through a number of phases, most described in Hoppe s PhD thesis [35], and finally involves the minimisation of an energy function. Halstead [30] describes a technique for forming interpolating Catmull-Clark surfaces. To interpolate, a system of linear equations must be solved (determined by the limit surface and interpolation points) for the new control mesh. The new control mesh can then be subdivided using the usual Catmull-Clark scheme. Finally, Litke [54] shows how Quasi-Interpolation can be used to generate interpolating Catmull-Clark surfaces within a certain tolerance. 4.6 Curvature of Surfaces To measure the quality of a curve, we introduced curvature. In a similar fashion, we can describe the quality of a surface by surface curvature. In the

141 4.6. Curvature of Surfaces 121 (a) Cube mesh (b) Star mesh (a) Cube mesh (quadrilaterals) (b) Star mesh (quadrilaterals) Figure 4.34: Limit surfaces (Doo-Sabin subdivision).

142 122 Chapter 4. Surfaces (a) Original mesh (b) Loop subdivision (c) 3 subdivision (d) Modified butterfly subdivision (e) Catmull-Clark subdivision (f) Doo-Sabin subdivision Figure 4.35: Subdivision of the mannequin head.

143 4.6. Curvature of Surfaces 123 discussion that follows, we assume that we have a parametric surface defined by x(u, v) = ( x 0 (u, v) x 1 (u, v) x 2 (u, v) ) T. Any curve on the surface can be defined by the points x(u, v) for some relation ψ(u, v) = 0. We are primarily interested in two such curves, namely a(u) = x(u, v) with v constant and b(v) = x(u, v) with u constant. The partial derivatives da = x db and = x of these coordinate curves both define du u dv v tangent vectors to the respective curves and the surface. These tangents are called the basic vectors of the surface. If we define a parametric curve r(t) := x(u(t), v(t)) on the surface by u = u(t) and v = v(t), then the arc length or distance on the curve between two points specified by parameters t 1 and t 2 is given by [24] t2 E u2 + 2F u v + G v 2 dt t 1 with u = du dv, v = and dt dt E(u, v) := x u x u F (u, v) := x u x v where denotes the scalar product. The equation G(u, v) := x v x v, ds 2 = E(du) 2 + 2F dudv + G(dv) 2 is known as the first fundamental form. The normal to the surface is given by n(u, v) = x u x v x u x v, with x u = x and x u v = x and denotes the vector product. The angle θ v at which two curves, a(t) and b(t), on the surface intersect is given by [17] cos θ = ȧ(t 0) ḃ(t 0) ȧ(t 0 ) ḃ(t 0), where the curves intersect at t = t 0. The angle ψ between the coordinate curves of the parameterised surface x(u, v) is thus given by [17] cos ψ = x u x v x u x v = F EG. If F (u, v) = 0 for all u and v the curves are orthogonal and we have an orthogonal parameterisation of the surface. Now suppose we have the arc

144 124 Chapter 4. Surfaces length parameterisation of the curve r on the surface, u = u(s) and v = v(s). The tangent of the curve is then given by t = dr ds = x du u ds + x dv v ds, by application of the chain rule. If we differentiate t with respect to the arc length s we obtain dt ds = x d 2 u u ds + x ( ) d 2 2 ( ) ( ) ( ) 2 v 2 v ds + 2 x du x du dv + 2 x dv. 2 u 2 ds u v ds ds v 2 ds Taking the dot product (scalar product) with the normal vector n on both sides yields ( ) 2 ( ) ( ) ( ) 2 dt du du dv dv ds n = L + 2M + N ds ds ds ds with L := n 2 x 2 x M := n N := n 2 x u 2 u v v. 2 L, M and N are coefficients of the second fundamental form. Now the curvature vector of the curve at the point determined by u and v is given by k = dt ds = κm, where m is the main normal (or principal normal) of the curve. If we take the dot product with n, the normal of the surface, we obtain dt n = κ cos φ, ds where φ is the angle between n and m. From the above we obtain the equation for the second fundamental form [24] κ cos φ ds 2 = Ldu 2 + 2Mdudv + Ndv 2. If we divide the second fundamental form by the first, and consider the case when φ = 0 we obtain κ 0 = 1 ρ 0 = L + 2Mλ + Nλ2 E + 2F λ + Gλ 2, with λ = dv du = dv. The radius of the osculating circle is ρ ds ds du 0 at the point determined by u and v. We have the following relationship for curves on the surface ρ = ρ 0 cos φ.

145 4.6. Curvature of Surfaces 125 Meusnier s theorem [24] states that all osculating circles of all the curves on the surface that pass through the point under consideration, and have the same tangent t, form a sphere. The radius of the sphere is ρ 0. We thus need only consider curves for which the main normal m is equal to n. If L = E, M = F and N = G, then the curvature is independent of λ and the point under consideration is known as an umbilical point. Otherwise the curvature is a function of λ. The extreme values of the curvature κ(λ) occur at the roots λ 1 and λ 2 of [24] λ 2 λ 1 E F G L M N = 0, where A is the determinant of the matrix A. The solutions λ 1 and λ 2 correspond to directions on the u v plane. The corresponding directions in the tangent plane are known as principal directions and the values κ 1 = κ(λ 1 ) and κ 2 = κ(λ 2 ) are known as principal curvatures. The values of κ 1 and κ 2 are the roots of [24] κe L κf M κf M κg N = 0. Suppose κ is a polynomial of degree 2, then (κ κ 1 )(κ κ 2 ) = 0 can be used to compute the values κ 1 and κ 2. If we compare this answer to the determinant above we obtain the Gaussian curvature and the mean curvature κ 1 + κ 2 = κ 1 κ 2 = LN M 2 EG F 2 NE 2MF + LG EG F 2. The mean curvature measures the average curvature of perpendicular curves in the surface. The Gaussian curvature is often used to measure the quality of a surface. For a further discussion of surface curvature, we refer the reader to the well known text by Farin [24]. Example 1. We consider the helicoid, constructed from a helix (spiral) by drawing a line from every point on the helix to the x 2 axis, parallel to the plane formed from the x 0 and x 1 axes. The helicoid is parameterised by x(u, v) = (v cos u, v sin u, au).

146 126 Chapter 4. Surfaces The partial derivatives are x u = x v = 2 x u 2 = 2 x v 2 = 2 x u v = v sin u v cos u a cos u sin u 0 v cos u v sin u sin u cos u. 0 The coefficients of the first fundamental form are given by E(u, v) = v 2 sin 2 u + v 2 cos 2 u + a 2 = v 2 + a 2 F (u, v) = v sin u cos u + v sin u cos u + 0 = 0 G(u, v) = cos 2 u + sin 2 u + 0 = 1. Since F (u, v) = 0 we have an orthogonal parameterisation. The normal to the surface is given by x u x a sin u v = a cos u, v and after normalising we obtain a sin u 1 n(u, v) = a cos u. a2 + v 2 v Now we can compute the coefficients of the second fundamental form to

147 4.6. Curvature of Surfaces 127 obtain L = M = 1 (av sin u cos u av sin u cos u + 0) = 0 a2 + v2 1 a2 + v 2 (a sin2 u + a cos 2 u + 0) = a a2 + v 2 N = 1 a2 + v 2 0 = 0. We find that the Gaussian curvature is The mean curvature is given by κ 1 κ 2 = LN M 2 EG F 2 = a 2 (a 2 + v 2 ) 2. κ 1 + κ 2 = NE 2MF + LG EG F 2 = 0. Example 2. In this example we consider the sphere of radius r parameterised by r sin u cos v x(u, v) = r sin u sin v. r cos u The partial derivatives are r cos u cos v x u = r cos u sin v r sin u x v = 2 x u 2 = 2 x v 2 = 2 x u v = r sin u sin v r sin u cos v 0 r sin u cos v r sin u sin v r cos u r sin u cos v r sin u sin v 0 r cos u sin v r cos u cos v. 0

148 128 Chapter 4. Surfaces The coefficients of the first fundamental form are given by E(u, v) = r 2 cos 2 u cos 2 v + r 2 cos 2 u sin 2 v + r 2 sin 2 u = r 2 F (u, v) = r 2 cos u sin u cos v sin v + r 2 cos u sin u cos v sin v 0 = 0 G(u, v) = r 2 sin 2 u sin 2 v + r 2 sin 2 u cos 2 v = r 2 sin 2 u. Since F (u, v) = 0 we have an orthogonal parameterisation. The normal to the surface is given by x u x sin u cos v v = r2 sin u sin u sin v cos u so that sin u cos v n(u, v) = sin u sin v. cos u The coefficients of the second fundamental form are L = r sin 2 u cos 2 v r sin 2 u sin 2 v r cos 2 u = r M = r sin u cos v cos u sin v + r cos u cos v sin u sin v + 0 = 0 N = r sin 2 u cos 2 v r sin 2 u sin 2 v + 0 = r sin 2 u. We find that the Gaussian curvature is constant. The mean curvature is also constant. κ 1 + κ 2 = 4.7 Conclusion κ 1 κ 2 = LN M 2 EG F 2 = 1 r 2 NE 2MF + LG EG F 2 = 2 r We have discussed various forms of surfaces including tensor product and subdivision surfaces. We have also briefly discussed some examples of fitting surfaces to unorganised points. To evaluate surfaces, the notion of curvature for surfaces was introduced. In the next chapter we introduce surfaces produced by harmonic interpolation. Since harmonic interpolation naturally interpolates the points, we will also investigate surface fitting of unorganised points using harmonic interpolation.

149 Chapter 5 Harmonic Surfaces In this chapter we see how harmonic surfaces can be created. We begin with the tensor product surface, the surface we will concentrate on. The potential of applying a subdivision algorithm to produce subdivision curves is discussed, and finally, an algorithm for fitting a harmonic surface to unorganised data points is discussed. The surface attempts to exploit the periodic and interpolating characteristics of harmonic interpolation. In the process we prove some useful theorems allowing us to find alternative representations of a curve created using harmonic interpolation. One of the theorems allows us to add interpolation points to curves produced by harmonic interpolation. We end off this chapter by discussing how harmonic surfaces can be represented by Bézier patches. 5.1 Tensor Product Surface The tensor product harmonic surface is given by p(u, v) = m n σj m (u)σk n (v)x j,k, j=0 where we define σk n (t) as sin(nπt) σk n (t) := σ n (t k/n), σ n n sin(πt), (t) := cos(πt) sin(nπt) n sin(πt), if n is odd if n is even. Unlike Bézier patches, harmonic surface parameter values must be chosen carefully. Since harmonic interpolation is periodic, we may duplicate the 129

150 130 Chapter 5. Harmonic Surfaces (a) Sphere (b) Torus Figure 5.1: Tensor product harmonic surfaces. surface at certain points. We illustrate two simple examples, the sphere and torus. For a sphere, we can use four points arranged in a diamond shape, and rotate the points 90. By duplicating control points at the poles we have 16 control points. There are thus four control points at each pole. Each set of 4 horizontal or vertical control points describes a circle. Creating a harmonic surface with parameter values 0 u 1 and 0 v 1 will duplicate the surface. Instead we stop halfway with one of the parameters, say 0 u 0.5. A torus is simply created by taking the same initial diamond shape, translating to the radius of the torus and rotating through 90 three times to obtain 16 control points. A simplified polygonal version of the sphere and torus were obtained by sampling the harmonic surface at equally spaced parametric values. The results obtained are illustrated in figure 5.1. The interpolation points are overlaid, ignoring visibility so that the simple structure used can be seen. 5.2 Subdivision To see that harmonic subdivision surfaces are a possibility, we rewrite harmonic interpolation into a subdivision form. We have (shown later in theorem 5.3) where σ k (t)x k = y j = 2n 1 σ k (t)y k, ( ) j σ k x k. 2n We can thus add n points to the existing n and still have the same curve. If we repetitively iterate this process, the limit curve is the same as that

151 5.3. Surface Fitting - Interpolation 131 produced by harmonic interpolation. We note that y 2j = x j. We thus have the following subdivision scheme x k+1 2i = x k i, n 1 x k+1 2i+1 = j=0 ( ) 2i + 1 σ j x k j. 2n The steps in repeated subdivision are shown in figure 5.2. The harmonic subdivision scheme is significantly slower than the other subdivision schemes. Both the use of trigonometric functions as opposed to polynomials and the fact that the σ k basis functions for harmonic interpolation do not have local support. Thus to get an accurate calculation of one surface point, all the points in the mesh have to be used. This becomes particularly difficult when trying to determine what masks can be used for an arbitrary mesh. The mask would have to be large enough to cover all points in the polygon. In addition, the requirement for periodicity must be met by the mask used. In the case where the interpolation points can be arranged to produce a tensor product surface, the task is somewhat simpler. To illustrate, we subdivide the control points of the torus. The process is illustrated in figure 5.3. Since we have a tensor product surface, we subdivide on parameter u and then parameter v for each subdivision step. The same process has been applied in figures 5.4 and 5.5 to deformed tori. 5.3 Surface Fitting - Interpolation In this section we apply harmonic interpolation to surface fitting. Our goal is not to produce a robust or accurate surface fitting algorithm, but to instead try to determine what quality of surface is produced by harmonic interpolation. We thus try to develop surface fitting algorithms that use harmonic interpolation for the surface, rather than other (perhaps more effective) techniques. We need two important results for the surface fitting algorithm. The first one involves rotation of the control points. We call the procedure rotation because we will evaluate new control points that are parametrically further along the curve than the original control points, and the curve is periodic. The uniform harmonic curve interpolates the control points at t = j, j Z. That is n n 1 ( ) j σ k x k = x j. n

152 132 Chapter 5. Harmonic Surfaces x 0 x 6 x 0 x 6 x x 5 4 x 3 x x 5 4 x 3 x 1 x 2 x 1 x 2 (a) P 0 (b) P 1 x 0 x 6 x 0 x 6 x x 5 4 x 3 x x 5 4 x 3 x 1 x 2 (c) P 2 x 1 x 2 (d) P Figure 5.2: Stages in harmonic subdivision.

153 5.3. Surface Fitting - Interpolation 133 (a) Original mesh (b) First subdivision step (c) Second subdivision step (d) Seventh subdivision step Figure 5.3: Stages in subdivision to produce a torus.

154 134 Chapter 5. Harmonic Surfaces (a) Original mesh (b) First subdivision step (c) Second subdivision step (d) Seventh subdivision step Figure 5.4: Stages in subdivision to produce a deformed torus.

155 5.3. Surface Fitting - Interpolation 135 (a) Original mesh (b) First subdivision step (c) Second subdivision step (d) Seventh subdivision step Figure 5.5: Stages in subdivision to produce a stretched.

156 136 Chapter 5. Harmonic Surfaces Since the curve is periodic we have ( ) j σ k n + 1 x k = x j. So we could define the harmonic interpolation as σ k (t + 1)y k, where ( ) j y j = σ k n + 1 x k. The generalisation follows in the following theorem. Theorem 5.1. Rotation by a parameter value o will be written as σ k (t)y k, where We have ( ) j y j = σ k n + o x k. σ k (t + o)x k = σ k (t)y k. Proof. We consider the even and odd cases separately. Odd case (n = 2m + 1) From equation 3.9 we see that m ( ) J u = P 0 + λ ju P j + λ ju P j. j=1 To permutate the control points of polygon X we evaluate J u X. To apply two permutations in sequence, J u and J s, we evaluate J u J s X.

157 5.3. Surface Fitting - Interpolation 137 We thus need to calculate ( m ( ) ) ( m ( ) ) J u J s = P 0 + λ ju P j + λ ju P j P 0 + λ js P j + λ js P j. j=1 j=1 From section 3.1 we know that P j P k = 0 for j k and P 2 j = P j so that J u J s = P 0 + m ( ) λ j(u+s) P j + λ j(u+s) P j = J u+s. j=1 Let s = on, and u = nt. We also know how to calculate the entries of J s X from equation The entries are n 1 σ k(o)x k J on σ k(o + 1 )x n k n 1 X = σ k(o + 2 )x n k.. n 1 σ k(o + n 1)x n k The harmonic interpolation of the polygon J s X is given by J u J s X = J u+s X. If we only consider the first entry of J u J s X we have J u+s X = J u J s X σ k (t + o)x k = σ k (t)y k, with Even case (n = 2m) 3.18 we see that ( ) j y j = σ k n + o x k. The proof in the even case is similar. From equation J u = P 0 + ( 1) u P m + m 1 j=1 ( λ ju P j + λ ju P j ). To permutate the control points of polygon X we evaluate J u X.

158 138 Chapter 5. Harmonic Surfaces To apply two permutations in sequence, J u and J s, we evaluate We thus need to calculate ( J u J s = P 0 + ( 1) u P m + ( J u J s X. m 1 j=1 P 0 + ( 1) s P m + ( λ ju P j + λ ju P j ) ) m 1 j=1 ( λ js P j + λ js P j ) ). Once again we use P j P k = 0 for j k and P 2 j = P j so that J u J s = P 0 + ( 1) (u+s) P m + m 1 j=1 ( λ j(u+s) P j + λ j(u+s) P j ) = J u+s. Let s = on, and u = nt. We also know how to calculate the entries of J s X from equation The entries are n 1 σ k(o)x k J on σ k(o + 1 )x n k n 1 X = σ k(o + 2 )x n k,. n 1 σ k(o + n 1)x n k where σ k has been defined in equation The harmonic interpolation of the polygon J s X is given by J u J s X = J u+s X. If we only consider the first entry of J u J s X we have with J u+s X = J u J s X σ k (t + o)x k = σ k (t)y k, ( ) j y j = σ k n + o x k. This theorem allows us to place the control points in a more convenient arrangement in certain situations. In the next theorem, we show that we can replace the existing n control points by n + m new control points and still have the same curve.

159 5.3. Surface Fitting - Interpolation 139 Theorem 5.2. For every curve q(t) produced by harmonic interpolation of n points, the same curve can be produced by harmonic interpolation of n + m (possibly different) points determined by q(t). Given x k, there exists y k so that σk n (t)x k = n+m 1 σ n+m k (t)y k. Proof. In section 2.13 we introduced Lagrange interpolation by solving the system of equations q(t j ) = x j, t j = 2πj, with n m q(t) = a 0 + (a k cos kt + b k sin kt), k=1 for a k and b k. This was only applied to the case where n is odd. In section 3.2 we saw that this corresponds precisely to harmonic interpolation with n odd. In particular we note the similarity between equations 3.11 and Likewise, when n is even (n = 2m), we find harmonic interpolation corresponds to the solution of which is simply q(t) = a 0 + a m cos(mt) + q(t) = a 0 + m 1 k=1 (a k cos kt + b k sin kt), m (a k cos kt + b k sin kt), k=1 with the added restriction that b m = 0. The solution to the system of equations q(t k ) = x k is given by a 0 = 1 2m 1 x j, 2m j=0 a m = 1 2m 1 x j cos(mt j ), 2m j=0 b m = 0 = 1 2m 1 x j sin(mt j ), 2m j=0 a k = 2 2m 1 x j cos(kt j ), 2m j=0 b k = 2 2m 1 x j sin(kt j ), (5.1) 2m j=0

160 140 Chapter 5. Harmonic Surfaces since sin(mt j ) = 0 given that n = 2m. If we substitute these values into the formula for q(t) as done in the odd case (equation 2.13) we note that the result corresponds to equation 3.19 and that the data points are interpolated. The above formulation is thus an alternative to the harmonic interpolation described previously. We rewrite q(t) using cos kt = 1 2 ( e ikt + e ikt) sin kt = i 2 ( e ikt e ikt), to get q(t) = a 0 + m k=1 ( 1 2 (a k ib k ) e ikt + 1 ) 2 (a k + ib k ) e ikt. The system of equations q(t j ) = x j, with t j = 2πj, can be written in matrix n form by noting that e ikt j = e ik2πj/n = e ik2π(n j)/n. By defining the matrix w w 2... w n 1 F := 1 w 2 w 4... w 2(n 1), w n 1 w 2(n 1)... w (n 1)2 with w j := e it j we can write the system of equations as c 0 x 0 c 1 x 1 F P c 2 = x 2,.. c n 1 x n 1 where P is an appropriate permutation matrix. A permutation matrix is a matrix that contains exactly one 1 in each row and column. The coefficients c j are given by c 0 = a 0 c k = 1 2 (a k ib k ), k = 0, 1,..., m 1 c k = 1 2 (a k + ib k ), k = m, m + 1,..., n 1. The matrix F P is thus unitary and invertible, and only one solution exists, namely equation 2.12 for n odd and equation 5.1 for n even. Now suppose

161 5.3. Surface Fitting - Interpolation 141 we have n points, and that we have found the solution for a k and b k using equation 2.12 or equation 5.1. If we want the same curve, but with n + p coefficients, we simply define a k := 0, b k := 0, k > m. These definitions ensure that q(t) remains the same, even though more coefficients are used in the definition. Now we consider the curve r p(t) = a 0 + (a k cos kt + b k sin kt), k=1 with n + p = 2r if n + p is even, and n + p = 2r + 1 if n + p is odd. To solve for the coefficients we require p(t j ) = q(t j ) with t j = 2πj and n+p j = 0, 1,..., n + p 1. We thus have n + p unknowns and n + p equations. We know that equation 2.12 provides a solution in the odd case, and that equation 5.1 provides a solution in the even case. We also know that q(t) extended to have n + p coefficients is a solution. As we have shown earlier, there is only one solution, namely the coefficients of the extended q(t). The solution provided by equation 2.12 or 5.1 is identical to the solution provided by extending q(t). The solution provided by extending q(t) is then the only solution, and the solution has a harmonic interpolation representation. We thus see that any curve described by n coefficients can also be described by n + p coefficients. We have verified the existence of a curve defined by more control points, that still interpolates the original control points. In the next theorem we determine the control points of this curve for harmonic interpolation. Theorem 5.3. To insert extra control points into the curve produced by harmonic interpolation we replace the existing n points x k by n + m new points y k so that n+m 1 σk n (t)x k = σ n+m k (t)y k, with We find that sin(nπt) σk n (t) := σ n (t k/n), σ n n sin(πt), (t) := cos(πt) sin(nπt) n sin(πt), y j = σ n k ( ) j x k n + m if n is odd if n is even

162 142 Chapter 5. Harmonic Surfaces is a solution. Proof. We want to find n + m vectors y k so that σk n (t)x k = n+m 1 σ n+m k (t)y k. We thus need n + m equations to solve. We choose the equations n 1 σk n ( ) n+m 1 j x k = n + m From harmonic interpolation we have n+m 1 We thus obtain the solution ( ) j σ n+m k y k, j = 0,..., n + m 1. n + m (5.2) ( ) j σ n+m k y k = y j. n + m y j = All that remains is to prove that σ n k σk n (t)x k = ( ) j x k. n + m n+m 1 σ n+m k (t)y k. Now, suppose we solved the equations n 1 σk n ( t + j ) n+m 1 x k = n + m ( σ n+m k t + j ) z k, n + m j = 0,..., n+m 1 (5.3) for a given t R, and assume that the curve produced is identical to the original curve. Then these equations hold for all t R including t = 0. We then have n 1 σk n ( ) n+m 1 j x k = n + m ( ) j σ n+m k y k = y j, j = 0,..., n + m 1 n + m

163 5.3. Surface Fitting - Interpolation 143 x 6 x 7 x 6 x 0 x 3 x 4 x 5 x 2 x 0 x x 5 4 x 3 x 2 x 1 (a) Application of theorem 5.1 (b) Application of theorem 5.3 x 1 Figure 5.6: Application of theorems 5.1 and 5.3 (with m = 1). and n 1 σk n ( ) n+m 1 j x k = n + m ( ) j σ n+m k z k = z k, j = 0,..., n + m 1 n + m and thus z k = y k. Thus the solution y k will produced the desired curve, and theorem 5.2 guarantees that the curve exists. An interesting consequence of theorem 5.3, is that the σ functions can be written in terms of σ functions as n+m 1 ( ) l σk n (t) = σ n+m l (t)σk n n + m l=0 with m 0. To illustrate theorem 5.1 and 5.3, we apply the theorems to figure 3.9(b). Figure 5.6(a) shows the effect of theorem 5.1 and figure 5.6(b) illustrates theorem 5.3 applied to figure 5.6(a) Algorithm 1 One possibility for surface fitting is listed below. We assume that the surface is solid in the sense that any cross section of the surface consists of one or more periodic (closed) curves. We also require the surface to be topologically similar to a sphere, and that any cross-section (that we consider) consists of only one boundary curve. The surface can be provided as a set of polygons or points (possibly triangulated using Delaunay triangulation [16]). 1. The user decides which cross-sections are most appropriate by orienting the data points.

164 144 Chapter 5. Harmonic Surfaces 2. The maximum bounds in the cross-section direction is determined. The cross section direction can be arbitrarily chosen if we are working with an unorganised data set. Some directions may be more suitable than others however. 3. The volume is recursively subdivided in the cross-section direction until a termination criteria is met. Termination criteria may be that the vertical distance between any two points in the cross section is less than the horizontal distance. At this point the cross section is a candidate for fitting. Since the topology of the object may not be ideally suited for this technique of determining cross-sections, we first project the data points onto a surrounding cylinder. A ray is cast from the origin though the point. The point where the ray intersects the surrounding cylinder, is the point used for determining cross-sections. The data may already be arranged as cross-sections, as is the case with CAT scans. 4. If there may be multiple curves in a cross section, then the polygon intersections with the plane of the cross section (described by the mean vertical value) should be used. Edges are shared between polygons. Thus each edge intersection with the plane can be stored. We will not consider multiple curves from this point on. These intersections should provide an inherent ordering of the related points, since we can determine which polygons share edges, and thus which intersection points form the line of intersection of the plane with the polygon. If no edge information is available, then ordering may be achieved using polar coordinates. The angle in polar coordinates may not be sufficient. One possibility is to use a nearest neighbour algorithm. In this case, if many points have similar angles, the next point along the boundary curve must be sufficiently close to the previous one. 5. A harmonic curve can be constructed from each cross-section in a minimum amount of time. To allow tensor product interpolation, each curve should have the same number of interpolation points, and these points should coincide approximately. 6. To insert interpolation points we note that (theorem 5.3) σk n (t)x k = n+m 1 σ n+m k (t)y k,

165 5.3. Surface Fitting - Interpolation 145 where y j = σ n k ( ) j x k. n + m We can thus add m points as necessary to each curve to obtain the desired number of interpolation points (which differ from the previous interpolation points). The original x k are still interpolated, however. 7. The parametric values of these curves do not necessarily coincide. In other words, if we look at a polar transform of the points, one curve may begin at t = 0 at 0 while another begins at t = 0 at 170. We thus need to rotate the interpolation points to obtain the nearest match. We have (by theorem 5.1) where σ k (t + o)x k = σ k (t)y k, ( ) j y j = σ k n + o x k, and o R is the parametric rotation of the control points. We can thus choose an offset amount o and rotate the control points parametrically by this amount. We have new interpolation points, but the original x k is still interpolated. We choose to orient the points according to angles for the minimum total deviation. 8. To interpolate cross-sections, we apply harmonic interpolation across a set of matching data points in each cross-section. To make the data periodic, we traverse the cross sections in reverse order on the other side of the object. We thus obtain a harmonic tensor product surface. 9. Once the surface is converted to B-spline or Bézier patches we have local control over the surface, which harmonic interpolation does not offer (Shown later in section 5.7). We have ignored the possibility of multiple boundary curves in the crosssections. The surface should thus be scanned over distinct parts, and the parts then integrated after the harmonic fitting process. The disadvantages of this algorithm, is the time needed to decide which cross-sections to take, and the time to optimise the location of the interpolation points (rotation). The advantage of this algorithm is that harmonic interpolation provides a fast way to fit a curve through the data points. No non-uniform algorithms are used, so

166 146 Chapter 5. Harmonic Surfaces (a) Data points (b) Surface Figure 5.7: Sphere fitting using algorithm 1. the only data needed is the interpolation points, which are provided directly by the data. Further interpolation points are easily computed. In comparison to other B-spline fitting techniques that require far more equations to be solved, harmonic fitting is far simpler. We thus expect very fast surface fitting at the possible expense of quality. The expense in quality is in fact severe. Figure 5.9 shows one such result. Problems occur in the choice of contours and making sure that the contours match even though the curves interpolate at different speeds. Sometimes very few points are isolated in a cross-section and the curve produced approximates the surface badly. In such cases we can merge adjacent cross-sections. However, the criteria to do so is not easily determined. We may often place more points in a crosssection than is required. Even a sphere when sampled in certain ways does not provide suitable results (figure 5.8). We note that a sphere sampled using equally spaced spherical coordinates (as in equation 4.1, show in figure 5.7) does produce an acceptable result, although some oscillation is visible. This may be so since the coordinates produced are easily arranged to produce a sphere with harmonic tensor product surfaces. Our next algorithm tries to exploit this fact to obtain better surface interpolation. If we obtain the data already arranged in cross-sections, we expect the results to be better Algorithm 2 For our second algorithm, we wish to end up producing a tensor product harmonic surface over a sphere in some form. We thus try to reparameterise the data using spherical coordinates. To do so, we need to make a few assumptions.

167 5.3. Surface Fitting - Interpolation 147 (a) Data points (b) Surface Figure 5.8: Failed sphere fitting using algorithm 1. (a) Data points (b) Surface Figure 5.9: Failed surface fitting using algorithm 1.

168 148 Chapter 5. Harmonic Surfaces We assume that any line intersecting the object does so in at most 2 points. The topology is thus restricted and excludes objects like the torus. We are actually only interested in certain lines, namely those passing through the origin. So we actually require that no line passing through the origin intersect the object at more than 2 points. Under this assumption, objects that can be sampled are deformed spheres. But only deformation in the sense of depressions on the surface. Although this is not very useful, it will allow us to demonstrate harmonic surfaces without delving into more sophisticated techniques. Secondly, we assume that the surface has been sampled at the Nyquist limit. We thus expect a relatively dense set of interpolation points. These assumptions allow us to sample the object using lines passing through the origin. The point at which the line intersects the object will be near one of the data points. Using the data points, we approximate the surface to find the point of intersection. This point of intersection can be described by the line and the distance from the origin to the intersection point. Using spherical geometry images [29, 67, 57, 37] as inspiration, we convert the data points into a two dimensional image. First we construct a sphere containing the object and then we cast rays from several spherical coordinates to the centre of the sphere. In spherical coordinates we use an angle of latitude and an angle of longitude. These two angles form the axes of the geometry image in much the same way as a map of the earth is created. As stated in chapter 4, a parametric form of the sphere is given by r sin u cos v f(u, v) = r sin u sin v, r cos u where 0 u π and 0 v 2π are the two dimensions for the geometry image. We thus determine the intercept point between the line passing through the point f(u, v) and the origin, and the data set. To determine the point of intersection between the ray and the object, we select the point in the data set which is closest to the ray. We also require that the distance from the point on the sphere to the point on the data set be less than the distance from the point on the sphere to the origin. According to our assumption, there can be only one such point. If we use only one point we may not capture the surface details correctly. We thus find several points that the ray passes between, then we apply the following steps to each point and compute an average of the obtained results. We assume that the surface

169 5.3. Surface Fitting - Interpolation 149 is spherical around a data point, and thus the point of intersection will be the same distance from the origin as the nearest data point. We must thus have a sufficient number of datapoints to make this approximation suitable, or we must try to sample near the data points. We can use the distance from the approximated point of intersection to the centre of the sphere as the depth for a particular ray. We only need this one quantity, the position is specified by the depth value and the ray for which we computed the intersection. Proceeding in this fashion we can construct an image from the data points using spherical coordinates. We need to sample the data twice, to provide the periodicity required for harmonic interpolation. We thus choose equally spaced u and v such that 0 u 2π and 0 v 2π. The resulting image is periodic both vertically and horizontally. We can now apply standard filtering and image processing techniques to reduce the noise in the image. We can also apply theorem 5.3 to reduce the number of points (discussed in the next section). We can also construct a harmonic tensor product surface from the depth data. The surface is easily reconstructed by harmonic interpolation of the depth values which, in combination with the known rays used to sample the surface, can be converted to a point in three-dimensional space. And so a smooth surface is constructed. Our focus is on the quality of the harmonic interpolation, not the quality of the geometry image created from the surface. Implementation To make sure at least some of the assumptions hold, we scale the datapoints and calculate the mean. We then translate the datapoints so that the mean is at the origin. Determining the point in the data set nearest to the ray can be a time consuming process. Since there can only be one point that satisfies the assumptions mentioned above, we select the point in the data set which most closely matches the direction the ray is coming from. We presume that this point best approximates the surface at the point of intersection. To improve the speed of creation of the geometry image, we use a kd-tree. The kd tree stores normalised points, that is the vector from the origin to the point in the data set, that has been normalised. We can compute the kd-tree efficiently from the normalised points, it is not necessary to insert the points directly into the kd-tree. The kd-tree will thus be balanced. To search the kd-tree for the nearest point, we need only find the point which

170 150 Chapter 5. Harmonic Surfaces is closest to the direction from which the ray comes. However, we would prefer to have 3 points or more to obtain a reasonable idea of the orientation of the surface at this point. We thus search for all points within a specified radius of the direction from which the ray comes from. We begin with a narrow radius from the ray. If no points are found, the radius is gradually increased, until a suitable data point is found. The whole process of creating the geometry image, filtering and rebuilding the surface takes a few minutes. One of the disadvantages of this approach, is the higher sampling rate near the poles. The sampling rate may be reduced, and theorem 5.3 used to add new points, to obtain a rectangular image. This should help overcome the sphere approximation problem at the poles, although we have not implemented it. We may also try other representations to try to avoid the high sampling rates at the poles. To produce a more uniform parameterisation, we can map the sphere onto an octahedron or flattened octahedron [67]. The octahedron parameterisation is illustrated in figure We must thus map from the octahedron onto the sphere, and then use the point on the sphere for the ray cast. Results Examples of this algorithm are shown in figures 5.10 to In figure 5.10 we see surface fitting of the mannequin head data set consisting of points. Figure 5.11 shows fitting of a data set consisting of points, the geometry image is illustrated in figure Finally, we see the fitting of a sphere in figure Figure 5.12 has no visible blemish even though the original data samples were not polar coordinates. For the geometry image we assumed that the surface was locally the same as a sphere, and in this case it is, so the data is converted to a geometry image without flaw. We note that harmonic interpolation applied to these points has no undulations. The other figures do have undulations. Examining figures 5.14 and 5.15 it appears that the undulations are largely a result of the geometry image. Figure 5.14 is constructed directly from the geometry image. Figures 5.16 and 5.17 display the results after a simple smoothing filter is applied to the geometry image. The sphere parameterisation has problems at the poles, as illustrated by the nose of the mannequin. To produce a more uniform parameterisation, we can map the sphere onto an octahedron or flattened octahedron [67]. The

171 5.4. Surface Fitting - Approximation 151 octahedron parameterisation (figure 5.18) produces seams when smoothed due to the discontinuities in parameterisation (as illustrated in figure 5.19). The flattened octahedron may be used to avoid these problems to some extent. A portion of the mapping of the flattened octahedron to the sphere is illustrated in figure 5.20 along with the tensor product harmonic surface. Results for various other publicly available objects ([79], [27]) are provided in figures 5.21, 5.22, 5.23 and In all cases we used a geometry image. If the models do not satisfy the requirement that the object is similar to a sphere, we obtain very poor results. We also obtain poor results for objects that have few points. In these cases the the rate of sampling is not high enough to apply the algorithm, so we sampled additional points on the polygons to produce a data set of points for a few of these models. The performance of the geometry image creation and harmonic interpolation are given in table 5.1. These results were obtained on a 1.9GHz AMD Athlon processor with 1GB of RAM. The harmonic interpolation takes a substantial portion of the time. Fitting of the harmonic surface to the geometry image takes no time whatsoever, since harmonic interpolation immediately interpolates the data set. The time quoted for harmonic interpolation is the time taken to rasterize the the surface by producing 4 times more data points than stored in the geometry image. In many cases, there is some undulation on the surface. We have seen that this is often the result of the steps taken to create the geometry image. For surfaces of arbitrary topology we suggest the use of phase 1 and 2 of Hoppe s PhD [35] followed by the formation of a geometry image [29] and harmonic interpolation. Geometry images have already been used quite successfully in the creation of smooth surfaces [57]. The next section shows how harmonic interpolation may be used to filter the geometry image and reduce the size. 5.4 Surface Fitting - Approximation Data provided for surface fitting may contain noise. The surface produced may thus have unnecessary undulations to fit the data. This is a considerable problem for harmonic interpolation since cusps are easily produced. We do however have a useful result from the previous section in theorem 5.3.

172 152 Chapter 5. Harmonic Surfaces Model Points GI HI angel s 417s bunny s 418s cow s 416s dragon s 418s duck s 426s horse s 419s mannequin s 417s p s spock s 418s teapot s 416s cow resampled s 418s p51 resampled s 420s teapot resampled s 419s Table 5.1: Performance of surface fitting algorithm. GI=Time for geometry image, HI=Time for harmonic interpolation. (a) Data points (b) Surface Figure 5.10: Surface fitting using harmonic tensor product surfaces (mannequin).

173 5.4. Surface Fitting - Approximation 153 (a) Data points (b) Surface Figure 5.11: Surface fitting using harmonic tensor product surfaces (Spock). (a) Data points (b) Surface Figure 5.12: Surface fitting using harmonic tensor product surfaces (sphere). Figure 5.13: Geometry image (Spock).

174 154 Chapter 5. Harmonic Surfaces (a) Surface (b) Close-up Figure 5.14: Surface produced by spherical geometry image (mannequin). (a) Surface (b) Close-up Figure 5.15: Surface produced by harmonic interpolation (mannequin).

175 5.4. Surface Fitting - Approximation 155 (a) Surface (b) Close-up Figure 5.16: Surface produced by geometry image after smoothing (mannequin). (a) Surface (b) Close-up Figure 5.17: Surface produced by harmonic interpolation after smoothing (mannequin). (a) Octahedron (b) Surface (c) Periodic image Figure 5.18: Octahedron geometry image.

176 156 Chapter 5. Harmonic Surfaces (a) Surface (b) Smooth (c) Harmonic interpolation (d) Close-up Figure 5.19: Harmonic surface produced using octahedron geometry image (mannequin).

177 5.5. Rendering 157 y z (0, 0) x (a) Flattened octahedron (b) Surface produced Figure 5.20: Flattened octahedron geometry image (one side only). Theorem 5.3 states that where σk n (t)x k = n+m 1 σ n+m k (t)y k, y j = σk n j ( n + m )x k. If we have redundant data, say n + m points where only n are needed, and we assume equally spaced data, then theorem 5.3 provides a technique for removing the redundant m points. We know that σk n (j/n)x k = x j, and the same is true for the new curve. We can thus sample n equally spaced points and use harmonic interpolation on these n points. To determine if removing the m points is valid, we can simply evaluate an error metric for the interpolated data points. If the error metric is below a certain threshold then we can assume the error is due to noise. 5.5 Rendering We begin by discussing rendering techniques for polynomial tensor product surfaces. One technique that can be applied to obtain polygons, is to evalu-

178 158 Chapter 5. Harmonic Surfaces (a) Angel data set (b) Surface (c) Stanford bunny data set (d) Surface (e) Cow data set (f) Surface Figure 5.21: Surface fitting using harmonic tensor product surfaces.

179 5.5. Rendering 159 (a) Dragon data set (b) Surface (c) Duck data set (d) Surface (e) Horse data set (f) Surface Figure 5.22: Surface fitting using harmonic tensor product surfaces.

180 160 Chapter 5. Harmonic Surfaces (a) P51 data set (b) Surface (c) Teapot data set (d) Surface Figure 5.23: Surface fitting using harmonic tensor product surfaces.

181 5.5. Rendering 161 (a) Cow data set (b) Surface (c) P51 data set (d) Surface (e) Teapot data set (f) Surface Figure 5.24: Surface fitting using harmonic tensor product surfaces of resampled data set.

182 162 Chapter 5. Harmonic Surfaces Figure 5.25: A scanline-rendered harmonic surface (torus). ate the parametric surface at discrete parametric values. The torus in figure 5.25 was rendered by a scanline renderer in this way. The control points used are the same as those used in figure 5.1(b). Schweitzer [74] discussed a way to perform scanline rendering of parametric surfaces. These techniques are more readily applied to polynomial surfaces such as Bézier patches where the convex hull property applies. To efficiently calculate the surface at parameter values, we can use differencing. Forward differencing [1] for polynomial surfaces (such as Bézier patches) are easily calculated. We first illustrate the process for a simple polynomial f(x) = a + bx + cx 2, and then we provide the general algorithm. If we wish evaluate f at parameter values sk denoted by f(sk) = f k, then we may try to use the difference between successive f k to simplify calculation. The step size s is constant and k Z. We have and f(sk) = a + bsk + cs 2 k 2 f(s(k + 1)) = a + bs(k + 1) + cs 2 (k + 1) 2 = a + bsk + cs 2 k 2 + bs + 2cks 2 + cs 2 so that δ 1 k := f k+1 f k = bs + 2cks 2 + cs 2. If we view f(sk) as a polynomial in k, then we note that the difference is of lower degree than the original function. In the same way we note that δ 1 k+1 = bs + 2c(k + 1)s 2 + cs 2 = bs + 2cks 2 + 3cs 2.

183 5.5. Rendering 163 The difference is then given by δ 2 k := δ 1 k+1 δ 1 k = 2cs 2, which is constant. If we compute differences again, we see that δ j k = 0, j > 2. We have thus have obtained a series of differences that can be used to calculate the function f at the parameter values sk. The value of f(sk) is calculated from f k+1 = f k + δ 1 k δ 1 k+1 = δ 1 k + δ 2 k δ 2 k = 2cs 2. At each step we calculate the next value of the function f, and then we calculate the δk 1 and δ2 k values required for the next step. We can now apply the same algorithm to an arbitrary polynomial. Assume that we want to calculate the value of a polynomial function f (of degree n) at parameter values sk, denoted by f(sk) = f k. The forward differences are given by δ 1 k = f k+1 f k δ 2 k = δ 1 k+1 δ 1 k δ 3 k = δ 2 k+1 δ 2 k. δ n k = δ n 1 k+1 δn 1 k. The forward differences δ n+1 are all zero. With a few calculations the forward difference δ k 0 can be calculated (using the above formulas). We need the function values f 0, f 1,... f n+1 to do so. We can then calculate f k as follows: δ n 1 k f k = f k 1 + δ 1 k 1 δ 1 k = δ 1 k 1 + δ 2 k 1 δ 2 k = δ 2 k 1 + δ 3 k 1. = δ n 1 k 1 + δn k 1. Central differencing [1] may also be used. In some applications we may wish to vary the stepsize s, if so, we must apply an adaptive differencing algorithm [52]. Differencing may be used to produce polygons efficiently for display. Using the formulation of harmonic interpolation as Chebyshev polynomials (section 3.9) we obtain an algebraic function. The function φ(s)

184 164 Chapter 5. Harmonic Surfaces makes application of forward differencing difficult. However, the Chebyshev form can be evaluated quickly due to the lack of trigonometric functions. We have considered how to convert parametric surfaces to polygonal models that can be rasterized, next we consider an alternative rendering technique: raytracing. 5.6 Ray tracing A variety of techniques have been applied for rendering parametric polynomial patches. We will mention a few of these techniques and see if any are applicable for rendering harmonic tensor product surfaces. A number of the techniques accelerate intersection testing, using properties of the surface or bounding volumes. Several other acceleration techniques are also available. We are not concerned with acceleration, but rather with techniques that correctly yield a point of intersection. We will concentrate on results that may be applicable to harmonic surfaces. To ray trace a tensor product surface we need to find the intersection point between the parametric surface given by x(u, v) f(u, v) = y(u, v). z(u, v) and a ray given by p(t) = o + td, where o is the origin of the ray and d is the direction of the ray. We must solve the system of equations f(u, v) = p(t) for u, v and t. One possibility is the multi-dimensional Newton-Raphson technique, however the results are seldom stable. Kajiya [42] provides one of the first techniques for raytracing parametric patches. Kajiya represents a ray as the intersection between two planes. The system of equations then reduces to two variables, u and v. The equations are not linear, so Kajiya [42] proceeds to explain how these equations may be solved. Sederberg and Anderson [75] apply a similar technique to Steiner patches. Applying this technique to harmonic interpolation yields trigonometric polynomials. Numerical techniques such as interval Newton-Raphson are thus preferable. Joy [41] used quasi-newton methods to determine the point of intersection. We found that the Newton-methods were not stable enough using the trigonometric functions. Further work on the intersection test on cubic parametric

185 5.6. Ray tracing 165 surfaces, in various forms have been published by Wang [88], Lischinksi [53]. Nishita [64], Roth [70], and Stürzlinger [84] discuss raytracing of trimmed and triangular Bézier surfaces. A variety of intersection algorithms are discussed by Manocha [59]. The majority of the algorithms presented rely on Newton s method, subdivision and the convex hull property of the surfaces discussed. A bounding volume for the surface can be produced using the convex hull so that portions of the surface can be identified that definitely do not intersect the ray. Chebyshev polynomials may be used for boxing [26], and a bounding volume hierarchy or Bézier clipping [7, 64] can also be used. Harmonic tensor product surfaces do not have the convex hull property, and Newton s method fails to converge in a stable manner. Subdivision surfaces can also be raytraced [46], but the lack of local support in harmonic interpolation makes this approach difficult. We turn our attention to the use of interval arithmetic as demonstrated by Toth [85] Interval arithmetic Interval arithmetic [60] is an arithmetic defined on sets of intervals. interval X is defined as An X = { x x l x x u } = [x l, x u ]. Elementary operations for idealised interval arithmetic are given by X Y = { x y x X and y Y }, where is +,, or. It is not always simple to perform these operations, we therefore prefer the operational definitions: X + Y = [x l + y l, x u + y u ] X Y = [x l y u, x u y l ] X Y = [min{x l y l, x l y u, x u y l, x u y u }, max{x l y l, x l y u, x u y l, x u y u }] 1 X = [1/x u, 1/x l ], 0 / X X Y = X 1/Y. Using these operations we can compute bounds on the ranges of functions. If we use the correct rounding on a computer then we can obtain accurate bounds in which a solution must lie. If f is a continuous function of a real variable, then an inclusion monotonic interval extension F is a function that maps from intervals to intervals such that { f(x) x X } F (X).

186 166 Chapter 5. Harmonic Surfaces Evaluating polynomials using the operational definitions provides us with an inclusion monotonic interval extension. Transcendental Functions We can also obtain interval extensions of the transcendental functions. For example [78]: with [ 1, 1], if 1 + x l π x u π [ 1, b], if xl π x u cos([x l, x u ]) = π and x l π mod 2 = 1 [a, 1], if xl π x u π and x l π mod 2 = 0 [a, b], otherwise, a = min{cos(x l ), cos(x u )}, b = max{cos(x l ), cos(x u )}. We can use similar results for the sine function, or we can use identities to reuse the cosine function. We can thus create interval extensions for polynomial functions, and functions such as σ. Next we consider root finding using intervals Interval Root Finding Bisection Using the interval extension F of a function f, the bisection method can very simply determine where the roots of the function lie. The algorithm is simply [14]: set interval bisection([a, b]) { real c; set S; if (0 F ([a, b])) { c (a + b)/2; if (b a < ɛ) { return set(c); } else { S interval bisection([a, c]); S S interval bisection([c, b]); return S; } } else {

187 5.6. Ray tracing 167 } } return ; The above algorithm returns all the roots with a maximum error of ɛ. The algorithm is easily modified to return intervals in which the roots are found. We can also apply the bisection method to multidimensional root finding, we would typically choose one dimension two divide at each step. We can obtain faster convergence if we modify the Newton-Raphson algorithm for use with intervals Interval Root Finding Newton-Raphson The Newton-Raphson, or Newton method can be used to solve the system of equations [80] f 1 (x 1, x 2,..., x n ) = 0 f 2 (x 1, x 2,..., x n ) = 0 f n (x 1, x 2,..., x n ) = 0.. Let f = ( f 1 f 2... f n ) T and x = ( x1 x 2... x n ) T. Then the system of equations can be written as f(x) = 0. The gradients of the components are given by the entries of the Jacobian matrix [80] J := f 1 f 1 x 1 f 2 f 2 x 1. f n x 1 x 2 x 2 f n x 2 f 1 x n f 2 x n f n x n. Suppose we want to solve the problem f(x) = 0, and our present approximation is x which can be written as x = y + h, where y is the exact solution. We compute f i (x 1, x 2,..., x n ) = g i. Using the Taylor expansion, and neglecting higher order terms, we find that Jh = g,

188 168 Chapter 5. Harmonic Surfaces and consequently h = J 1 g. We assume that the matrix J is nonsingular. We can now compute h to obtain a better approximation of the correct answer y. The Newton iteration is then given by x n+1 = x n J 1 f(x n ). To apply a Newton-Raphson algorithm to intervals, we need to introduce the midpoint (which we have used in interval bisection) and the width of an interval. We use the syntax of Toth [85]. The midpoint of an interval X = [x l, x u ] is given by and the width is defined as m(x) := (x l + x u )/2, w(x) := x u x l. Since we will be working with vectors and matrices with Newton-Raphson it is useful to define interval vectors and matrices. These are quite naturally just vectors and matrices with intervals as entries. Now we can define the norm of a vector x = ( x 0... x n 1 ) T to be (differs from chapter 2): x = max i x i. If we have two interval vectors, X = ( X 0... X n 1 ) T and Y = ( Y0... Y n 1 ) T, with X i = [a i, b i ] and Y i = [c i, d i ], we define a = ( a 0... a n 1 ) T, b = ( b0... b n 1 ) T and likewise for c and d. We define a distance metric on the interval vectors as d(x, Y) = max( a c, b d ). Using this metric continuity can be defined in the normal manner. We can now define the interval vector norm as X := max i ( X i ), where X i = [a i, b i ] and X i := max( a i, b i ). For an interval matrix A (a matrix with interval entries) we define the maximum row sum norm as A = max i ( j A ij ).

189 5.6. Ray tracing 169 The interval vector norm and interval matrix norm are compatible, that is AX A X, for an interval matrix A and interval vector X. We will need a mean value theorem for intervals [85]: Theorem 5.4 (The Mean Value Theorem for Intervals). If x and y are any real vectors in X, then f(x) f(y) F (X)(x y), where F (X) is the interval extension of f. The following lemma [85] will assist in developing the Newton method for interval arithmetic. We consider the Newton step with Y = J 1. p(x) = x Y f(x), Lemma 5.1. Suppose that p(x) = x Y f(x) maps X onto itself and there is a constant r < 1 for which p(x) p(y) r x y for any x and y in X. Then the simple Newton sequence x n+1 = p(x n ) will converge to x in X, where x is a unique solution to the equation f(x) = 0. To determine if p(x) maps X to itself we define the Krawczyk operator [48] K(X, y, Y ) := y Y f(y) + (I Y F (X))(X y), for an interval vector X, real vector y and nonsingular matrix Y. We then note that p(x) = y Y f(y) + (x y) Y (f(x) f(y)). The mean value theorem for intervals yields and consequently Y (f(x) f(y)) Y F (X)(x y) p(x) y Y f(y) + (I Y F (X))(x y) K(X, y, Y ). Thus K(X, y, Y ) is an interval extension of p(x), and p(x) maps X onto itself. The operator K is a centred form, C(f, X, y) = f(c) + G(X y)(x y),

190 170 Chapter 5. Harmonic Surfaces with f(x) = p(y). We are interested in a particular centred form, the mean value form C(f, X, y) = f(c) + F (X)(X y), and we note that K is indeed in mean value form. We now examine the operator K with y = m(x). Using the norms defined earlier we calculate r = I Y F (X) and with the mean value theorem we obtain so that p(x) p(y) (I Y F (X))(x y), p(x) p(y) r x y. From lemma 5.1 we obtain the theorem Theorem 5.5. If K(X, y, Y ) X and r < 1 then the simple Newton sequence x n+1 = p(x n ) will converge to a unique solution x X to f(x) = 0 from any starting point x 0 in X. Interval Newton iteration[48] is defined as where X n+1 = K(X n, m(x n ), Y n ) X n, Y n = { m(f (X n )) 1, Y n 1, r n r n 1 otherwise and r n = I Y n F (X n ). By applying interval Newton iteration, we will either obtain the empty set (in which case there is no solution), or the solution to f(x) = 0. Toth [85] describes an algorithm using the interval Newton iteration to raytrace Bézier patches. In addition to the interval Newton method, the convex hull property of Bézier patches is used Raytracing Harmonic Surfaces Applying interval Newton iteration or the interval bisection method to the problem of intersection between a ray and a tensor product harmonic surface does yield a solution. The torus in figure 5.1(b) was raytraced along with a few other objects. The result is shown in figure The process of raytracing the image took several hours, and yet further accuracy is still desired. The methods mentioned take a considerable amount of time because

191 5.7. Approximating Basis Functions 171 Figure 5.26: A raytraced harmonic surface (torus). the trigonometric functions cause difficulties in determining a tight bound on the interval at each step, and we have no convex hull property to quickly discard portions of the surface for which there can be no intercept. Due to the time taken to render these simple images, we decided not to compare the interval Newton and interval bisection methods. Instead, we try to find alternative techniques to improve the rendering speed. We now try to answer the question: Can we obtain a convex hull for a harmonic tensor product surface? Our answer is obtained by approximating the harmonic surface by a series of Bézier patches. To obtain the Bézier patches we will need to approximate the basis functions of harmonic interpolation. 5.7 Approximating Basis Functions The harmonic surfaces are difficult to ray trace, even using interval analysis. Much of the literature on ray tracing parametric patches exploit the convex hull property of Bézier patches. We have no similar result for harmonic surfaces. Although the techniques of interval analysis do provide a solution for rendering harmonic surfaces, the process is time consuming. We choose to approximate the harmonic surface by several Bézier patches. To do so, we will approximate the σ function by a polynomial, in the form of a Bézier curve. To approximate the σ function, we must decide on the degree of the polynomial to use, and how many to use. By combining several polynomials and ensuring piecewise continuity, we increase the possibility of modelling the σ function for larger n without using polynomials of excessively high degree.

192 172 Chapter 5. Harmonic Surfaces We can thus also reduce the time taken to solve for the coefficients of the polynomial. We choose to approximate the σ function over separate intervals [a, b] with σ (a) = σ (b) = 0, where denotes the derivative. This is a root finding problem. We choose to use interval analysis, since we want to find all roots of σ (t). The structure of a function can influence the results for interval analysis, by choosing functions that produce tighter bounds under the interval operators we obtain a solution far more quickly. We found that using ( ) 1 m cos(2πjt), if n is odd n σ(t) := ( j= cos(πnt) + 2 n m 1 j=1 cos(2πjt) ), if n is even and the derivative ( ) 1 m 4π j sin(2πjt), if n is odd n σ j=1 (t) = ( ) m 1 1 πn sin(πnt) 4π j sin(2πjt), if n is even n j=1 (5.4) from equations 3.11 and 3.19 gave the best results. The root finding of σ(t) proceeds without difficulty. We found (experimentally) that using two Bézier curves of degree 5 to approximate each interval between two roots of the σ function provided sufficient accuracy for rendering harmonic curves. We will introduce an alternative to this approximation that has more desirable qualities a little later on. As a result, we do not give a rigorous analysis of the approximation quality here. After studying the σ k (t) functions for different values of n, it becomes clear that we need 2(n 1) Bézier curves to model the odd case and 2n Bézier curves to model the even case. Once the basis functions have been approximated, the curve can be converted to several Bézier patches. We begin with the equation σ k (t)x k

193 5.7. Approximating Basis Functions 173 with σ k (t) approximated by Bézier curves σ k (t) 5 Bj 5 (t (t))p k,j, j=0 where p k,j is the j th coefficient of the Bézier curve that approximates σ k (t). We have different approximations for different ranges of t, thus we need the function t (t) to map from the σ parameter to the parameter of the Bézier curve. The curve then becomes σ k (t)x k = j=0 5 Bj 5 (t (t))p k,j x k 5 Bj 5 (t (t)) p k,j x k, (5.5) j=0 for each range of t. The sum n 1 p k,jx k can be precomputed before rendering so that we have a regular Bézier patch that is sent through the rendering process. We take each segment of the curve and sample 3 points on the curve. At these 3 points, we calculate both σ k and σ k. These 6 values are used to determine the Bézier coefficients. The coefficients and values form a system of 6 linear equations which is easily solved using standard techniques. If the interval is [a, b] then the sample points are a, b and (a + b)/2. When selecting segments (sample points) we search for the roots of σ k for every valid k. Once all these roots are found, segments can be identified for approximation. If we don t use all the roots for determining the segments, then the Bézier coefficients are defined over different ranges and equation 5.5 is not valid. If we have distinct ranges in t over which the curves are all defined, then these form Bézier patches. These patches are piecewise smooth. Since we sample at the ends of the intervals, and use the derivative at these points, two adjacent Bézier curves will have the same gradient, and will thus be piecewise smooth. Unfortunately, we do not have a guarantee that the data points will be interpolated. Bézier patches of degree 6 are not common primitives in graphics software. Cubic Bézier patches are however. It would thus be desirable to approximate

194 174 Chapter 5. Harmonic Surfaces σ k (t) by cubic Bézier curves. That is σ k (t) 3 Bj 3 (t (t))p k,j. j=0 In this case we make use of the properties of Bézier curve to choose the approximation intervals. We choose intervals of the form [ a, a+1 ] and approximate σ k (t) by a cubic Bézier curve over this interval (as above). Bézier n n curves interpolate their endpoints, so we know that the approximation of σ k (t) will also interpolate the control points. We may use the values of σ k (t) at a a+1 and for approximation. We will need two more equations to solve for n n the Bézier coefficients. One option is to use the derivative at these parameter values. We chose to use two more equally spaced values of the function σ k (t). The curve can then be calculated by σ k (t)x k = j=0 3 Bj 3 (t (t))p i k,jx k, 3 Bj 3 (t (t)) p i k,jx k, j=0 i n t < i + 1 n so that we can pre-calculate the control points of the Bézier curve. We see that different control points are used for different portions of the curve, indicated by i. We also use the Bézier parameter t such that t = (1 t ) i n + t i + 1 n. We can construct Bézier surfaces in a similar manner. We assume that the interpolation points are arranged in a square, the discussion is easily modified for rectangles. The tensor product surface is given by σ k (u) σ l (v)x k,l l=0 = 3 j=0 3 j=0 Bj 3 (u )p k,j l=0 3 Bi 3 (v )p l,i x k,l, i=0 3 Bj 3 (u )Bi 3 (v ) p k,j p l,i x k,l, i=0 l=0 so that we can calculate the control points of the patch beforehand. Using this approach, we have the ability to approximately represent harmonic tensor product surfaces as Bézier patches. In addition, we can use harmonic interpolation for surface fitting to produce a set Bézier patches that smoothly

195 5.7. Approximating Basis Functions 175 (a) Harmonic tensor product surface (b) Approximation Figure 5.27: Approximation of harmonic tensor product surface. (a) Surface (b) Colour coded Bézier patches Figure 5.28: Bézier patches used to approximate figure interpolates the surface. To illustrate this approach we have placed the previous example of a harmonic tensor product surface (figure 5.25 next to an approximation using Bézier patches (using the algorithm to produce cubic Bézier patches). The results are displayed in figure Since there are 4 4 interpolation points we produce 16 Bézier patches to approximate the surface. The Bézier patches are illustrated in figure The patches have been colour coded in figure 5.28(b) to allow easy identification.

196 176 Chapter 5. Harmonic Surfaces (a) The mannequin head (b) Colour coded Bézier patches Figure 5.29: Final rendering of mannequin head formed from Bézier patches. 5.8 Combined results To illustrate the techniques discussed throughout this thesis, we have applied a slightly modified version of algorithm 2 (from section 5.3) to the mannequin and Spock data sets. For the geometry image we chose to use a flattened octahedron. We apply the same technique to form the geometry image, but we do not approximate the surface near the located point by a sphere. Instead, we add the point to a list. For each row of the geometry image we obtain a number of points ordered by the sampling of the model. We treat these points as a contour, where the contour is given by harmonic interpolation. We then use theorem 5.3 to add points and obtain the number of points required for a rectangular geometry image. We still experience some noise, so smoothing is applied. We also chose to sample at a higher rate than required so that we can apply theorem 5.3 to reduce the size of the geometry image. We reduce the smoothed geometry image to approximately 25% of its original size. Finally, we approximate the obtained harmonic surface by a series of cubic Bézier patches. Figure 5.29 displays the results for the mannequin data set. There are undulations on the surface, which can be removed with further smoothing (and consequent loss of detail). Figure 5.29(b) displays the Bézier patches in a colour coded form to highlight how Bézier patches have been used. For the mannequin data set we used a geometry image (reduced from ). The time taken to convert this data set to Bézier patches was 5 minutes 43 seconds on a 1.9GHz AMD Athlon processor. The same procedure has been applied to the Spock data set in figure Once again we have included colour coded Bézier patches in figure 5.30(b). The time taken to convert the spock data set to Bézier patches,

197 5.9. Curvature 177 (a) Spock model (b) Colour coded Bézier patches Figure 5.30: Final rendering of Spock formed from Bézier patches. was 43 minutes and 15 seconds on a 1.9GHz AMD Athlon processor. When compared to other polygonal models of the Spock data set, the reproduction seems to be fairly faithful. In both data sets, undulations occur. We can only speculate as to the cause at this point pending further analysis. Since we interpolate, we do not consider the possibility of error in measurement for the data set. Undulations may be as a result of such measurement error. We also found that reducing the size of the geometry image too much produces undulations. Theorem 5.3 can only be applied when there are more points used to describe the curve than are needed. If points are removed then higher frequency components are removed. If these higher frequency components are required to define the surface accurately, then we tend to see undulations. In the figures, we have attempted to strike a balance between sufficient detail and illustration of the Bézier patch approximation. The algorithms listed here may be improved after rigorous error analysis. We do not know if any of the suggested algorithms provide optimal or near optimal solutions. 5.9 Curvature We have seen a few problems with harmonic interpolation. One of the greatest problems encountered was the undulation of the surfaces produced. In this section we measure the curvature of a few surfaces produced by harmonic interpolation. We use the measures introduced in section 4.6 to determine curvature. To measure the curvature of surfaces produced by harmonic interpolation, we sampled known parametric surfaces. We then compare the

198 178 Chapter 5. Harmonic Surfaces curvature of the parametric surface with the curvature of the harmonic surface. In each case, we only sampled 24 4 points on the parametric surface. The surfaces tested are as follows: A quadrilateral: 3u 1.5 f(u, v) = 3u A partial sphere: r cos ρ cos θ f(u, v) = r cos ρ sin θ r sin ρ with ρ = 0.9(πv π ) and θ = 2πu. 2 A sphere: with ρ = 2πv π 2 r cos ρ cos θ f(u, v) = r cos ρ sin θ r sin ρ and θ = 2πu. A torus: with ρ = 2πv and θ = 2πu. cos θ(r cos ρ + R) f(u, v) = r sin ρ sin θ(r cos ρ + R) The Moëbius strip: sin s(2 t sin s) 2 f(u, v) = cos s(2 t sin s) 2 t cos s 2 with s = 4πu and t = v 0.5. We actually have two strips in this case to ensure periodicity of the data. A surface of revolution: θ f(u, v) = cos ρ(sin θ + 2) sin ρ(sin θ + 2) with θ = 2πu π and ρ = 2πv.

199 5.9. Curvature 179 A shell: (r 1) cos θ + (r 1) cos θ cos ρ f(u, v) = (r 1) sin θ + (r 1) sin θ cos ρ (r 2 1) + (r 1) sin ρ with θ = 6πu, ρ = 2πv and r = e u. Another shell: (r 1) sin ρ f(u, v) = (r 1)(1 + cos ρ) sin(θ sin(2ρ+π/2) (r 1)(1 + cos ρ) cos(θ sin(2ρ+π/2) with θ = 6πu, ρ = 2πv and r = e u. A portion of the Klein bottle: x + r cos(ρ + π) f(u, v) = 16 sin θ r sin ρ ) 2 ) 2 with θ = πu + π, ρ = 2πv, r = 4(1 cos θ/2) and x = 6 cos θ(1 + sin θ). An overhand knot: cos θ( sin( 3θ)) 2 f(t) = sin θ( sin( 3θ)) 2 4 cos( 3θ) 2 with θ = 4πt. This formula produces a curve. To obtain a surface, we compute the Frenet frame for each point on the curve and construct a circle, using this coordinate system, around the curve and in a plane perpendicular to the curve. The construction produces a tube following the path of the curve. The Solomon s Seal knot: cos(2θ)(1 + 2 cos(5θ)) 5 f(t) = sin(2θ)(1 + 2 cos(5θ)) 5 1 sin(5θ) 2 with θ = 2πt. This formula produces a curve. As in the case above, we use the Frenet frame to produce a tube that follows the path of the curve.

200 180 Chapter 5. Harmonic Surfaces (a) Plane (b) Gaussian curvature (c) Mean curvature (d) Harmonic surface (e) Gaussian curvature (f) Mean curvature Figure 5.31: Comparison of plane and harmonic surface. A few of the surfaces cover certain areas twice. The sphere is one such surface. To render the surface we place restrictions on the u and v parameters so that each portion of the surface is only covered once. In general the values are such that 0 < u < 1 and 0 < v < 1. In the case of the sphere we add the restriction 0 < v < 0.5. In each case, we have rendered the original parametric surface as well as curvature values. Both Gaussian and mean curvature are used to provide a complete picture. Lighting is omitted on the curvature diagrams to emphasise the measured values. Blue indicates little or no curvature, and purple indicates high curvature. The interpolation points are indicated by red spheres. Curvature is determined numerically for parametric surfaces and analytically for the harmonic surfaces. We find that harmonic interpolation extends the plane (figure 5.31) a little bit, but otherwise the surface properties appear to be the same. The shape of the partial sphere differs from the surface produced by harmonic interpolation (figure 5.32) because the partial sphere is not a completely periodic parameterisation of the sphere. High curvature is clearly visible at the ends of the harmonic surface. As we have seen, harmonic interpolation can produce a torus precisely. Figure 5.33 shows the constant Gaussian curvature for the torus. We also see

201 5.9. Curvature 181 (a) Partial sphere (b) Gaussian curvature (c) Mean curvature (d) Harmonic surface (e) Gaussian curvature (f) Mean curvature Figure 5.32: Comparison of partial sphere and harmonic surface. (a) Torus (b) Gaussian curvature (c) Mean curvature (d) Harmonic surface (e) Gaussian curvature (f) Mean curvature Figure 5.33: Comparison of torus and harmonic surface.

202 182 Chapter 5. Harmonic Surfaces (a) Sphere (b) Gaussian curvature (c) Mean curvature (d) Harmonic surface (e) Gaussian curvature (f) Mean curvature Figure 5.34: Comparison of sphere and harmonic surface. that the harmonic interpolation matches the curvature of the parametric torus. The mean curvature does not match precisely, this can only be due to numerical inaccuracy. The fully periodic parameterisation of the sphere is correctly duplicated by harmonic interpolation in figure The high curvature at the poles are due to numerical inaccuracy. When the Moëbius strip is parameterised to produce two strips, as in figure 5.35, the results are fairly consistent with the original strip. If we use the conventional parameterisation, then the surface is not periodic, and we have a reversal of the order of the interpolation points where the strip is joined. This reversal of order causes undulations for a large portion of the surface. Harmonic interpolation fails to interpolate the points on the surface of revolution (figure 5.36) correctly. Severely high curvature is indicated on the curvature diagrams of the harmonic surface for both the Gaussian curvature and the mean curvature. The severe undulation is clearly visible. In this particular object, the parameterisation is not periodic. We address this problem in figure 5.43.

203 5.9. Curvature 183 (a) Moëbius strip (b) Gaussian curvature (c) Mean curvature (d) Harmonic surface (e) Gaussian curvature (f) Mean curvature Figure 5.35: Comparison of Moëbius strip and harmonic surface. (a) Surface of revolution (b) Gaussian curvature (c) Mean curvature (d) Harmonic surface (e) Gaussian curvature (f) Mean curvature Figure 5.36: Comparison of surface of revolution and harmonic surface.

204 184 Chapter 5. Harmonic Surfaces (a) Shell (b) Gaussian curvature (c) Mean curvature (d) Harmonic surface (e) Gaussian curvature (f) Mean curvature Figure 5.37: Comparison of shell and harmonic surface. Once again the non-periodic interpolation causes some problems with the shell in figure The object has been stretched and exhibits higher curvature in a few places of the harmonic interpolation of the shell. In this particular instance it is more challenging to determine a successful periodic parameterisation of the shell. Although the shape of the harmonic surface in figure 5.38 does not match the parametric surface, it seems to have the same character. The higher curvature in the centre of the shell indicates the difficulty harmonic interpolation has at this point. The rounded edges are produced by the periodic interpolation: the harmonic surface begins bending back toward the centre of the shell. The Klein bottle is also not periodic. We once again see severe undulations in figure 5.39, along with high curvature in the harmonic interpolation of the surface. Harmonic interpolation has failed to produce an acceptable surface in this case. The overhand knot (figure 5.40) changes direction frequently as indicated by the curvature. Our parametrisation results in a rotation of 90 in the interpolation points where the surface is joined. The produced surface is thus not strictly periodic. However, harmonic interpolation produces reasonable results for a large portion of the surface. There is undulation in the segment

205 5.9. Curvature 185 (a) Another shell (b) Gaussian curvature (c) Mean curvature (d) Harmonic surface (e) Gaussian curvature (f) Mean curvature Figure 5.38: Comparison of another shell and harmonic surface. (a) Klein bottle (b) Gaussian curvature (c) Mean curvature (d) Harmonic surface (e) Gaussian curvature (f) Mean curvature Figure 5.39: Comparison of partial Klein bottle and harmonic surface.

206 186 Chapter 5. Harmonic Surfaces (a) Overhand knot (b) Gaussian curvature (c) Mean curvature (d) Harmonic surface (e) Gaussian curvature (f) Mean curvature Figure 5.40: Comparison of overhand knot and harmonic surface. where the rotation takes place which causes earlier portions of the surface to be enlarged. This region is also characterised by high curvature. The undulations have not carried through to the whole surface. Examination of the basis functions of harmonic interpolation indicates that the effect of an interpolation point decreases with distance from that point (although this is not guaranteed). Even though the basis functions have all interpolation points as support, the effect of interpolation points that disturb the surface usually diminishes with distance from that point. Under the circumstances, harmonic interpolation has performed reasonably well. Solomon s Seal knot is represented reasonably well by the harmonic surface in figure The intricacy of the surface would probably be better reproduced if more samples were taken. We see that harmonic interpolation performs remarkably well with a sampling rate of 48 4 in figure If we parametrise the surface of revolution using g(θ) f(u, v) = cos ρ(sin θ + 2) sin ρ(sin θ + 2)

207 5.9. Curvature 187 (a) Solomon s Seal knot (b) Gaussian curvature (c) Mean curvature (d) Harmonic surface (e) Gaussian curvature (f) Mean curvature Figure 5.41: Comparison of Solomon s Seal knot and harmonic surface. (a) Solomon s Seal knot (b) Gaussian curvature (c) Mean curvature (d) Harmonic surface (e) Gaussian curvature (f) Mean curvature Figure 5.42: Comparison of Solomon s Seal knot (higher sampling rate) and harmonic surface.

208 188 Chapter 5. Harmonic Surfaces (a) Surface of revolution (b) Gaussian curvature (c) Mean curvature (d) Harmonic surface (e) Gaussian curvature (f) Mean curvature Figure 5.43: Comparison of periodic surface of revolution and harmonic surface. with θ = 4πu π, ρ = 2πv and { θ, θ < π g(θ) = 2π θ, otherwise, we obtain a periodic surface. We then add the restriction 0 < u < 0.5 to obtain the results in figure The results are far better than those obtained in figure In a few of the surfaces we note disturbing undulations. We cannot predict these effects as yet, but some indications as to causes and solutions were provided. However, Halstead et al. note that their interpolating subdivision surfaces also have this problem [30]. Interpolation can often cause this kind of behaviour. Halstead et al. use a fairness norm [10] to address these issues. It may be possible to attempt a similar approach for harmonic interpolation Conclusion In this chapter we have discussed the construction of smooth harmonic surfaces. Harmonic tensor product surfaces were discussed and form the core of the discussion. An algorithm for fitting a surface to a set of points was presented. Finally, the topic of displaying surfaces was discussed. In particular

Mathematical Tools in Computer Graphics with C# Implementations Table of Contents

Mathematical Tools in Computer Graphics with C# Implementations Table of Contents Mathematical Tools in Computer Graphics with C# Implementations by Hardy Alexandre, Willi-Hans Steeb, World Scientific Publishing Company, Incorporated, 2008 Table of Contents List of Figures Notation

More information

MATHEMATICAL TOOLS IN COMPUTER GRAPHICS WITH C# IMPLEMENTATIONS

MATHEMATICAL TOOLS IN COMPUTER GRAPHICS WITH C# IMPLEMENTATIONS MATHEMATICAL TOOLS IN COMPUTER GRAPHICS WITH C# IMPLEMENTATIONS This page intentionally left blank World Scientific N E W J E R S E Y L O N D O N S I N G A P O R E B E I J I N G S H A N G H A I H O N G

More information

Design considerations

Design considerations Curves Design considerations local control of shape design each segment independently smoothness and continuity ability to evaluate derivatives stability small change in input leads to small change in

More information

Computer Graphics Curves and Surfaces. Matthias Teschner

Computer Graphics Curves and Surfaces. Matthias Teschner Computer Graphics Curves and Surfaces Matthias Teschner Outline Introduction Polynomial curves Bézier curves Matrix notation Curve subdivision Differential curve properties Piecewise polynomial curves

More information

COMPUTER AIDED GEOMETRIC DESIGN. Thomas W. Sederberg

COMPUTER AIDED GEOMETRIC DESIGN. Thomas W. Sederberg COMPUTER AIDED GEOMETRIC DESIGN Thomas W. Sederberg January 31, 2011 ii T. W. Sederberg iii Preface This semester is the 24 th time I have taught a course at Brigham Young University titled, Computer Aided

More information

Freeform Curves on Spheres of Arbitrary Dimension

Freeform Curves on Spheres of Arbitrary Dimension Freeform Curves on Spheres of Arbitrary Dimension Scott Schaefer and Ron Goldman Rice University 6100 Main St. Houston, TX 77005 sschaefe@rice.edu and rng@rice.edu Abstract Recursive evaluation procedures

More information

Computergrafik. Matthias Zwicker. Herbst 2010

Computergrafik. Matthias Zwicker. Herbst 2010 Computergrafik Matthias Zwicker Universität Bern Herbst 2010 Today Curves NURBS Surfaces Parametric surfaces Bilinear patch Bicubic Bézier patch Advanced surface modeling Piecewise Bézier curves Each segment

More information

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016 Computergrafik Matthias Zwicker Universität Bern Herbst 2016 Today Curves NURBS Surfaces Parametric surfaces Bilinear patch Bicubic Bézier patch Advanced surface modeling 2 Piecewise Bézier curves Each

More information

CS130 : Computer Graphics Curves (cont.) Tamar Shinar Computer Science & Engineering UC Riverside

CS130 : Computer Graphics Curves (cont.) Tamar Shinar Computer Science & Engineering UC Riverside CS130 : Computer Graphics Curves (cont.) Tamar Shinar Computer Science & Engineering UC Riverside Blending Functions Blending functions are more convenient basis than monomial basis canonical form (monomial

More information

The goal is the definition of points with numbers and primitives with equations or functions. The definition of points with numbers requires a

The goal is the definition of points with numbers and primitives with equations or functions. The definition of points with numbers requires a The goal is the definition of points with numbers and primitives with equations or functions. The definition of points with numbers requires a coordinate system and then the measuring of the point with

More information

Fall CSCI 420: Computer Graphics. 4.2 Splines. Hao Li.

Fall CSCI 420: Computer Graphics. 4.2 Splines. Hao Li. Fall 2014 CSCI 420: Computer Graphics 4.2 Splines Hao Li http://cs420.hao-li.com 1 Roller coaster Next programming assignment involves creating a 3D roller coaster animation We must model the 3D curve

More information

Curves and Surfaces for Computer-Aided Geometric Design

Curves and Surfaces for Computer-Aided Geometric Design Curves and Surfaces for Computer-Aided Geometric Design A Practical Guide Fourth Edition Gerald Farin Department of Computer Science Arizona State University Tempe, Arizona /ACADEMIC PRESS I San Diego

More information

Central issues in modelling

Central issues in modelling Central issues in modelling Construct families of curves, surfaces and volumes that can represent common objects usefully; are easy to interact with; interaction includes: manual modelling; fitting to

More information

Lecture 25: Bezier Subdivision. And he took unto him all these, and divided them in the midst, and laid each piece one against another: Genesis 15:10

Lecture 25: Bezier Subdivision. And he took unto him all these, and divided them in the midst, and laid each piece one against another: Genesis 15:10 Lecture 25: Bezier Subdivision And he took unto him all these, and divided them in the midst, and laid each piece one against another: Genesis 15:10 1. Divide and Conquer If we are going to build useful

More information

Subdivision Surfaces

Subdivision Surfaces Subdivision Surfaces 1 Geometric Modeling Sometimes need more than polygon meshes Smooth surfaces Traditional geometric modeling used NURBS Non uniform rational B-Spline Demo 2 Problems with NURBS A single

More information

2D Spline Curves. CS 4620 Lecture 18

2D Spline Curves. CS 4620 Lecture 18 2D Spline Curves CS 4620 Lecture 18 2014 Steve Marschner 1 Motivation: smoothness In many applications we need smooth shapes that is, without discontinuities So far we can make things with corners (lines,

More information

ECE 600, Dr. Farag, Summer 09

ECE 600, Dr. Farag, Summer 09 ECE 6 Summer29 Course Supplements. Lecture 4 Curves and Surfaces Aly A. Farag University of Louisville Acknowledgements: Help with these slides were provided by Shireen Elhabian A smile is a curve that

More information

2D Spline Curves. CS 4620 Lecture 13

2D Spline Curves. CS 4620 Lecture 13 2D Spline Curves CS 4620 Lecture 13 2008 Steve Marschner 1 Motivation: smoothness In many applications we need smooth shapes [Boeing] that is, without discontinuities So far we can make things with corners

More information

Splines. Parameterization of a Curve. Curve Representations. Roller coaster. What Do We Need From Curves in Computer Graphics? Modeling Complex Shapes

Splines. Parameterization of a Curve. Curve Representations. Roller coaster. What Do We Need From Curves in Computer Graphics? Modeling Complex Shapes CSCI 420 Computer Graphics Lecture 8 Splines Jernej Barbic University of Southern California Hermite Splines Bezier Splines Catmull-Rom Splines Other Cubic Splines [Angel Ch 12.4-12.12] Roller coaster

More information

Parameterization of triangular meshes

Parameterization of triangular meshes Parameterization of triangular meshes Michael S. Floater November 10, 2009 Triangular meshes are often used to represent surfaces, at least initially, one reason being that meshes are relatively easy to

More information

Know it. Control points. B Spline surfaces. Implicit surfaces

Know it. Control points. B Spline surfaces. Implicit surfaces Know it 15 B Spline Cur 14 13 12 11 Parametric curves Catmull clark subdivision Parametric surfaces Interpolating curves 10 9 8 7 6 5 4 3 2 Control points B Spline surfaces Implicit surfaces Bezier surfaces

More information

08 - Designing Approximating Curves

08 - Designing Approximating Curves 08 - Designing Approximating Curves Acknowledgement: Olga Sorkine-Hornung, Alexander Sorkine-Hornung, Ilya Baran Last time Interpolating curves Monomials Lagrange Hermite Different control types Polynomials

More information

Curves and Surfaces. Shireen Elhabian and Aly A. Farag University of Louisville

Curves and Surfaces. Shireen Elhabian and Aly A. Farag University of Louisville Curves and Surfaces Shireen Elhabian and Aly A. Farag University of Louisville February 21 A smile is a curve that sets everything straight Phyllis Diller (American comedienne and actress, born 1917) Outline

More information

Curves D.A. Forsyth, with slides from John Hart

Curves D.A. Forsyth, with slides from John Hart Curves D.A. Forsyth, with slides from John Hart Central issues in modelling Construct families of curves, surfaces and volumes that can represent common objects usefully; are easy to interact with; interaction

More information

Parameterization. Michael S. Floater. November 10, 2011

Parameterization. Michael S. Floater. November 10, 2011 Parameterization Michael S. Floater November 10, 2011 Triangular meshes are often used to represent surfaces, at least initially, one reason being that meshes are relatively easy to generate from point

More information

Curve and Surface Basics

Curve and Surface Basics Curve and Surface Basics Implicit and parametric forms Power basis form Bezier curves Rational Bezier Curves Tensor Product Surfaces ME525x NURBS Curve and Surface Modeling Page 1 Implicit and Parametric

More information

3D Modeling Parametric Curves & Surfaces. Shandong University Spring 2013

3D Modeling Parametric Curves & Surfaces. Shandong University Spring 2013 3D Modeling Parametric Curves & Surfaces Shandong University Spring 2013 3D Object Representations Raw data Point cloud Range image Polygon soup Surfaces Mesh Subdivision Parametric Implicit Solids Voxels

More information

Bezier Curves, B-Splines, NURBS

Bezier Curves, B-Splines, NURBS Bezier Curves, B-Splines, NURBS Example Application: Font Design and Display Curved objects are everywhere There is always need for: mathematical fidelity high precision artistic freedom and flexibility

More information

An introduction to interpolation and splines

An introduction to interpolation and splines An introduction to interpolation and splines Kenneth H. Carpenter, EECE KSU November 22, 1999 revised November 20, 2001, April 24, 2002, April 14, 2004 1 Introduction Suppose one wishes to draw a curve

More information

09 - Designing Surfaces. CSCI-GA Computer Graphics - Fall 16 - Daniele Panozzo

09 - Designing Surfaces. CSCI-GA Computer Graphics - Fall 16 - Daniele Panozzo 9 - Designing Surfaces Triangular surfaces A surface can be discretized by a collection of points and triangles Each triangle is a subset of a plane Every point on the surface can be expressed as an affine

More information

Information Coding / Computer Graphics, ISY, LiTH. Splines

Information Coding / Computer Graphics, ISY, LiTH. Splines 28(69) Splines Originally a drafting tool to create a smooth curve In computer graphics: a curve built from sections, each described by a 2nd or 3rd degree polynomial. Very common in non-real-time graphics,

More information

Parametric curves. Brian Curless CSE 457 Spring 2016

Parametric curves. Brian Curless CSE 457 Spring 2016 Parametric curves Brian Curless CSE 457 Spring 2016 1 Reading Required: Angel 10.1-10.3, 10.5.2, 10.6-10.7, 10.9 Optional Bartels, Beatty, and Barsky. An Introduction to Splines for use in Computer Graphics

More information

Splines. Connecting the Dots

Splines. Connecting the Dots Splines or: Connecting the Dots Jens Ogniewski Information Coding Group Linköping University Before we start... Some parts won t be part of the exam Basically all that is not described in the book. More

More information

3D Modeling Parametric Curves & Surfaces

3D Modeling Parametric Curves & Surfaces 3D Modeling Parametric Curves & Surfaces Shandong University Spring 2012 3D Object Representations Raw data Point cloud Range image Polygon soup Solids Voxels BSP tree CSG Sweep Surfaces Mesh Subdivision

More information

Computer Graphics CS 543 Lecture 13a Curves, Tesselation/Geometry Shaders & Level of Detail

Computer Graphics CS 543 Lecture 13a Curves, Tesselation/Geometry Shaders & Level of Detail Computer Graphics CS 54 Lecture 1a Curves, Tesselation/Geometry Shaders & Level of Detail Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) So Far Dealt with straight lines

More information

Surfaces for CAGD. FSP Tutorial. FSP-Seminar, Graz, November

Surfaces for CAGD. FSP Tutorial. FSP-Seminar, Graz, November Surfaces for CAGD FSP Tutorial FSP-Seminar, Graz, November 2005 1 Tensor Product Surfaces Given: two curve schemes (Bézier curves or B splines): I: x(u) = m i=0 F i(u)b i, u [a, b], II: x(v) = n j=0 G

More information

CS-184: Computer Graphics

CS-184: Computer Graphics CS-184: Computer Graphics Lecture #12: Curves and Surfaces Prof. James O Brien University of California, Berkeley V2007-F-12-1.0 Today General curve and surface representations Splines and other polynomial

More information

GEOMETRIC TOOLS FOR COMPUTER GRAPHICS

GEOMETRIC TOOLS FOR COMPUTER GRAPHICS GEOMETRIC TOOLS FOR COMPUTER GRAPHICS PHILIP J. SCHNEIDER DAVID H. EBERLY MORGAN KAUFMANN PUBLISHERS A N I M P R I N T O F E L S E V I E R S C I E N C E A M S T E R D A M B O S T O N L O N D O N N E W

More information

Kai Hormann, N. Sukumar. Generalized Barycentric Coordinates in Computer Graphics and Computational Mechanics

Kai Hormann, N. Sukumar. Generalized Barycentric Coordinates in Computer Graphics and Computational Mechanics Kai Hormann, N. Sukumar Generalized Barycentric Coordinates in Computer Graphics and Computational Mechanics Contents Chapter 1 Multi-Sided Patches via Barycentric Coordinates 1 Scott Schaefer 1.1 INTRODUCTION

More information

CS 536 Computer Graphics Intro to Curves Week 1, Lecture 2

CS 536 Computer Graphics Intro to Curves Week 1, Lecture 2 CS 536 Computer Graphics Intro to Curves Week 1, Lecture 2 David Breen, William Regli and Maxim Peysakhov Department of Computer Science Drexel University 1 Outline Math review Introduction to 2D curves

More information

Curves. Computer Graphics CSE 167 Lecture 11

Curves. Computer Graphics CSE 167 Lecture 11 Curves Computer Graphics CSE 167 Lecture 11 CSE 167: Computer graphics Polynomial Curves Polynomial functions Bézier Curves Drawing Bézier curves Piecewise Bézier curves Based on slides courtesy of Jurgen

More information

Properties of Blending Functions

Properties of Blending Functions Chapter 5 Properties of Blending Functions We have just studied how the Bernstein polynomials serve very nicely as blending functions. We have noted that a degree n Bézier curve always begins at P 0 and

More information

Intro to Curves Week 1, Lecture 2

Intro to Curves Week 1, Lecture 2 CS 536 Computer Graphics Intro to Curves Week 1, Lecture 2 David Breen, William Regli and Maxim Peysakhov Department of Computer Science Drexel University Outline Math review Introduction to 2D curves

More information

u 0+u 2 new boundary vertex

u 0+u 2 new boundary vertex Combined Subdivision Schemes for the design of surfaces satisfying boundary conditions Adi Levin School of Mathematical Sciences, Tel-Aviv University, Tel-Aviv 69978, Israel. Email:fadilev@math.tau.ac.ilg

More information

Physically-Based Modeling and Animation. University of Missouri at Columbia

Physically-Based Modeling and Animation. University of Missouri at Columbia Overview of Geometric Modeling Overview 3D Shape Primitives: Points Vertices. Curves Lines, polylines, curves. Surfaces Triangle meshes, splines, subdivision surfaces, implicit surfaces, particles. Solids

More information

Advanced Modeling 2. Katja Bühler, Andrej Varchola, Eduard Gröller. March 24, x(t) z(t)

Advanced Modeling 2. Katja Bühler, Andrej Varchola, Eduard Gröller. March 24, x(t) z(t) Advanced Modeling 2 Katja Bühler, Andrej Varchola, Eduard Gröller March 24, 2014 1 Parametric Representations A parametric curve in E 3 is given by x(t) c : c(t) = y(t) ; t I = [a, b] R z(t) where x(t),

More information

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Parametric Curves University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Parametric Representations 3 basic representation strategies: Explicit: y = mx + b Implicit: ax + by + c

More information

INF3320 Computer Graphics and Discrete Geometry

INF3320 Computer Graphics and Discrete Geometry INF3320 Computer Graphics and Discrete Geometry More smooth Curves and Surfaces Christopher Dyken, Michael Floater and Martin Reimers 10.11.2010 Page 1 More smooth Curves and Surfaces Akenine-Möller, Haines

More information

Rational Bezier Curves

Rational Bezier Curves Rational Bezier Curves Use of homogeneous coordinates Rational spline curve: define a curve in one higher dimension space, project it down on the homogenizing variable Mathematical formulation: n P(u)

More information

Until now we have worked with flat entities such as lines and flat polygons. Fit well with graphics hardware Mathematically simple

Until now we have worked with flat entities such as lines and flat polygons. Fit well with graphics hardware Mathematically simple Curves and surfaces Escaping Flatland Until now we have worked with flat entities such as lines and flat polygons Fit well with graphics hardware Mathematically simple But the world is not composed of

More information

UNIVERSITY OF CALGARY. Subdivision Surfaces. Advanced Geometric Modeling Faramarz Samavati

UNIVERSITY OF CALGARY. Subdivision Surfaces. Advanced Geometric Modeling Faramarz Samavati Subdivision Surfaces Surfaces Having arbitrary Topologies Tensor Product Surfaces Non Tensor Surfaces We can t find u-curves and v-curves in general surfaces General Subdivision Coarse mesh Subdivision

More information

CSE 167: Introduction to Computer Graphics Lecture #11: Bezier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

CSE 167: Introduction to Computer Graphics Lecture #11: Bezier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016 CSE 167: Introduction to Computer Graphics Lecture #11: Bezier Curves Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016 Announcements Project 3 due tomorrow Midterm 2 next

More information

Homework #2. Hidden Surfaces, Projections, Shading and Texture, Ray Tracing, and Parametric Curves

Homework #2. Hidden Surfaces, Projections, Shading and Texture, Ray Tracing, and Parametric Curves Computer Graphics Instructor: Brian Curless CSE 457 Spring 2013 Homework #2 Hidden Surfaces, Projections, Shading and Texture, Ray Tracing, and Parametric Curves Assigned: Sunday, May 12 th Due: Thursday,

More information

Introduction p. 1 What Is Geometric Modeling? p. 1 Computer-aided geometric design Solid modeling Algebraic geometry Computational geometry

Introduction p. 1 What Is Geometric Modeling? p. 1 Computer-aided geometric design Solid modeling Algebraic geometry Computational geometry Introduction p. 1 What Is Geometric Modeling? p. 1 Computer-aided geometric design Solid modeling Algebraic geometry Computational geometry Representation Ab initio design Rendering Solid modelers Kinematic

More information

Fathi El-Yafi Project and Software Development Manager Engineering Simulation

Fathi El-Yafi Project and Software Development Manager Engineering Simulation An Introduction to Geometry Design Algorithms Fathi El-Yafi Project and Software Development Manager Engineering Simulation 1 Geometry: Overview Geometry Basics Definitions Data Semantic Topology Mathematics

More information

PS Geometric Modeling Homework Assignment Sheet I (Due 20-Oct-2017)

PS Geometric Modeling Homework Assignment Sheet I (Due 20-Oct-2017) Homework Assignment Sheet I (Due 20-Oct-2017) Assignment 1 Let n N and A be a finite set of cardinality n = A. By definition, a permutation of A is a bijective function from A to A. Prove that there exist

More information

Generalized barycentric coordinates

Generalized barycentric coordinates Generalized barycentric coordinates Michael S. Floater August 20, 2012 In this lecture, we review the definitions and properties of barycentric coordinates on triangles, and study generalizations to convex,

More information

A story about Non Uniform Rational B-Splines. E. Shcherbakov

A story about Non Uniform Rational B-Splines. E. Shcherbakov A story about Non Uniform Rational B-Splines E. Shcherbakov Speakers 09-06: B-spline curves (W. Dijkstra) 16-06: NURBS (E. Shcherbakov) 30-06: B-spline surfaces (M. Patricio) Seminar 16-06-2004 2 Outline

More information

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics Parametric Curves University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Parametric Representations 3 basic representation strategies: Explicit: y = mx + b Implicit: ax + by + c

More information

CHAPTER 6 Parametric Spline Curves

CHAPTER 6 Parametric Spline Curves CHAPTER 6 Parametric Spline Curves When we introduced splines in Chapter 1 we focused on spline curves, or more precisely, vector valued spline functions. In Chapters 2 and 4 we then established the basic

More information

Curves and Surfaces 2

Curves and Surfaces 2 Curves and Surfaces 2 Computer Graphics Lecture 17 Taku Komura Today More about Bezier and Bsplines de Casteljau s algorithm BSpline : General form de Boor s algorithm Knot insertion NURBS Subdivision

More information

COMP3421. Global Lighting Part 2: Radiosity

COMP3421. Global Lighting Part 2: Radiosity COMP3421 Global Lighting Part 2: Radiosity Recap: Global Lighting The lighting equation we looked at earlier only handled direct lighting from sources: We added an ambient fudge term to account for all

More information

Bezier Curves. An Introduction. Detlef Reimers

Bezier Curves. An Introduction. Detlef Reimers Bezier Curves An Introduction Detlef Reimers detlefreimers@gmx.de http://detlefreimers.de September 1, 2011 Chapter 1 Bezier Curve Basics 1.1 Linear Interpolation This section will give you a basic introduction

More information

and the crooked shall be made straight, and the rough ways shall be made smooth; Luke 3:5

and the crooked shall be made straight, and the rough ways shall be made smooth; Luke 3:5 ecture 8: Knot Insertion Algorithms for B-Spline Curves and Surfaces and the crooked shall be made straight, and the rough ways shall be made smooth; uke 3:5. Motivation B-spline methods have several advantages

More information

CSE 167: Introduction to Computer Graphics Lecture #13: Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

CSE 167: Introduction to Computer Graphics Lecture #13: Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017 CSE 167: Introduction to Computer Graphics Lecture #13: Curves Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017 Announcements Project 4 due Monday Nov 27 at 2pm Next Tuesday:

More information

CSE 167: Introduction to Computer Graphics Lecture 12: Bézier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

CSE 167: Introduction to Computer Graphics Lecture 12: Bézier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013 CSE 167: Introduction to Computer Graphics Lecture 12: Bézier Curves Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013 Announcements Homework assignment 5 due tomorrow, Nov

More information

CS130 : Computer Graphics Curves. Tamar Shinar Computer Science & Engineering UC Riverside

CS130 : Computer Graphics Curves. Tamar Shinar Computer Science & Engineering UC Riverside CS130 : Computer Graphics Curves Tamar Shinar Computer Science & Engineering UC Riverside Design considerations local control of shape design each segment independently smoothness and continuity ability

More information

4 Parametrization of closed curves and surfaces

4 Parametrization of closed curves and surfaces 4 Parametrization of closed curves and surfaces Parametrically deformable models give rise to the question of obtaining parametrical descriptions of given pixel or voxel based object contours or surfaces,

More information

Knot Insertion and Reparametrization of Interval B-spline Curves

Knot Insertion and Reparametrization of Interval B-spline Curves International Journal of Video&Image Processing and Network Security IJVIPNS-IJENS Vol:14 No:05 1 Knot Insertion and Reparametrization of Interval B-spline Curves O. Ismail, Senior Member, IEEE Abstract

More information

Introduction to Computer Graphics

Introduction to Computer Graphics Introduction to Computer Graphics 2016 Spring National Cheng Kung University Instructors: Min-Chun Hu 胡敏君 Shih-Chin Weng 翁士欽 ( 西基電腦動畫 ) Data Representation Curves and Surfaces Limitations of Polygons Inherently

More information

Lecture IV Bézier Curves

Lecture IV Bézier Curves Lecture IV Bézier Curves Why Curves? Why Curves? Why Curves? Why Curves? Why Curves? Linear (flat) Curved Easier More pieces Looks ugly Complicated Fewer pieces Looks smooth What is a curve? Intuitively:

More information

For each question, indicate whether the statement is true or false by circling T or F, respectively.

For each question, indicate whether the statement is true or false by circling T or F, respectively. True/False For each question, indicate whether the statement is true or false by circling T or F, respectively. 1. (T/F) Rasterization occurs before vertex transformation in the graphics pipeline. 2. (T/F)

More information

Further Graphics. Bezier Curves and Surfaces. Alex Benton, University of Cambridge Supported in part by Google UK, Ltd

Further Graphics. Bezier Curves and Surfaces. Alex Benton, University of Cambridge Supported in part by Google UK, Ltd Further Graphics Bezier Curves and Surfaces Alex Benton, University of Cambridge alex@bentonian.com 1 Supported in part by Google UK, Ltd CAD, CAM, and a new motivation: shiny things Expensive products

More information

Subdivision Surfaces

Subdivision Surfaces Subdivision Surfaces 1 Geometric Modeling Sometimes need more than polygon meshes Smooth surfaces Traditional geometric modeling used NURBS Non uniform rational B-Spline Demo 2 Problems with NURBS A single

More information

(Refer Slide Time: 00:02:24 min)

(Refer Slide Time: 00:02:24 min) CAD / CAM Prof. Dr. P. V. Madhusudhan Rao Department of Mechanical Engineering Indian Institute of Technology, Delhi Lecture No. # 9 Parametric Surfaces II So these days, we are discussing the subject

More information

Curves and Surfaces 1

Curves and Surfaces 1 Curves and Surfaces 1 Representation of Curves & Surfaces Polygon Meshes Parametric Cubic Curves Parametric Bi-Cubic Surfaces Quadric Surfaces Specialized Modeling Techniques 2 The Teapot 3 Representing

More information

Parametric curves. Reading. Curves before computers. Mathematical curve representation. CSE 457 Winter Required:

Parametric curves. Reading. Curves before computers. Mathematical curve representation. CSE 457 Winter Required: Reading Required: Angel 10.1-10.3, 10.5.2, 10.6-10.7, 10.9 Parametric curves CSE 457 Winter 2014 Optional Bartels, Beatty, and Barsky. An Introduction to Splines for use in Computer Graphics and Geometric

More information

Pythagorean - Hodograph Curves: Algebra and Geometry Inseparable

Pythagorean - Hodograph Curves: Algebra and Geometry Inseparable Rida T. Farouki Pythagorean - Hodograph Curves: Algebra and Geometry Inseparable With 204 Figures and 15 Tables 4y Springer Contents 1 Introduction 1 1.1 The Lure of Analytic Geometry 1 1.2 Symbiosis of

More information

An Introduction to B-Spline Curves

An Introduction to B-Spline Curves An Introduction to B-Spline Curves Thomas W. Sederberg March 14, 2005 1 B-Spline Curves Most shapes are simply too complicated to define using a single Bézier curve. A spline curve is a sequence of curve

More information

Spline Methods Draft. Tom Lyche and Knut Mørken

Spline Methods Draft. Tom Lyche and Knut Mørken Spline Methods Draft Tom Lyche and Knut Mørken 24th May 2002 2 Contents 1 Splines and B-splines an introduction 3 1.1 Convex combinations and convex hulls..................... 3 1.1.1 Stable computations...........................

More information

Spline Methods Draft. Tom Lyche and Knut Mørken

Spline Methods Draft. Tom Lyche and Knut Mørken Spline Methods Draft Tom Lyche and Knut Mørken January 5, 2005 2 Contents 1 Splines and B-splines an Introduction 3 1.1 Convex combinations and convex hulls.................... 3 1.1.1 Stable computations...........................

More information

B-spline Curves. Smoother than other curve forms

B-spline Curves. Smoother than other curve forms Curves and Surfaces B-spline Curves These curves are approximating rather than interpolating curves. The curves come close to, but may not actually pass through, the control points. Usually used as multiple,

More information

Sung-Eui Yoon ( 윤성의 )

Sung-Eui Yoon ( 윤성의 ) CS480: Computer Graphics Curves and Surfaces Sung-Eui Yoon ( 윤성의 ) Course URL: http://jupiter.kaist.ac.kr/~sungeui/cg Today s Topics Surface representations Smooth curves Subdivision 2 Smooth Curves and

More information

MA 323 Geometric Modelling Course Notes: Day 21 Three Dimensional Bezier Curves, Projections and Rational Bezier Curves

MA 323 Geometric Modelling Course Notes: Day 21 Three Dimensional Bezier Curves, Projections and Rational Bezier Curves MA 323 Geometric Modelling Course Notes: Day 21 Three Dimensional Bezier Curves, Projections and Rational Bezier Curves David L. Finn Over the next few days, we will be looking at extensions of Bezier

More information

CS354 Computer Graphics Surface Representation IV. Qixing Huang March 7th 2018

CS354 Computer Graphics Surface Representation IV. Qixing Huang March 7th 2018 CS354 Computer Graphics Surface Representation IV Qixing Huang March 7th 2018 Today s Topic Subdivision surfaces Implicit surface representation Subdivision Surfaces Building complex models We can extend

More information

Intro to Curves Week 4, Lecture 7

Intro to Curves Week 4, Lecture 7 CS 430/536 Computer Graphics I Intro to Curves Week 4, Lecture 7 David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory Department of Computer Science Drexel University

More information

CS-184: Computer Graphics. Today

CS-184: Computer Graphics. Today CS-84: Computer Graphics Lecture #5: Curves and Surfaces Prof. James O Brien University of California, Berkeley V25F-5-. Today General curve and surface representations Splines and other polynomial bases

More information

Normals of subdivision surfaces and their control polyhedra

Normals of subdivision surfaces and their control polyhedra Computer Aided Geometric Design 24 (27 112 116 www.elsevier.com/locate/cagd Normals of subdivision surfaces and their control polyhedra I. Ginkel a,j.peters b,,g.umlauf a a University of Kaiserslautern,

More information

Spline Methods Draft. Tom Lyche and Knut Mørken. Department of Informatics Centre of Mathematics for Applications University of Oslo

Spline Methods Draft. Tom Lyche and Knut Mørken. Department of Informatics Centre of Mathematics for Applications University of Oslo Spline Methods Draft Tom Lyche and Knut Mørken Department of Informatics Centre of Mathematics for Applications University of Oslo January 27, 2006 Contents 1 Splines and B-splines an Introduction 1 1.1

More information

CS 475 / CS 675 Computer Graphics. Lecture 16 : Interpolation for Animation

CS 475 / CS 675 Computer Graphics. Lecture 16 : Interpolation for Animation CS 475 / CS 675 Computer Graphics Lecture 16 : Interpolation for Keyframing Selected (key) frames are specified. Interpolation of intermediate frames. Simple and popular approach. May give incorrect (inconsistent)

More information

Intro to Modeling Modeling in 3D

Intro to Modeling Modeling in 3D Intro to Modeling Modeling in 3D Polygon sets can approximate more complex shapes as discretized surfaces 2 1 2 3 Curve surfaces in 3D Sphere, ellipsoids, etc Curved Surfaces Modeling in 3D ) ( 2 2 2 2

More information

Need for Parametric Equations

Need for Parametric Equations Curves and Surfaces Curves and Surfaces Need for Parametric Equations Affine Combinations Bernstein Polynomials Bezier Curves and Surfaces Continuity when joining curves B Spline Curves and Surfaces Need

More information

Curves and Surfaces Computer Graphics I Lecture 9

Curves and Surfaces Computer Graphics I Lecture 9 15-462 Computer Graphics I Lecture 9 Curves and Surfaces Parametric Representations Cubic Polynomial Forms Hermite Curves Bezier Curves and Surfaces [Angel 10.1-10.6] February 19, 2002 Frank Pfenning Carnegie

More information

Computer Graphics I Lecture 11

Computer Graphics I Lecture 11 15-462 Computer Graphics I Lecture 11 Midterm Review Assignment 3 Movie Midterm Review Midterm Preview February 26, 2002 Frank Pfenning Carnegie Mellon University http://www.cs.cmu.edu/~fp/courses/graphics/

More information

Spline Surfaces, Subdivision Surfaces

Spline Surfaces, Subdivision Surfaces CS-C3100 Computer Graphics Spline Surfaces, Subdivision Surfaces vectorportal.com Trivia Assignment 1 due this Sunday! Feedback on the starter code, difficulty, etc., much appreciated Put in your README

More information

Shape Representation Basic problem We make pictures of things How do we describe those things? Many of those things are shapes Other things include

Shape Representation Basic problem We make pictures of things How do we describe those things? Many of those things are shapes Other things include Shape Representation Basic problem We make pictures of things How do we describe those things? Many of those things are shapes Other things include motion, behavior Graphics is a form of simulation and

More information

Curves & Surfaces. Last Time? Progressive Meshes. Selective Refinement. Adjacency Data Structures. Mesh Simplification. Mesh Simplification

Curves & Surfaces. Last Time? Progressive Meshes. Selective Refinement. Adjacency Data Structures. Mesh Simplification. Mesh Simplification Last Time? Adjacency Data Structures Curves & Surfaces Geometric & topologic information Dynamic allocation Efficiency of access Mesh Simplification edge collapse/vertex split geomorphs progressive transmission

More information

Figure 5.1: Spline and ducks.

Figure 5.1: Spline and ducks. Chapter 5 B-SPLINE CURVES Most shapes are simply too complicated to define using a single Bézier curve. A spline curve is a sequence of curve segments that are connected together to form a single continuous

More information

Name: Let the Catmull-Rom curve q(u) be defined by the following control points: p 1 = 0, 1 p 2 = 1, 1 p 3 = 1, 0. p 2. p 1.

Name: Let the Catmull-Rom curve q(u) be defined by the following control points: p 1 = 0, 1 p 2 = 1, 1 p 3 = 1, 0. p 2. p 1. Name: 2 1. Let the Catmull-Rom curve q(u) be defined by the following control points: p 0 = 0, 0 p 1 = 0, 1 p 2 = 1, 1 p 3 = 1, 0 p 4 = 2, 0 y p 1 p 2 p 0 p 3 p 4 x Thus, q(i) =p i for i =1, 2, 3. For

More information

Spline Notes. Marc Olano University of Maryland, Baltimore County. February 20, 2004

Spline Notes. Marc Olano University of Maryland, Baltimore County. February 20, 2004 Spline Notes Marc Olano University of Maryland, Baltimore County February, 4 Introduction I. Modeled after drafting tool A. Thin strip of wood or metal B. Control smooth curved path by running between

More information