1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote...

13
1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote Kurvenapproximation SWP Anwendungen von Algorithmen Team 3 Team 3: Stefan Behrendt, Ralf Öchsner, Ying Wei

Transcript of 1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote...

Page 1: 1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote Kurvenapproximation SWP Anwendungen von AlgorithmenTeam.

1

Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013

Prof. Dr. Günter Rote

Kurvenapproximation

SWP Anwendungen von Algorithmen Team 3

Team 3: Stefan Behrendt, Ralf Öchsner, Ying Wei

Page 2: 1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote Kurvenapproximation SWP Anwendungen von AlgorithmenTeam.

2SWP Anwendungen von Algorithmen Team 3

Our task

Technique

• Technologies

• Flow of process

Preparations for Greedy approach

Greedy approach

Analysis

Demo

….

Outline

Page 3: 1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote Kurvenapproximation SWP Anwendungen von AlgorithmenTeam.

3SWP Anwendungen von Algorithmen Team 3

Our task

Approximation of point sequences by spline

Input : The points with an order A predefined tolerance error

Output : A Curve, which goes through the selected points from original given points and can sufficiently good approximate the original point sequence

Page 4: 1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote Kurvenapproximation SWP Anwendungen von AlgorithmenTeam.

4

Technologies :

C++, Lua, IPE

QT

Cubic Hermite spline, Cubic Bezier spline, Interpolation

Greedy Algorithm

SWP Anwendungen von Algorithmen Team 3

Technique

Page 5: 1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote Kurvenapproximation SWP Anwendungen von AlgorithmenTeam.

5

Technique

SWP Anwendungen von Algorithmen Team 3

Flow of process

Calculate all Tangents of original given Points

1) Convert Selected Hermite Points & Tangents to Bezier control points

2) Then draw curve again by Bezier cubic spline

1) Convert given points and computed Tangents to Bezier control points in order to prepare with Greedy

2) Select points & Tangents using Greedy

1) Convert given points and computed Tangents to Bezier control points in order to prepare with Greedy

2) Select points & Tangents using Greedy

Add spline into IPE for display

Page 6: 1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote Kurvenapproximation SWP Anwendungen von AlgorithmenTeam.

6SWP Anwendungen von Algorithmen Team 3

Tangents Calculation

i is index of given points (points[i]), n is the size of given points

for (i=0; i <n; i++) if (i==0) thenelse if (i==n-1) thenelseend if

T(n)=n

Page 7: 1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote Kurvenapproximation SWP Anwendungen von AlgorithmenTeam.

7SWP Anwendungen von Algorithmen Team 3

Preparations for Greedy Approach

n=size of given points; T(n)=nis defined as maximal error from beginning to the current position :

m=size of cPoints; T(n)=n, , is defined as minimal distance between points[i] and cubic Bezier interpolating points:

, where

: cubic Bezier Curve. T(n)=1Let , interpolating could be realized.

Page 8: 1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote Kurvenapproximation SWP Anwendungen von AlgorithmenTeam.

8SWP Anwendungen von Algorithmen Team 3

Greedy Approach

1). Add points[0] and its tangent into hermitePoint[0] and tangents[0]

2). for (i=1 to (size of given points -1), i++)

2.1) Add points[i] and its tangent into hermitePoint[i] and tangents[i]

2.2) Convert hermite points and tangents to cubic Bezier control points i=0;

for(j=1 to (size of hermitePoints -1), j++)

i++;

Page 9: 1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote Kurvenapproximation SWP Anwendungen von AlgorithmenTeam.

9SWP Anwendungen von Algorithmen Team 3

Greedy Approach2.3) select points and tangents2.3.1) if the error in the position i ≤ tolerance error ε , and i isn’t end position

( errorUntil(i) < maxError && i != (size of points -1) )

then a.) Adjust the length of tangent

, where

b.) Remove this point from hermitePoints[end];

Remove its tangents from tangents[end];

Page 10: 1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote Kurvenapproximation SWP Anwendungen von AlgorithmenTeam.

10

2.3.2) else if at the end, and the error >maxError

(i==(size of points-1) && (errorUntil(i)>Error)) then insert points[i-1] into hermite[end-1];

insert tangent[i-1] into tangents[end-1];2.3.3) else (when the error > maxError),

insert points[i-1] into hermitePoints[end-1];insert tangent[i-1] into tangents[end-1];

3) Convert the selected hermitePoints to cPoints again. Method is the same with 2.2) T(n)=n

4) add bezier spline to IPE

Greedy Approach

SWP Anwendungen von Algorithmen Team 3

Page 11: 1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote Kurvenapproximation SWP Anwendungen von AlgorithmenTeam.

11SWP Anwendungen von Algorithmen Team 3

Analysis Runtime:

n is the size of inputs• Tangents Calculation : O(n)• Greedy approach : O(n*n)• Convert selected hermitePoints to cPoints : O(n)

Memory requirements := In worse case, memory requirements :=

Page 12: 1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote Kurvenapproximation SWP Anwendungen von AlgorithmenTeam.

12SWP Anwendungen von Algorithmen Team 3

Demo

DEMO…

Page 13: 1 Softwareprojekt über Anwendungen effizienter Algorithmen, WS 2012/2013 Prof. Dr. Günter Rote Kurvenapproximation SWP Anwendungen von AlgorithmenTeam.

13

Thanks For Attention!

Questions and Suggestions for improvement?

SWP Anwendungen von Algorithmen Team 3