• No results found

Curve Morphing via Surface Slicing

N/A
N/A
Protected

Academic year: 2021

Share "Curve Morphing via Surface Slicing"

Copied!
34
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

Curve Morphing via Surface Slicing

Computing Science BSc. Thesis

Freerk H. Oudman

primary supervisor

dr. Jiˇr´ı Kosinka

secondary supervisor

prof. dr. Alexandru C. Telea

Groningen, July 2017

(2)

Abstract

The classic way of morphing from one planar curve to another is to establish point correspondences between source and target curves and then design connecting trajectories between those points.

An alternative is to view the morphing trajectory as a spatial dimension. This way, we model the morph as a 3D surface with as its top and bottom the source and target curve, respectively.

This thesis investigates a method for initial creation of such a 3D surface, different operators to improve the transition smoothness, and a slicing implementation to evaluate the created morph.

Researched smoothing operators include Centroidal Voronoi Tessellation, different kinds of subdi- vision, T-scaling, and Laplacian Smoothing.

(3)

Contents

1 Introduction 2

1.1 Research goal . . . 2

1.2 Thesis structure . . . 2

2 Concepts 4 2.1 Open triangular surface meshes . . . 4

2.2 Centroidal Voronoi Tessellation . . . 4

2.3 Surface subdivision . . . 5

2.4 T-scaling . . . 6

3 Implementation 8 3.1 Code starting point . . . 8

3.2 Half-edge data structure . . . 9

3.3 Code architecture . . . 9

3.4 Connecting surface . . . 11

3.5 Slicing . . . 15

3.6 Other . . . 16

4 Results 18 4.1 Surface construction . . . 18

4.2 T-scaling + Loop subdivision . . . 18

4.3 T-scaling + CVT (Lloyd) . . . 18

4.4 T-scaling + Laplacian . . . 21

4.5 T-scaling + plain subdivision + CVT (Lloyd) . . . 22

4.6 T-scaling + plain subdivision + Laplacian . . . 22

4.7 Discussion . . . 28

5 Conclusion 29 5.1 Research question . . . 29

5.2 Future work . . . 29

List of Figures 31

References 32

(4)

Chapter 1

Introduction

1.1 Research goal

Given two curves, for example a square and a pentagon, how could one morph from one curve into the other? A standard approach for solving this question is to first find point correspondence between the source curve and target curve, and then to design trajectories for all these points. In Figure 1.1 example point correspondences between a square and a pentagon are indicated. If we would take linear point trajectories, the morph would consist of the square vertices 2 and 3 moving inwards, while vertices 1 and 4 move down- and outwards, and while vertex 5 emerges from the initial straight line between vertex 1 and 4. The result: a nice, simple morph between a square and a pentagon.

In essence, a 2D morph is a 3D shape, with the third dimension being the transition from the source to the target curve. Most often, the third dimension is represented as a time dimension, for example in a short video animation. A different option is to represent the third dimension as a spatial dimension. This way, we can view the 2D morph as a 3D shape. An 3D shape representation of the previous square - pentagon example is visible in Figure 1.2.

Instead of first finding point correspondence between curves, then designing connecting trajec- tories, and finally creating the morph, we could also take a different approach by first creating a coarse 3D shape representing the morph, and then finalizing the morph by smoothing the shape.

The corresponding question is: how to achieve this?

1.2 Thesis structure

For this thesis, I have researched different aspects of the smoothing process, these are described in Chapter 2. In Chapter 3 the implementation of the coarse shape creation, the different smoothing operators, and the slicing process are discussed. Results of these are covered in Chapter 4. Finally, Chapter 5 contains a conclusion and recommendations for future work.

(5)

(a) Source curve: square. (b) Target curve: pentagon.

Figure 1.1: Source and target curves.

Figure 1.2: A 2D morph visualized as a 3D shape. [9]

(6)

Chapter 2

Concepts

2.1 Open triangular surface meshes

In CAD systems, 3D models are stored as a combination of mathematical definitions which together define the exact shape. When absolute precision is less important than plasticity, a close approxi- mation of the exact shape with the use of a triangular mesh is sufficient. The main advantage of a triangular mesh over a mesh consisting of higher-order polygons is its simplicity, since a triangle surface is perfectly flat and always in exactly one plane, defined by the three corner vertices. A second reason for the usage of triangular meshes is that surfaces in this format can be easily edited, for example by adjusting vertex positions, or by adding or removing triangles. All in all, triangular meshes are the way to go in this research project.

There exists an important difference between open and closed meshes. Closed meshes form a

‘real’ shape, where open meshes are surfaces that do not fully enclose a volume. As an illustration, Figure 2.1a shows an open surface, representing a simple drinking cup. Figure 2.1b also represents a drinking cup, but with thickened walls that form together an enclosed volume, thus a closed mesh.

Since an open mesh does not fully enclose a volume, the mesh surface contains one or multiple boundaries. In the example of drinking cup example in Figure 2.1a this is the edge of the cup.

Such surface boundaries are treated differently by different smoothing operators. Some smoothing operators may change surface boundaries, others will leave the surface boundaries always exact the same. Since our 3D morph is an open mesh, defined by the surface between the source and target curves, we need to apply merely boundary preserving smoothing operators in order to not change the source and target curves.

2.2 Centroidal Voronoi Tessellation

The Centroidal Voronoi Tessellation operator, in short, CVT operator, is a special kind of smoothing operator. Not only does it stepwise adjust vertex locations, it also has the ability of flipping edges.

Simply said: CVT converges a mesh to a state in which every edge is as short as possible, and all edges and faces have as much the same (small) size.

Let us take as an example a situation in 2D, a surface with divided into six different faces. If we now take the gravity center of every face, and create from these points a Voronoi Diagram,

(7)

(a) An open mesh. (b) A closed mesh.

Figure 2.1: Open versus closed meshes. [9]

Figure 2.2: Illustration of CVT convergence in 2D. [7]

a situation in which every point has a corresponding face consisting of all locations of which the nearest point is the concerned point, we have applied one CVT iteration. We can repeat this until convergence. In Figure 2.2 this example is illustrated with an initial situation, the situation after one iteration, and the situation after convergence.

This described algorithm was originally developed by S. Lloyd [1]. Since convergence can be quite slow, superlinear variants of CVT have been developed, one of which L-BFGS [3]. This algorithm converges faster, but can give incorrect results in some cases. The starting code by J.

Vos [7] made use of code by Hao Pan [6] which implemented both algorithms.

2.3 Surface subdivision

A popular method to get from a shape with a rough surface to a shape with a smooth surface is by the usage of a subdivision surface. A widely-used variant is Loop subdivision, developed by Charles Loop in 1987 [2].

The algorithm consists of two steps per iteration:

• Every triangle is split up into four triangles.

• All vertices positions are updated using quartic box splines.

(8)

Figure 2.3: Icosahedron with two steps of Loop subdivision applied. [4]

As an example, Figure 2.3 shows two iterations of Loop subdivision applied to an icosahedron.

It is clearly visible how the icosahedron converges to a more sphere looking mesh.

Application of this algorithm gives two advantages: a higher triangle resolution and a smoother surface.

However, this has also one important drawback: since vertex positions are adjusted, boundaries of a mesh may change as well. The solution to this problem is simple, skipping the second step of the algorithm. By skipping the second step, we still have the advantage of a higher resolution, but not the disadvantage of the original mesh being changed. Subdividing a mesh without adjusting vertices is called plain subdivision. Since we still need a smoother surface, plain subdivision must always be combined with other smoothing operators such as CVT or Laplacian.

2.4 T-scaling

When applying CVT on a surface mesh, the surface will converge to a so-called minimal surface, a surface with the minimum surface area possible. This can cause unintended mesh squeezing, as visible in Figure 2.4a. A solution to this problem is by decreasing the T-distance by scaling the mesh. This way, the minimal surface will not squeeze the mesh as much. Results of T-scaling are visible in Figure 2.4. Clearly visible is how scaling decreases the squeezing of the mesh. Ideally, the scaling would be limT →0. Practically, value representations will not be precise enough when scaling to less than 0.1%. The implemented version of T-scaling has an option to scale the mesh while viewing the mesh scaled back to the original size. This way, results of smoothing operators on a scaled mesh are immediately visible.

(9)

(a) At 100% height. (b) At 50% height.

(c) At 25% height. (d) At 10% height.

Figure 2.4: Minimal surface between two squares at different distances

(10)

Chapter 3

Implementation

3.1 Code starting point

As mentioned, this research is a continuation of the work done by J. Vos [7]. All implemented algorithms have been build on top of his end code product. The code was written in C++, developed on top of the QT framework, with OpenGL used for rendering. The IDE used was QT Creator [10].

Key features of this starting code were the following:

• Import of obj files. Wavefront .obj is a simple human-readable file, representing meshes by a list of all mesh vertices and a list of faces, counter-clockwise defined by the indices of the vertices. Optionally, additional information such as texture vertices and face normals can be stored as well. The code only accepts .obj files with vertex and triangular face definitions.

• Half-edge structure. This data structure is used internally for mesh representation. See Section 3.2 for more details.

• Centroidal Voronoi Tessellation (CVT). This operator step-wise reorders faces between ver- tices and moves vertex locations a little in such a way that the resulting mesh slowly converges to a state in which every face has as much the same size, and in which every edge is as short as possible. See Section 2.2 for more details.

• Loop subdivision. This operator quadruples the number of triangles in the mesh and adjusts vertex locations to smooth the surface. See Section 2.3 for more details.

• Laplacian Smoothing. This operator smooths a mesh by adjusting vertex locations in the direction of the average of its vertex neighbors. I will not go into technical details here.

• Dual-dual. This is a double application of the dual operator. This smoothing operator only works on closed meshes. Because of this limitation, I have not used the operator. I will not go into technical details here.

• GUI. All operators are available through a GUI. A screenshot is visible in Figure 3.1.

(11)

Figure 3.1: Starting point GUI. [7]

3.2 Half-edge data structure

Meshes are implemented in the half-edge data structure. The half-edge data structure keeps track of all vertices, faces, edges and their connections. The basic type is, the name spoils it, half of an edge. Every edge is split up into two half-edges, one for every direction. Every half-edge contains a pointer to its twin half-edge, a pointer to its next half-edge measured counter-clockwise, a pointer to its previous half-edge, a pointer to its target vertex, and, if applicable, a pointer to the face of which the half-edge is a counter-clockwise half-edge. A topological illustration is visible in Figure 3.2. Every face contains a pointer to one of its counter-clockwise half-edges. Every vertex contains a pointer to (one of its) outgoing half-edges, and the vertex coordinates. A UML diagram of the complete half-edge implementation is visible in Figure 3.3.

It is important to keep care of all pointers when transforming the mesh using this structure.

But if handled correctly, the half-edge structure is a very robust data structure which can handle every mesh type, both open and closed meshes, with any type of polygon. Furthermore, traversing a mesh can be done quite fast.

3.3 Code architecture

The half-edge data structure in the starting point code was implemented trough the classes halfedge, face, and vertex. Three other important classes were the classes mesh, customopenglwidget, and loop- subdivision. The class mesh was used to store the halfedges, faces and vertices. The class loopsubdi- vision was used as a passthrough from the GUI. The class customopenglwidget functioned as a god class, containing basically all functionality. Next to adding new features, I had to refactor this class.

This refactoring consisted of moving a few functions from loopsubdivision to customopenglwidget, and moving a lot of functions from customopenglwidget to mesh.

Furthermore, I added the class edge. This class is used for curve representation and is needed for dealing with mesh slices.

(12)

Figure 3.2: Illustration of the half-edge relations. [5]

Figure 3.3: Half-edge UML collaboration diagram. [8]

(13)

Listing 3.1: Algorithm pseudocode: rough curve lining up 1 Z = h i g h e s t z−v a l u e o f a l l v e r t i c e s i n VERTS;

2 I = i n d e x o f f i r s t o c c u r r e n c e o f v e r t e x w i t h z−v a l u e Z i n VERTS;

3 s h i f t e l e m e n t s i n VERTS I s t e p s backwards ;

The final main structure is:

• The classes halfedge, face, and vertex. Used for the half-edge data structure implementation

• The class mesh. Used for storing 3D meshes, and containing all mesh operators.

• The class edge. Used for storing curves, and containing all curve operators.

• The class customopenglwidget. Used as a control class, containing the 3D mesh operations stack, applying operators, and rendering to the screen.

• The class loopsubdivision. Used as a passthrough from the GUI.

With this refactored code, coupling has been decreased and logical and functional cohesion has been increased.

3.4 Connecting surface

For connecting two curves with one surface, thus creating an open mesh, we first need two curves.

Since there does not exists a widely used standard format for segmented 2D curves, I decided to go with the .obj file format, extract the bottom outline from such an 3D mesh, and use this as a curve.

My implementation does the following. First, the algorithm slices both meshes at a height t, with t being the lowest T-value of the concerned mesh. Both curves are stored as an array of vertices, ordered counterclockwise from the perspective of the positive end of the Z-axis. More information about the slicing algorithm can be found in Section 3.5. Before connecting the two resulting curves, the algorithm roughly lines both curves up by shifting all curve vertices in such a way that the first vertex of a curve is the one with the highest Z coordinate.

Pseudocode for this lining up is shown in Listing 3.1. In this code, VERTS represents the curve vertices.

Next preparation step before creating the surface mesh is to calculate per curve the distances between every vertex and the starting vertex. This distance should be relative, so the total distance of a curve should be 1.0.

Pseudocode for distances calculation up is shown in Listing 3.2. In this code, VERTS represents the curve vertices, and DISTANCES represents the array with the relative distances.

Using these relative vertex distances, the algorithm can now compare both curves and create the connecting surface. It starts with both starting vertices, then moves along both counter-clockwise curves. If the next two curve vertices line up, in terms of relative distances, the algorithm connects both with an edge. If the next two vertices do not line up, it connects the nearest vertex with a newly added vertex in between the current vertex and next vertex of the other curve. The coordinates of

(14)

Listing 3.2: Algorithm pseudocode: relative distance calculation 1 TOTAL = 0 . 0 ;

2 DISTANCES = [ 0 . 0 ] ;

3 f o r ( i = 1 ; i < s i z e o f VERTS; i = i +1) {

4 TOTAL = TOTAL + d i s t a n c e between VERTS[ i −1] and VERTS[ i ] ; 5 append TOTAL t o DISTANCES ;

6 }

7 TOTAL = TOTAL + d i s t a n c e between f i r s t and l a s t v e r t i c e s i n VERTS;

8 d i v i d e e v e r y v a l u e i n DISTANCES by TOTAL;

(a) Two curves. (b) The curves connected.

Figure 3.4: Surface creation.

this inserted vertex can be calculated using the relative distances. If the relative distances of both next vertices are larger than a set minimum, the algorithm adds extra vertices to both curves. This is repeated until the surface is completed.

As an illustration, an example of connecting a square and a pentagon is visible in Figure 3.4.

In this example, the relative distances of the square are [0; 0.25; 0.5; 0.75], the relative distances of the pentagon are [0; 0.2; 0.4; 0.6; 0.8], and the minimum connecting distance is 0.05.

Pseudocode for curve connection up is shown in Listing 3.3. In this code, the surface mesh produced is stored in obj-style, with vertices stored in one array and faces stored in a second array, as a combination of vertex array indices. CURVEA and CURVEB represent the source and target curve, DISTA and DISTB represent the relative distances of both curves, A and B are index counters of both curves, MINRES represents the minimal resolution, DISTANCE keeps track of the surface created, VERTA and VERTB are temporary vertices, VERTS is the mesh vertex array, and FACES is the mesh face array. Intermediate vertices are calculated using the formula Vintermediate= distdistnext−distance

next−distcurr · Vcurr+ (1 − distdistnext−distance

next−distcurr) · Vnext.

In the last step, the algorithm optimizes the surface by shifting curve vertices in such a way that the average length of all edges connecting the starting outlines are minimized. The result of this operation is visible in Figure 3.5.

Pseudocode for lineup optimization is visible in Listing 3.4. In this code, VERTS is the mesh vertex array, as produced by the curve connecting algorithm in Listing 3.3. The functions

(15)

Listing 3.3: Algorithm pseudocode: connecting the curves 1 MINRES = 0 . 0 0 5 ;

2 DISTANCE = 0 . 0 3 A = 0 ;

4 B = 0 ; 5

6 VERTA = {CURVEA[A ] . x , −1.0 , CURVEA[A ] . z } ; 7 VERTB = {CURVEB[ B ] . x , 1 . 0 , CURVEB[ B ] . z } ; 8 append VERTA t o VERTS;

9 append VERTB t o VERTS;

10

11 while (DISTANCE+MINRES < 1 . 0 | | A+1 < s i z e o f CURVEA | | B+1 < s i z e o f CURVEB) {

12 i f (DISTANCE+MINRES < minimum o f DISTA [A+1] and DISTB [ B+ 1 ] ) ) {

13 DISTANCE = DISTANCE + MINRES ;

14 VERTA = i n t e r m e d i a t e v e r t e x ; 15 VERTB = i n t e r m e d i a t e v e r t e x ;

16 } e l s e i f (DISTA [A+1] == DISTB [ B+1]) {

17 A = A + 1 ;

18 B = B + 1 ;

19 DISTANCE = DISTA [A ] ;

20 VERTA = {CURVEA[A ] . x , −1.0 , CURVEA[A ] . z } ; 21 VERTB = {CURVEB[ B ] . x , 1 . 0 , CURVEB[ B ] . z } ; 22 } e l s e i f (DISTA [A+1] < DISTB [ B+1]) {

23 A = A + 1 ;

24 DISTANCE = DISTA [A ] ;

25 VERTA = {CURVEA[A ] . x , −1.0 , CURVEA[A ] . z } ; 26 VERTB = i n t e r m e d i a t e v e r t e x ;

27 } e l s e {

28 B = B + 1 ;

29 DISTANCE = DISTB [ B ] ;

30 VERTA = i n t e r m e d i a t e v e r t e x ;

31 VERTB = {CURVEB[ B ] . x , 1 . 0 , CURVEB[ B ] . z } ;

32 }

33 append VERTA t o VERTS;

34 append VERTB t o VERTS;

35 append { s i z e o f VERTS − 3 , s i z e o f VERTS − 2 , s i z e o f VERTS − 1} t o FACES ;

36 append { s i z e o f VERTS − 2 , s i z e o f VERTS − 3 , s i z e o f VERTS − 4} t o FACES ;

37 } 38

39 append { s i z e o f VERTS − 3 , 0 , 1} t o FACES ;

40 append { 0 , s i z e o f VERTS − 3 , s i z e o f VERTS − 4} t o FACES ;

(16)

(a) Before. (b) After.

Figure 3.5: Lining up connecting edges.

Listing 3.4: Algorithm pseudocode: better lining up 1 void f u n c t i o n SHIFT ( i n t OFFSET) {

2 f o r ( i = OFFSET ; i < s i z e o f VERTS − 1 ; i = i +2) { 3 swap VERTS[ i ] and VERTS[ i + 2 ] ;

4 }

5 } 6

7 void f u n c t i o n LINEUP ( ) { 8 TMP = 0 . 0 ;

9 SUM = sum o f l e n g t h s o f c o n n e c t i n g e d g e s ; 10 while (SUM >= TMP) {

11 SHIFT ( 0 ) ;

12 TMP = sum o f l e n g t h s o f c o n n e c t i n g e d g e s ;

13 SUM = minimum o f SUM and TMP;

14 }

15 TMP = 0 . 0 ;

16 while (SUM >= TMP) {

17 SHIFT ( 1 ) ;

18 TMP = sum o f l e n g t h s o f c o n n e c t i n g e d g e s ;

19 SUM = minimum o f SUM and TMP;

20 }

21 SHIFT ( 0 ) ; 22 }

(17)

MOVERIGHT() and MOVELEFT() exploit the way vertices are stored in VERTS: vertices at even indices are part of the bottom curve, while vertices at odd indices are part of the top curve.

By shifting all even vertices one place, the vertices of the bottom curve are shifted one position.

By shifting all odd vertices one place, the vertices of the top curve are shifted one position. The while-loops at lines 10 and 16 apply shifting until no better alignment can be found. The shift at line 21 compensates for the one step overshoot of the last while loop.

3.5 Slicing

The idea behind slicing is quite simple. Let us slice the surface mesh at height t. First, find an edge that crosses height t. From this edge, extract the crossing coordinates. Next, move forward from this edge to the next crossing. Repeat until we are back at the first found crossing.

Implementationwise, slicing is a bit harder. First, in case t lies somewhere halfway the mesh, there are a whopping seven possible cases of a half-edge crossing height t. Second, in case t touches the top or bottom of the mesh, four other cases are possible.

So I came up with an idea to combine all possible situations into one clear edge classification scheme, optimized for our moving forward algorithm.

0. above t → above t 1. under t → under t 2. exact t → above t 3. exact t → under t 4. above t → under t 5. under t → above t 6. above t → exact t 7. under t → exact t 8. exact t → exact t

Using this classification scheme, we can now develop a subroutine calculating relevant crossing points:

• Classes c ≤ 3 imply no relevant crossing, since classes 0 and 1 have no crossing point at all, and the crossing point in the classes 2 and 3 consists of the current coordinates.

• Classes 4 ≤ c ≤ 5 have their crossing point halfway.

• Classes c ≥ 6 have their crossing point as the target coordinates.

Using this classification, we can now develop an finite state machine with two states: state A in which the current crossing point is at height T, and state B in which the current crossing point is either above or under t. The FSM is visible in Figure 3.6. Please keep in mind that this FSM only works on triangular meshes!

This FSM has two problems: it has no starting state and no end state.

(18)

A

B next = 8

next= 2, 3, next.next = 4, 5

next = 4, 5 next = 6, 7

Figure 3.6: Slicing algorithm FSM

In the implementation, the algorithm starts with searching for a crossing edge. If it finds a crossing 4 ≤ c ≤ 5, it adds the crossing point to the edge and starts in state B. If it finds a crossing 6 ≤ c ≤ 7, it adds the crossing point to the edge and starts in state A. If it finds a crossing c = 8, it first adds the starting point of the edge, and then the crossing point to the edge and starts in state A. With these specific three starting cases, all cases in which t is somewhere halfway the mesh are covered, plus all cases in which t touches the mesh with only one, two or more points are covered.

To get to an end state, the implemented algorithm checks after every addition of a crossing point if it matches the starting crossing point, and if so, it removes this last crossing point from the list and returns the edge. In case no next edge can be found within one of the two states, the edge is considered complete and returned as well.

3.6 Other

Some other features have been implemented as well, I will list them shortly:

• An option to export the mesh to an .obj file.

• An option to export the current mesh view to an image.

• An option to export the mesh to a series of rendered slices.

• Plain subdivision. More details on this operator can be found in Section 2.3.

• An option to view individual mesh slices.

• GUI update. This consists of three parts:

– The function bar on the left has been split up into three tabs: file, tools, and stats. The first tab is used for import and export of files, the second tab contains all mesh operators and the last tab is used for analyzing the mesh, or slices of the mesh.

(19)

Figure 3.7: Updated GUI

– The mesh view on the right has been updated with new controls. Rotating and zooming can now be done with the mouse, panning with the arrow keys. Shortcut keys for standard views, switching between perspective and orthogonal view, and a reset of the view are available as well.

– The application bar at the top of the window has been extended with some mesh view options and options for quick import and export of an mesh. For all these functions, shortcut keys are available as well.

A screenshot of this new GUI is visible in Figure 3.7.

(20)

Chapter 4

Results

This chapter shows the results of individual and combined operators on different curves. Results of the single operators subdivision, Centroidal Voronoi Tessellation, Laplacian smoothing, and dual- dual are not discussed, for a discussion of these single operators I would refer the reader to the thesis of Julian Vos [7]. For each applied operator, the number of steps used is described. If T-scaling is applied, it is applied at 1.0% height.

4.1 Surface construction

Figures 4.1, 4.2 and 4.3 show the results of surface creation between a square and a square, a square and a pentagon, and a T and an S, respectively. Corresponding mesh slices are visible in Figures 4.16a, 4.17a and 4.18a. In all these situations, a minimal resolution of 0.005 is applied.

The square-square morph is exactly as one would expect it to be: a 3D cube. The square-pentagon morph shows the difference between a 3D surface approach and a point correspondence approach.

With point correspondence, the bottom two corners of the square would move inwards, the top two corners of the square would move inwards/downwards, while the upper edge would bow into two edges, thus morphing into a pentagon. With this created 3D morph, the complete edge transforms from a square to a pentagon: new corners emerge and old corners disappear.

These exact automatic surface construction morphs are used as the basis for all next tested operators.

4.2 T-scaling + Loop subdivision

Loop subdivision in combination with T-scaling is not very spectacular, the results are pretty the same as applying Loop subdivision without T-scaling, as can be seen in Figures 4.4, 4.5, 4.6, 4.16b, 4.17b and 4.18b.

4.3 T-scaling + CVT (Lloyd)

CVT is not very useful on an automatically created surface, since such a surface only consists of

(21)

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.1: Surface construction: square - square

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.2: Surface construction: square - pentagon

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.3: Surface construction: T - S

(22)

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.4: T-scaling + Loop subdivision: square - square

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.5: T-scaling + Loop subdivision: square - pentagon

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.6: T-scaling + Loop subdivision: T - S

(23)

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.7: T-scaling + CVT (Lloyd): square - square

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.8: T-scaling + CVT (Lloyd): square - pentagon

CVT can only swap edges and adjust location coordinates of non-boundary vertices, but cannot create new faces, the results are not very useful, as can be seen in Figures 4.7, 4.8, 4.9, 4.16c, 4.17c and 4.18c. In the square-square morph, the morph stays exactly the same, while on the square-pentagon and the T-S morph some ‘shortcuts’ are added to the corners.

4.4 T-scaling + Laplacian

On a fresh automatically created surface, Laplacian Smoothing is even less useful than CVT. Since Laplacian smoothing can only adjust non-boundary surface vertices, this operator does in such situations exactly nothing. For this reason, I have not included any figures.

(24)

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.9: T-scaling + CVT (Lloyd): T - S

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.10: T-scaling + plain subdivision + CVT (Lloyd): square - square

4.5 T-scaling + plain subdivision + CVT (Lloyd)

Now we are getting to the more interesting results. Figures 4.10, 4.11, 4.12, 4.16d, 4.17d and 4.18d show the results of an automatically created surface, 1% T-scaling, three times plain subdivision, and Lloyd CVT. Because of the extra triangles, CVT can now really smooth the surface.

4.6 T-scaling + plain subdivision + Laplacian

Figures 4.13, 4.14, 4.15, 4.16e, 4.17e and 4.18e show the results of an automatically created surface, 1% T-scaling, three times plain subdivision, and Laplacian smoothing. Again, T-scaling has no effect on the Laplacian smoothing. However, plain subdivision in combination with Laplacian smoothing undoes the staircasing of an automatically created surface mesh.

(25)

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.11: T-scaling + plain subdivision + CVT (Lloyd): square - pentagon

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.12: T-scaling + plain subdivision + CVT (Lloyd): T - S

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.13: T-scaling + plain subdivision + Laplacian: square - square

(26)

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.14: T-scaling + plain subdivision + Laplacian: square - pentagon

(a) 3D isometric view. (b) 3D front view. (c) 3D side view.

Figure 4.15: T-scaling + plain subdivision + Laplacian: T - S

(27)

(a) Automatic surface construction

(b) T-scaling + Loop subdivision

(c) T-scaling + CVT (Lloyd)

(d) T-scaling + plain subdivision + CVT

(e) T-scaling + plain subdivision + Laplacian Figure 4.16: Morph comparison: square - square

(28)

(a) Automatic surface construction

(b) T-scaling + Loop subdivision

(c) T-scaling + CVT (Lloyd)

(d) T-scaling + plain subdivision + CVT

(e) T-scaling + plain subdivision + Laplacian

(29)

(a) Automatic surface construction

(b) T-scaling + Loop subdivision

(c) T-scaling + CVT (Lloyd)

(d) T-scaling + plain subdivision + CVT

(e) T-scaling + plain subdivision + Laplacian Figure 4.18: Morph comparison: T - S

(30)

4.7 Discussion

Figures 4.16, 4.17 and 4.18 clearly show the differences between the various mesh operators.

Morphing from one square to another exact same square can be considered as the most basic transition. Figure 4.16 shows the differences between the various mesh operators. Automatic surface construction creates the perfect starting mesh. T-scaling + Loop subdivision does not change this transition very much, corners are slightly rounded at the source and target curve, a little more halfway through the transition. The effect is not very strong, it would be stronger if we had used a lower minimum resolution with automatic surface construction. T-scaling + CVT does not change the mesh. T-scaling + plain subdivision + CVT does change the mesh a little: halfway through the transition corners are rounded a little because of insufficient T-scaling. T-scaling + plain subdivision + Laplacian has the same effects.

The morphing from a square to a pentagon, shown in Figure 4.17 gives information about corner transitions. Automatic surface construction creates a nice, direct transition. However, all oblique lines are not straight, but a staircase pattern at high resolution. Adding T-scaling + Loop subdivision smoothes these staircases, but does not converge them to straight lines. T-scaling + CVT do not have enough triangles to undo the staircase patterns, but does add unwanted ‘shortcuts’

to the source and target curve corners. T-scaling + plain subdivision + CVT gives a nice solution:

the extra faces added by plain subdivision give CVT space for straightening of the staircase patterns.

Furthermore, corners halfway through the transition are rounded. The results of T-scaling + plain subdivision + Laplacian is comparable, but has less corner rounding.

The morphing from a T to a S, shown in Figure 4.18 gives information about more complex cases, in which corners and roundings have to morph without being lined up. Since a T has its surface area mainly located at the top of the 2D shape while the surface of S is more widely distributed, and automatic surface construction evenly distributes connecting edges, slices taken halfway through the transition have quite interesting shapes. Staircasing is visible. Adding T-scaling + Loop subdivision again smoothes sharp corners. T-scaling + CVT gives very rough results. Again corner ‘shortcuts’

are taken, but the top left corner now contains a lot of noise. T-scaling + plain subdivision + CVT results in the most smooth transition. The results of T-scaling + plain subdivision + Laplacian are a smoothed version of automatic surface creation.

In general, automatic surface construction gives a very good morph, although lines are sometimes composed of staircase patterns. Loop subdivision can smooth such a morph, plain subdivision + Laplacian even better, but both cannot make big changes. CVT can, but only given enough extra intermediate faces which can be produced by plain subdivision.

(31)

Chapter 5

Conclusion

5.1 Research question

I started this thesis with the following research question: how to achieve a smooth 2D morph by creating a 3D shape and smoothing such a shape with different operators?

The answer is as following. First, we create an initial shape in the form of a surface mesh by adding evenly distributed connecting edges between the two curves. A good initial lining up is not absolutely necessary at this point, but improves efficiency later on, so we improve this initial surface mesh by shifting the connecting vertices around such that the average lengths of the connecting edges is as short as possible. Second, we scale this mesh to an as low as possible value. In my implementation, 1% seems a good scaling point that does not lead to artifacts later on. Third, we apply CVT until convergence. To increase the resolution, we use plain subdivision. For fast computing, alternate between one step of plain subdivision and CVT until convergence. Repeat until the resolution is good enough. The morph can now be exported as a 3D mesh, or as a series of slices.

5.2 Future work

In my work, I have focused on creating an optimal shape representing a smooth morph between a source and a target curve. I have achieved this goal, but there is still room for further improvement.

The work described in this thesis focused on the 3D shape representation of the morph. Not much work has been spent on analyzing and possibly improving individual slices of the mesh. This might be the topic of a different bachelor thesis.

Another interesting topic to dive into would be higher-order morphs. The current framework uses 3D meshes for 2D morphs, but the program could be extended to more dimensions, for example 4D meshes for 3D morphs. Such higher order morphs would require a new way of displaying the mesh, and a lot of code to be rewritten, especially the CVT implementation.

The current code requires the user to apply all operators manually. An improvement to the program might be an automatic application of different operators, using the algorithm described in the conclusion of this thesis.

The current code applies different operators as-is. Adding pre-processing and post-processing

(32)

options to the different operators gives room for improvement on several levels. On possible manner would be a scalar option, which would scale a mesh slicewise in such a way that the surface of every slice would be linear between the source curve and the target curve. By combining this option with an operator, we could get a perfect converging of CVT, while at the same time having a linear change in slice surface area.

Some of the algorithms are not very efficiently implemented, rewriting these might give large processing improvements. I’m looking at you, CVT!

(33)

List of Figures

1.1 Source and target curves. . . 3

1.2 A 2D morph visualized as a 3D shape. [9] . . . 3

2.1 Open versus closed meshes. [9] . . . 5

2.2 Illustration of CVT convergence in 2D. [7] . . . 5

2.3 Icosahedron with two steps of Loop subdivision applied. [4] . . . 6

2.4 Minimal surface between two squares at different distances . . . 7

3.1 Starting point GUI. [7] . . . 9

3.2 Illustration of the half-edge relations. [5] . . . 10

3.3 Half-edge UML collaboration diagram. [8] . . . 10

3.4 Surface creation. . . 12

3.5 Lining up connecting edges. . . 14

3.6 Slicing algorithm FSM . . . 16

3.7 Updated GUI . . . 17

4.1 Surface construction: square - square . . . 19

4.2 Surface construction: square - pentagon . . . 19

4.3 Surface construction: T - S . . . 19

4.4 T-scaling + Loop subdivision: square - square . . . 20

4.5 T-scaling + Loop subdivision: square - pentagon . . . 20

4.6 T-scaling + Loop subdivision: T - S . . . 20

4.7 T-scaling + CVT (Lloyd): square - square . . . 21

4.8 T-scaling + CVT (Lloyd): square - pentagon . . . 21

4.9 T-scaling + CVT (Lloyd): T - S . . . 22

4.10 T-scaling + plain subdivision + CVT (Lloyd): square - square . . . 22

4.11 T-scaling + plain subdivision + CVT (Lloyd): square - pentagon . . . 23

4.12 T-scaling + plain subdivision + CVT (Lloyd): T - S . . . 23

4.13 T-scaling + plain subdivision + Laplacian: square - square . . . 23

4.14 T-scaling + plain subdivision + Laplacian: square - pentagon . . . 24

4.15 T-scaling + plain subdivision + Laplacian: T - S . . . 24

4.16 Morph comparison: square - square . . . 25

4.17 Morph comparison: square - pentagon . . . 26

4.18 Morph comparison: T - S . . . 27

(34)

References

[1] S. Lloyd. “Least squares quantization in PCM”. In: IEEE Transactions on Information Theory 28.2 (Mar. 1982), pp. 129–137. issn: 0018-9448. doi: 10.1109/TIT.1982.1056489.

[2] Charles Loop. “Smooth Subdivision Surfaces Based on Triangles”. University of Utah, 1987.

[3] Dong C. Liu and Jorge Nocedal. “On the limited memory BFGS method for large scale optimization”. In: Mathematical Programming 45.1 (1989), pp. 503–528. issn: 1436-4646.

doi: 10.1007/BF01589116. url: http://dx.doi.org/10.1007/BF01589116.

[4] SimonFuhrmann. Loop Subdivision Icosahedron.svg. Aug. 2009. url: https : / / commons . wikimedia.org/wiki/File:Loop_Subdivision_Icosahedron.svg.

[5] Accountalive. Dcel-halfedge-connectivity.svg. May 2011. url: https://commons.wikimedia.

org/wiki/File:Dcel-halfedge-connectivity.svg.

[6] Hao Pan et al. “Robust Modeling of Constant Mean Curvature Surfaces”. In: ACM Trans.

Graph 31.4 (July 2012), 85:1–85:11. issn: 0730-0301. doi: 10.1145/2185520.2185581. url:

http://doi.acm.org/10.1145/2185520.2185581.

[7] Julian Vos. “Minimal Surfaces from Triangular Meshes”. Automatically Converging to Smooth Versions of Triangular Meshes. University of Groningen, July 2016. url: http://irs.ub.

rug.nl/dbi/57837a58e9d57.

[8] Doxygen. url: https://github.com/doxygen/doxygen.

[9] Onshape. url: https://www.onshape.com.

[10] QT. url: https://www.qt.io.

Referenties

GERELATEERDE DOCUMENTEN

Also all primes p ≤ 19 occur as the order of a torsion point of some elliptic curve over a number field of degree at most 5.. Table 3.2 also contains the results obtained using the

The implementation does this by determining the area and total positive curvature of slice curves, calculating the non-overlapping area of slices taken from the subdivided mesh and

Rational curves also allow to draw exact conics like ellipses, circles, parabolas and

Adding a point p E conv(P) to the set of weighted points P will not change the skin curve, because that point would already be generated by the convex hull.. The same holds for

This chapter also presents related work by Bernstein and Lange on inverted Edwards curves and completed Edwards curves [BL07c, BL10] as well as Hisil et al.’s extended formulas and

Maar nieuwe spullen voor klas drie betekent dat je eerst een beeld moet hebben van de grote lijnen.. Maar grote lijnen kun je niet aangegeven als je geen duidelijke

An additional tin layer presents the possibility of an inter- stitial state, as an H atom can occupy the subsurface sites between the atoms of the first and second layers of

Deze ovalen structuur kan naast de nu nog zichtbare wal ook bestaan uit de buitenste gracht die aangetroffen werd in het archeologisch onderzoek (spoor 1.4).. Figuur