• Keine Ergebnisse gefunden

A Measuring the Shape Error by Fourier Transformation

A shape similarity function compares the new shape of a polygon with its original one. Beside measuring the shape error by summing up angle differences of the input and output mesh (see chapter 4), we can also use a more general Fourier transformation based approach. The advantage here is we do not need a graph isomorphism between the two meshes. Defining a useful shape similarity function is in itself a difficult problem, since the similarity measure should be translation-invariant, scale-invariant, and at least partially rotation-invariant. From CAD research it is known that the Euclidean distance in Fourier space is useful for measuring shape similarity [67, 8]. To gain invariance against translation, rotation, and scaling, we use the Fourier transformation of the differential geometric curvature of the polygons, instead of the polygons themselves, and normalize the arc length of the polygons to 2π. Using the curvature guarantees translation- and rotation-invariance, and normalizing the arc length guarantees scale-invariance.

In the following, we assume that the polygons are transformed into a normalized parameterized polygon contour function p :[0,2π]→R2. Then, we can define the curvature C of the polygons as

C :(R→R2)−→(R→R2). (A.1)

The Fourier transformation F is a transformation

F :(R→R2)−→Rd, (A.2)

determining the Fourier coefficients for a given curvature function in d-dimensional Fourier space. The shape similarity of two polygons p and p can then be defined as

d˜S(S(p),S(p)) =dEuclid(F(C(p)),F(C(p))). (A.3) In the following, we describe the curvature transformation C and the Fourier transformation F in more detail.

Determining the Curvature of a Polygon

In general, the curvature of a polygon defined as a parameterized function is mathematically undefined because the second derivative is not continuous. We can avoid this problem by approximating the polygon by replacing each vertex with very small circular arcs as shown in Figure A.1. This yields a new geometric object of which the first derivative is continuous. The curvature of this structure is defined in sections;

concatenating these sections we obtain the curvature as a square wave function.

To describe the curvature transformation in more detail, let us focus on two subsequent edges ei−1and ei. These edges coincide in vertex vi with an angle αi. For the polygon containing vi, we may easily compute the curvature function ci(t), describing the differential geometric curvature of the approximated polygon because the curvature of a circle segment with radius r is a constant function 1r and the curvature of a straight line is a constant zero function. We may calculate the arc length of the circle segment substituting vertex viby bi=|αi| ·r. For ci(t), we therefore obtain

ci(t) = (1

r if(tvibi/2 > t > tvi+bi/2)

0 otherwise (A.4)

(a) Original polygon (b) Approximated polygon (c) Curvature

Figure A.1: Approximation of a polygon

(a) Two polygons (b) Curvature of the two polygons

Figure A.2: Curvature transformation

The curvature of an arbitrary polygon p is c(t) =|p|−1k=0 ck(t). Figure A.1c shows the graph of the curvature function c(t)for the approximation of the polygon section in figure A.1a. Figure A.2 shows the curvature functions for two polygons which are identical under translation-invariance, rotation-invariance, and scale-invariance.

The approximation of the original polygon, and in particular the choice of r, influences the curvature function. If we reduce the radius r of the circle segment, 1r will be increased while bi will be decreased.

This causes c(t) to become more narrow and the amplitude of square waves to become higher, while the approximation of the polygon converges against the polygon itself. On the other hand, c(t)becomes difficult to handle numerically. An adequate value for r which has proven useful for our application is 50π for polygons with a normalized length of 2π. As our experiments show, the similarity function is quite robust against a suboptimal choice of r, as long as r is smaller than half of the length of the shortest edge since otherwise individual square wave functions may overlap.

Fourier Transformation

The next step is computing the Fourier transformation F of the curvature. The principle of the Fourier transformation is to approximate a function by summing up sine and cosine functions with certain pa-rameters. The quality of the approximation is improved by increasing the degree d of the Fourier ap-proximation, which means to successively sum up cos(x),sin(x),cos(2x),sin(2x), ...,cos(x),sin(x). More formally, the Fourier approximation of a function f with a period of 2πis defined as

F(x) =a0 2

n k=1

(akcos(kx) +bksin(kx)) (A.5)

where the coefficients ak and bk are defined as ak = 1

π Z 2π

0

f(x)cos(kx)dx and (A.6)

bk = 1 π

Z 2π 0

f(x)sin(kx)dx (A.7)

In general, integrals of the form R f(x)sin(x)dx are difficult to solve analytically. For the special case where f(x)is a square wave function, however, the integral can be easily determined. Let us assume that

f(x) has a value of 1r in the interval [u,v] and is zero elsewhere. Since the value of the integral is zero outside of[u,v], we just have to integrate from u to v. Therefore, we are able to calculate akand bkas:

ak = 1

πkr(sin(kv)−sin(ku)) and (A.8)

bk = 1

πkr(cos(kv)−cos(ku)) (A.9)

To determine the Fourier coefficients of the curvature function c(t)of the whole polygon p, we only have to sum up the above formula ci(t)for all vertices viof the polygon. We obtain the following formulas for the Fourier coefficients:

ak = 1 πkr

|p|−1 i=0

αi

i|

sin

k·

ti+|αir|

2

−sin

k·

ti−|αir|

2

(A.10) bk = − 1

πkr

|p|−1 i=0

αi

i|

cos

k·

ti+|αir|

2

−cos

k·

ti−|αir|

2

(A.11) The calculation of ak and bk can be done in O(|p|)time, and the calculation of all coefficients can be done in O(|p| ·d), where d is the degree of the Fourier sum. Note that we are able to compute the coef-ficients of the Fourier sum analytically, and therefore do not run into numerical problems such as finding the right sample rate. Experimental results show that the Fourier transformation provides a good approx-imation of the polygons and their curvature function even for rather small d. For a detailed discussion of Fourier theory see [133].