Top Banner
Interpolation of Two-Dimensional Curves with Euler Spirals Dale Connor and Lilia Krivodonova University of Waterloo Waterloo, Ontario, Canada Abstract We propose an algorithm for interpolation of two-dimensional curves using Euler spirals. The method uses a lower order reconstruction to approximate solution derivatives at each sample point. The computed tangents are then used to connect consecutive points with segments of Euler spirals. The resulting interpolation is G 1 in regions where the curve being interpolated is smooth. The algorithm uses an adaptive stencil which allows it to construct an approximation free of oscillations near discontinuities in the function or its derivatives. The approximation is based on geometrical shapes which makes it particularly suitable for two-dimensional curves. 1 Introduction We propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented by a one-to-one function y (x), with Euler spirals. The main features of the algorithm are independence of a coordinate system, local character of approximation, and smoothness of the resulting interpolant. Given an ordered set of points (x i ,y i ), the algorithm connects pairs of neighboring points with Euler spirals. The interpolant is G 1 with the exception of points where the algorithm selectively places a discontinuity in the tangent. The Euler spiral is a curve with curvature changing linearly with the arclength. Planar spirals have attractive properties such as monotone curvature and absence of singulari- ties. They are used as approximations as well as transitions between circular and linear segments in a variety of applications. Euler spirals are traditionally employed in high- way and railway route design [3]. And more recently, in path generation for high speed machinery [22] and image completion in computer graphics [11]. Generalized spirals are also used in robotics for generation of optimal trajectories [10] and as a G 2 transition curve in fair path planning [6, 7]. 1
21

Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

Mar 11, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

Interpolation of Two-Dimensional Curves with Euler

Spirals

Dale Connor and Lilia KrivodonovaUniversity of Waterloo

Waterloo, Ontario, Canada

Abstract

We propose an algorithm for interpolation of two-dimensional curves using Euler

spirals. The method uses a lower order reconstruction to approximate solution

derivatives at each sample point. The computed tangents are then used to connect

consecutive points with segments of Euler spirals. The resulting interpolation is

G1 in regions where the curve being interpolated is smooth. The algorithm uses an

adaptive stencil which allows it to construct an approximation free of oscillations

near discontinuities in the function or its derivatives. The approximation is based

on geometrical shapes which makes it particularly suitable for two-dimensional

curves.

1 Introduction

We propose an algorithm for interpolation of two-dimensional curves, i.e., curves thatcannot be represented by a one-to-one function y(x), with Euler spirals. The mainfeatures of the algorithm are independence of a coordinate system, local character ofapproximation, and smoothness of the resulting interpolant. Given an ordered set ofpoints (xi, yi), the algorithm connects pairs of neighboring points with Euler spirals. Theinterpolant is G1 with the exception of points where the algorithm selectively places adiscontinuity in the tangent.

The Euler spiral is a curve with curvature changing linearly with the arclength. Planarspirals have attractive properties such as monotone curvature and absence of singulari-ties. They are used as approximations as well as transitions between circular and linearsegments in a variety of applications. Euler spirals are traditionally employed in high-way and railway route design [3]. And more recently, in path generation for high speedmachinery [22] and image completion in computer graphics [11]. Generalized spirals arealso used in robotics for generation of optimal trajectories [10] and as a G2 transitioncurve in fair path planning [6, 7].

1

Page 2: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

The motivation for this research came from previous work of one of the authors onimplementation of high-order accurate boundary conditions for compressible flows incomplex geometries [12]. The standard method of imposing boundary conditions at solidwalls is to require that no flow passes through the numerical boundary. The numericalboundary is comprised of edges of a triangular or quadrilateral mesh such as, for exam-ple, a mesh around a NACA0012 airfoil in fig. 1. The curved surface of the airfoil isimperfectly approximated by the straight edges of the triangular mesh. This results in alarge error committed near the surface which then propagates through the domain (fig.2, left). It was shown that higher order finite element methods such as the discontin-uous Galerkin method are significantly affected by this boundary effect. Krivodonovaet al [12] proposed to use curved boundary conditions which resulted in no flow passingthrough the physical boundary. This was done by incorporating normals to the physicalwall into the computation of the flux on the numerical boundary. The normals can beobtained by reconstructing the physical surface from the edges forming the numericalboundary. Approximating the physical boundary on each edge with circular arcs andusing normals to these arcs as an approximation to the true physical normals resulted ina great improvement in computations as compared with the traditional implementationof boundary conditions (fig. 2).

We propose to use Euler spirals to obtain a more accurate reconstruction of normalsto the two-dimensional boundary. The new reconstruction is more accurate than an inter-polation using circular arcs and is G1 in smooth regions. Thus, the normal to the surfaceis a continuous function which can be an important factor in aerodynamical simulations.Furthermore, the normal and curvature of the interpolating curve can be easily obtainedat any point. Non-lagrangian approximation of curved boundaries has been used in fi-nite element codes. For example, approximation with splines [5] or NURBS [17, 16] forused in simulation of Navier-Stokes or Euler equation. However, this approach assumesavailability of high-order meshes incorporating cells with curved sides and introduces itsown difficulties such as numerical integration on curved mesh cells. We note that our ap-proach is different as we assume that high-order accuracy approximation is not availableand instead seek to locally reconstruct a more accurate normal to the true geometry ona straight-sided mesh.

The idea of approximating two-dimensional curves with circular arcs was also pro-posed in [18] by Siddiqi et al. The stencil for constructing an interpolant between pointsPi−1 and Pi was chosen adaptively with the third point needed to create a circle chosenfrom Pi−2 and Pi+1. The circle used in interpolation was the one with the smallest cur-vature. This idea is similar to the adaptive stencil of essentially non-oscillatory (ENO)schemes [8] used in numerical solution of partial differential equations and the resultingmethod was named the geometrical essentially non-oscillatory scheme (GENO). Siddiqiet al suggested that Euler spirals could be used for constructing a higher order GENOinterpolation. This would seem to be a natural choice as Euler spirals can be thoughtof as the next geometrical shape function. The simplest geometric shape is a curve withzero curvature, i.e., a line. It is followed by a curve with a constant curvature, a circle.

2

Page 3: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

An Euler spiral would be the next shape since its curvature changes linearly with thearclength. However, this idea is difficult to implement as there seems to be no existingalgorithm for passing an Euler spiral through four ordered points.

Figure 1: Mesh around NACA0012.

The proposed algorithm takes a hierarchical approach to interpolation. First, wepass three circles through each sample point, Pi, using the stencils: {Pi−2, Pi−1, Pi},{Pi−1, Pi, Pi+1}, {Pi, Pi+1, Pi+2}. The circle with the smallest curvature is taken as alow order approximation at point Pi. Then, the interpolation between points Pi−1 andPi is computed by finding an Euler spiral passing through these points such that thetangents to the spiral coincide with the tangents to the local circular approximations atPi−1 and Pi. Since the tangent at Pi is shared by segments (Pi−1, Pi) and (Pi, Pi+1), theinterpolation is G1. The spiral is constructed using an algorithm of Meek and Walton[20, 13].

Euler spirals were previously used for shape completion by Kimia et al [11], wherethe missing part of a shape was reconstructed using the slopes at the end points of themissing interval. They also argued that “the most pleasing curve” is the curve with thesmallest change in curvature and not with the minimal curvature. It was demonstratedthat an Euler spiral is a curve that satisfies the above requirement. This is in contrastwith the GENO approach which chooses the flattest curve. Our algorithm combinesthe ideas expressed in [18] and [11] by first looking for the stencil giving the smoothestapproximation and then using “the most pleasing” reconstruction in that region. Anotherinterpolation method based on Euler spirals was proposed by Stoer [19]. The interpolantis in G2 but the method requires solving a global system of equations and would not besuitable for function with discontinuities in first derivatives.

The proposed algorithm is able to construct accurate approximations of functionswith discontinuities, that is, functions with jumps in the solution or its derivatives. Theinterpolant on the interval (Pi−1, Pi) uses information from one to four additional nearbypoints and chooses the stencil which forms the local approximation with lowest curvature.

3

Page 4: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

This process prevents segments containing discontinuities from affecting neighboring in-tervals and stops oscillations from propagating through the domain. In addition to thechoice of points involved, the size of the stencil also changes adaptively. When a shock,that is a discontinuity in the function or its derivative, is present and needs to be re-solved, we allow the two interpolants meeting at Pi to have different tangents. Themethod determines at which sample points placing a shock is appropriate. This allowsus to accurately resolve sharp corners such as the tail of an airfoil (fig. 1). The smallstencil and local interpolation element by element is also convenient for reconstructionof the physical boundary from a computational mesh since a global reconstruction maybe difficult to use with the data structures in finite element codes.

An additional advantage of using geometrical shapes as interpolants is their inde-pendence of a coordinate system. Cubic splines are a popular choice for interpolation,however, finding a good parametrization for a polynomial interpolation may be difficult.A bad choice may lead to oscillatory behavior even for relatively smooth functions. Thearclength can serve as a good parameter but it is not known prior to the interpolation.Using standard interpolation techniques in a local rotated coordinate system may notbe robust for curves which change direction rapidly as it might be difficult to find acoordinate system where the curve is one to one. In addition, when a curve has a sharpcorner, fixed-stencil polynomial interpolation techniques produce oscillations [4].

Figure 2: Mach isolines for a simulation of subsonic flow around a circular cylinderwith reflective (left) and curvature (right) boundary conditions. The reflective boundaryconditions result in a large unphysical wake at the back of the cylinder.

The paper is organized as follows. We begin by explaining the basic properties of anEuler spiral in Section 2. In Section 3, we summarize the algorithm for fitting spiralsproposed by Walton and Meek in [20]. In Section 4, we introduce our interpolationmethod. Lastly, a number of numerical experiments are presented in Section 5.

2 Introduction to Spirals

An Euler spiral, also known as a Cornu spiral or a clothoid, is a two-dimensional curvewith a curvature that changes linearly as a function of arclength. A canonical Euler

4

Page 5: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

spiral is described by the following parameterized form(

x(α)y(α)

)

=

(

C̄(α)S̄(α)

)

, (1)

where C̄(α) and S̄(α) are given by

C̄(α) =1√2π

∫ α

0

cos(u)√u

du, S̄(α) =1√2π

∫ α

0

sin(u)√u

du, (2)

for α > 0. For negative values of α, we take C̄(α) = −C̄(−α) and likewise for S̄. In theseequations, |α| is the angle between the tangent and the positive x-axis. The expressions(2) were derived from the cosine and sine Fresnel integrals

C(t) =

∫ t

0

cos

(

πu2

2

)

du, S(t) =

∫ t

0

sin

(

πu2

2

)

du (3)

using a change of variable α = ±πt2

2.

By construction, positive values of parameters t and α correspond to the right half ofthe spiral, the negative values to the left half, and t = 0 and α = 0 to the origin (fig. 3).The expressions (2) and (3) are related by

C̄(πt2

2) = C(t), S̄(

πt2

2) = S(t). (4)

It follows from (3) that the arclength between a point (x(t), y(t)) = (C(t), S(t)) and the

π

0

22π

−π

−3π

2

−π2

−2π

Figure 3: An Euler Spiral as defined by (1) with α values labeled.

origin is equal to |t|. Differentiating (1) with respect to α (α > 0) yields(

x′(α)y′(α)

)

=1√2πα

(

cos(α)sin(α)

)

. (5)

5

Page 6: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

This demonstrates that α is the angle formed by the tangent to the curve at point(C̄(α), S̄(α)) with the x-axis. The angle is measured in the counter-clockwise directionfrom the axis to the tangent vector. In terms of parametrization (3), the angle at point(C(t), S(t)) is given by πt2/2.

The canonical Euler spiral can be scaled by a factor a, rotated by an angle ψ andtranslated to a point (x0, y0). Thus, an arbitrary Euler spiral can be described as

(

x(α)y(α)

)

= a

(

cos(ψ)sin(ψ)

− sin(ψ)cos(ψ)

) (

C̄(α)S̄(α)

)

+

(

x0

y0

)

. (6)

Or, equivalently,P̄ (α) = P̄0 + aC̄(α)~T0 + aS̄(α) ~N0, (7)

where ~T0 = (cosψ, sinψ)T and ~N0 = (− sinψ, cosψ)T are the unit tangent and normalvectors to the spiral at P0. This can be rewritten in terms of parameter t as:

P̄ (t) = P̄0 + aC(t)~T0 + aS(t) ~N0. (8)

The center of the spiral corresponds to t = 0 and is located at P0 = (x0, y0). At thecenter, the curvature is equal to zero and ψ is the angle between the tangent vector andthe x-axis (fig. 5). The length of the curve from P0 to point (x(t), y(t)) is equal toa|t|. From geometrical considerations, the angle from the positive x-axis to the tangentat point (x(t), y(t)) is equal to the sum of the angle of rotation and α, i.e. ψ + πt2/2.Differentiating this with respect to arclength, we obtain the curvature κ

κ =πt

a. (9)

This demonstrates that the curvature of an Euler spiral at a point is indeed proportionalto the arclength from P0. For positive t, curvature is positive and the spiral is rotatingcounterclockwise as t increases; for negative t, curvature is negative and the spiral isrotating clockwise as t increases.

3 Algorithm for Finding a Spiral

Any two given points P1 and P2 with associated tangent vectors ~T1 and ~T2 can be con-nected by an Euler spiral such that the tangent vector of the spiral matches the prescribedtangents at both points (fig. 4). In fact, there exists a countable number of Euler spiralssatisfying the above conditions [11]. We are interested in the spiral with the shortestarclength that will interpolate the data without completing a full coil. Kimia et al [11]proposed an algorithm for finding such a spiral. Later, Walton and Meek [21, 20] pro-posed a different solution to this problem which we used in our implementation. Herewe briefly summarize the implementation of their algorithm for use in our problem. Thealgorithm constructs an Euler spiral to solve the interpolation problem using the centralregion characterized by α ∈ [−π, 2π].

6

Page 7: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

P1

P2

~T1

~T2

Figure 4: Two point G1 Hermite data.

ψ

ψ

φ1

φ1

φ2

φ2

θθ P0

P0

P1

P1

P2

P2

~T1

~T1

~T2

~T2

~T0

~T0

~D

~D

Figure 5: A C-shaped segment with completion extended back to P0 (left) and an S-shaped segment (right). The spiral completions are shown as dashed lines.

First, we check if the data can be connected with a straight line or a circle. These canbe thought of as degenerate cases of Euler spirals. Otherwise, the following is applied.We distinguish between two cases, an S-shaped segment and a C-shaped segment. AnS-shaped segment contains the inflection point P0 (fig. 5, right). A C-shaped segment is

located entirely on one side of P0 (fig. 5, left). Let ~D be the vector from starting point

P1 to end point P2. Denote by φ1 the angle from the tangent ~T1 to ~D and by φ2 theangle from ~D to the tangent ~T2, both measured counter-clockwise.

The algorithm assumes that φ1 and φ2 satisfy the following two conditions:

1. |φ2| ≥ |φ1|

2. 0 ≤ φ2 ≤ π.

If these are not met, the problem is adjusted to satisfy them. If the first condition isviolated, the spiral needs to be constructed in the opposite direction, from P2 to P1. To

7

Page 8: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

remain consistent with the original data, we need to set φ1 = −φ2 and φ2 = −φ1. If thesecond condition is not met, the data needs to be reflected over ~D. This is achieved bysetting φ1 = −φ1 and φ2 = −φ2. The spiral obtained by the algorithm will need to bereflected back over ~D for it to satisfy the initial data.

To construct a spiral described by (7), the values of P0, a, ~T0, and ~N0 need to bedetermined. In addition, values of parameter α corresponding to points P1 and P2 mustbe found.

First, we determine the type of interpolating segment. A C-shaped solution existsonly when two conditions are met: 0 < φ1 < φ2 < π and h(φ1, φ2) < 0, where

h(φ1, φ2) = S(φ1 + φ2) cos(φ1) − C(φ1 + φ2) sin(φ1). (10)

If h(φ1, φ2) > 0 or φ1 < 0 the solution will be an S-shaped segment.

3.1 C-Shaped Segments

We start by computing the value of θ, the angle between ~T0 and ~T1, the tangent vectorsat points P0 and P1, respectively. The sought θ is the solution of

f(θ) = 0 (11)

in the interval [0, θMAX ], where

f(θ) = (S̄(θ + φ1 + φ2) − S̄(θ)) cos(θ + φ1) − (C̄(θ + φ1 + φ2) − C̄(θ)) sin(θ + φ1), (12)

θMAX =λ2(φ1 + φ2)

1 − λ2, (13)

and

λ =1 − cos(φ1)

1 − cos(φ2). (14)

The equation (11) can be solved using Newton’s method combined with bracketing.Having obtained θ, we compute a as

a =|| ~D||2

[

S̄(θ + φ1 + φ2) − S̄(θ)]

sin(θ + φ1) +[

C̄(θ + φ1 + φ2) − C̄(θ)]

cos(θ + φ1), (15)

where || ~D||2 is the length of ~D. ~T0 can be calculated by rotating the vector ~D by an

angle θ + φ1 clockwise, ~N0 is obtained by rotating ~T0 by π/2, also clockwise:

~T0 =

(

cos(θ + φ1)− sin(θ + φ1)

sin(θ + φ1)cos(θ + φ1)

) ~D

|| ~D||, ~N0 =

(

0−1

10

)

~T0. (16)

If the spiral needs to be reflected back over ~D, we reflect ~T0 and ~N0 over ~D:

~T0 =

(

cos(−θ − φ1)− sin(−θ − φ1)

sin(−θ − φ1)cos(−θ − φ1)

) ~D

|| ~D||, ~N0 =

(

01

−10

)

~T0. (17)

P0 can be calculated from (7) by using the substitution P (θ) = P1. The interpolationbetween points P1 and P2 is now given by the segment of the spiral with α ∈ [θ, θ+φ1+φ2].

8

Page 9: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

3.2 S-Shaped Segments

With an S-shaped solution, the points P1 and P2 will be on opposite sides of the centralpoint, P0. We choose P1 to correspond to a negative value of α, and P2 to a positive one.Similarly to the previous section, we first compute the value of θ as a solution of

g(θ) = 0, (18)

where

g(θ) = (S̄(θ + φ1 + φ2) + S̄(θ)) cos(θ + φ1) − (C̄(θ + φ1 + φ2) + C̄(θ)) sin(θ + φ1). (19)

If φ1 > 0, we choose the zero of (18) in the interval [0, π/2−φ1]; otherwise, in the interval[−φ1, π/2 − φ1]. We obtain a from

a =|| ~D||2

(S̄(θ + φ1 + φ2) + S̄(θ)) sin(θ + φ1) + (C̄(θ + φ1 + φ2) + C̄(θ)) cos(θ + φ1). (20)

Next, the vectors ~T0 and ~N0 are calculated by rotating ~D by θ+ φ1 using (16) and (17).P0 is calculated from (7) using the substitution P (−θ) = P1. The interpolating segmentof the spiral is now defined by (7) with α ∈ [−θ, θ + φ1 + φ2].

3.3 Evaluation of Fresnel Integrals

Fresnel integrals used in the description of Euler spirals need to be evaluated numerically.Integration of the Taylor series expansions of sine and cosine give [1, 15]

C(t) =

∞∑

n=0

(−1)n(π2)2n

(2n)!(4n+ 1)t4n+1, S(t) =

∞∑

n=0

(−1)n(π2)2n+1

(2n+ 1)!(4n+ 3)t4n+3. (21)

These series (21) converge quickly for small t. We observe that the algorithm of Section3 only utilizes angles between −π and 2π. Since the angle is equal to πt2/2, this isequivalent to t values between −

√2 and 2. Calculations can be sped up for small t by

precomputing the coefficients in front of t4n+1 and t4n+3

cn =(−1)n(π

2)2n

(2n)!(4n+ 1), sn =

(−1)n(π2)2n+1

(2n+ 1)!(4n+ 3). (22)

These are given by

~c = (1,−2.46E − 01, 2.82E − 02,−1.60E − 03, 5.41E − 05,−1.20E − 06,

1.88E − 08,−2.20E − 10, 1.99E − 12,−1.43E − 14, 8.38E − 17) (23)

and

~s = (5.24E − 01,−9.23E − 02, 7.24E − 03,−3.12E − 04, 8.44E − 06,−1.56E − 07,

2.11E − 09,−2.16E − 11, 1.73E − 13,−1.12E − 15, 5.98E − 18).(24)

9

Page 10: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

In this case, computing of the integrals becomes a vector by vector multiplication withthe error bound given by the next term in the series for t < 1. For a large t, care mustbe taken to avoid cancelation errors.

An alternate method for evaluating Fresnel integrals using rational approximation ispresented in [9].

4 Approximation of Tangent Vectors

We describe an algorithm for interpolation of two-dimensional curves with Euler spirals.Let us assume that we are given an ordered set of sample points Pi = (xi, yi), i =1, 2, . . . , N . In order to apply the algorithm of Section 3, additional data is needed, i.e.,a tangent vector at each sample point. These are obtained from a local lower orderapproximation of the curve by circles.

We define the tangent ~Ti at Pi as the tangent to a circle passing through Pi andtwo nearby points. We consider three stencils: {Pi−2, Pi−1, Pi}, {Pi−1, Pi, Pi+1}, and{Pi, Pi+1, Pi+2} and choose the stencil corresponding to the circle with the smallest cur-vature, or equivalently, the largest radius (fig. 6). Thus, the stencil is chosen adaptivelyto select a well-behaved local approximation for the data and resists influence from pointswhich could cause undesirable oscillations. For example, in fig. 6 the stencil correspond-ing to {P3, P4, P5} would lead to creation of spurious oscillations between points P2 andP4. Either of the other two stencils produce an admissible approximations to the localbehavior at P3, but the chosen stencil ({P1, P2, P3}) has a lower curvature.

P1

P2

P3

P4

P5

~T3

Figure 6: Computing the tangent vector at P3. Three circles pass through P3: {P1, P2, P3}(solid), {P2, P3, P4} (dashed), and {P3, P4, P5} (dotted). The tangent is obtained fromthe largest circle {P1, P2, P3}.

For a given circle, we can compute two tangent vectors at each point correspondingto two orientations of the circle. We choose the tangent vector pointing in the directionof increasing indices on the set of sample points. For this to hold, we require

~Di · ~Ti > 0 and ~Di+1 · ~Ti > 0, (25)

where ~Di is the vector connecting Pi−1 to Pi, i = 1, 2, . . . , N If both these conditionsare not met, the corresponding tangent vector should be rotated by π radians. This is

10

Page 11: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

illustrated in fig. 7. In the figure, there are two possible choices at P2, ~T2 and −~T2. Thechoice of −~T2 causes the interpolant to make a “U-turn” and forces the curve to pointin the wrong direction at the end point (fig 7, right). This is undesirable as the curveon the left is clearly smoother than the curve on the right. If both conditions cannotbe met simultaneously, we treat this case as an exception the handling of which will bediscussed later.

P1

P1P2

P2

~T1

~T1

~T2

−~T2

Figure 7: Two possible spiral completions using ~T2 (left) and −~T2 (right)

Once the tangents are computed, we use the method of Section 3 for each pair ofpoints Pi−1 and Pi and the corresponding tangents ~Ti−1 and ~Ti to construct the inter-polating segment between the points. The union of all interpolating segments forms theinterpolating curve. By construction, this curve is G1 for well behaved data since at eachpoint Pi the tangent vector to the segments sharing Pi is equal to ~Ti.

In some situations, a more accurate approximation can be formed by permitting adiscontinuity in the tangent vector. This is the case when the conditions (25) cannotbe satisfied simultaneously. In this situation, we place a shock at point Pi. That is,rather than attempt to find a smooth interpolation in this region, we use two differ-ent tangents at Pi. The tangent for the (Pi−1, Pi) interval is obtained from the stencil{Pi−2, Pi−1, Pi}. Similarly, the tangent at Pi for the (Pi, Pi+1) interval is computed fromthe {Pi, Pi+1, Pi+2}. As a result, shocks are placed at specific points along the inter-polation allowing sharp corners and cusps to be approximated. These situations aredemonstrated in figures 8 and 9 respectively.

5 Numerical Examples

In this section, we provide numerical examples of approximating two-dimensional datawith Euler spirals and compare the results with cubic splines and GENO interpolations.Spline interpolations where computed using the MATLAB function spline().

11

Page 12: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

Pi−1

Pi

Pi+1

~Di

~Di+1

γ

Figure 8: A discontinuous tangent vector will be used in the approximation at point Pi ifchosen tangent vector is parallel to Di since γ > π/2. The tangent vector approximatingthe (Pi, Pi+1) interval will be collected separately. The resulting interpolation shouldform a sharp corner at Pi (assuming Pi+2 is positioned reasonably)

Pi−1

Pi

Pi+1

~Ti

−~Ti

~Di~Di+1

γ1

γ2

Figure 9: Point Pi will need to have two tangent vectors defined since γ1 < π/2 and

γ2 < π/2. As a result, ~Di · ~Ti > 0 while ~Di+1 · ~Ti < 0, so the required conditions to placea discontinuous tangent vector are met. The interpolation will form a cusp atPi

5.1 Example 1

We perform a convergence test on the interval [−5, 5] for y = cos(2πx/5) and reportthe results in Table 1. The observed rate of convergence is around 2.7. The spiralapproximation is less accurate than cubic splines for this smooth one-dimensional problemas expected.

5.2 Example 2

We apply the three algorithms to a set of sample points representing a step function. Asexpected, cubic splines exhibit spurious oscillations extending far from the discontinuity.GENO and spiral interpolations result in a monotone data reconstruction with no visibleovershoots in y-direction. The spirals result in a smoother reconstruction than GENOsince the tangents at x = 10, x = 10.5 are continuous. The GENO reconstruction has anabrupt jump in the first derivative at these points. Even without subpixel interpolationof discontinuous data, the spiral interpolation captures the discontinuity in one elementand results in a visually pleasing approximation. We also note that the discontinuity

12

Page 13: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

Spirals SplinesN error r error r

11 2.80E-01 - 2.11E-2 -21 4.31E-02 2.67 2.60E-03 3.0241 6.50E-03 2.73 1.41E-04 4.281 9.63E-04 2.75 6.65E-06 4.4161 1.53E-04 2.65 3.13E-07 4.41

Table 1: L2 errors of the two methods applied to cos

(

2πx

5

)

on x ∈ [−5, 5] with N

sample points.

in the function affects the spiral interpolation only on the interval containing the jump.The other segments are not influenced by the shock, as the adaptive stencil chooses onlysample points to the left or right of the discontinuity.

9 9.5 10 10.5 11 11.5 12

0

0.2

0.4

0.6

0.8

1

GENOSpiral InterpolationCubic Spline

Figure 10: Cubic splines, GENO and the spiral algorithm applied to a step-function.

5.3 Example 3

Next, we apply the three methods to a NACA0012 airfoil, the surface of which is givenby

y = ±5t(0.2969√x− 0.126x− 0.3516x2 + 0.2843x3 − 0.1015x4), (26)

with t = 0.12. The airfoil is a closed curve and cannot be expressed as a single valuedfunction. We use parameterized cubic splines with the index j of point Pj as a parameter

13

Page 14: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

value, i.e., (x(j), y(j)) = Pj, j = 1, 2, . . . , N . We then obtain a cubic spline approxima-tion of x(t) and y(t) by interpolating them separately. With 38 sample points, all threeinterpolations appear to be very accurate (fig. 11). The only visible discrepancy fromthe actual airfoil occurs right at the tail where the airfoil comes to a sharp point (fig. 12).This is a feature cubic splines are unable to simulate. We observe that cubic splines resultin smoothing of the tail of the airfoil, whereas both GENO and the proposed algorithmcapture the desired behavior. We computed the L2 errors in parameterized splines, one-dimensional splines, GENO and spiral interpolations with 80 sample points. The resultsare 7.22e− 04, 2.2e− 03, 3.90e− 04, and 3.76e− 05, respectively. In this example, Eulerspirals provide the smallest error. The large error in parameterized splines comes froma poor approximation of the tail. The one-dimensional splines (regular splines appliedto upper and lower halves of the airfoil separately) generated a large error due to in-ability to estimate and meet boundary conditions. One could apply a local interpolationmethod such as piecewise continuous hermite interpolating polynomials to this problem,however the result with this method would encounter the same smoothing problem asparameterized splines at the end of the wing. In Figure 13 we plot pressure isolines forthe flow with free flow Mach number equal to .38. The isolines are smooth and numericalirregularities like ones in Figure 2, left, are not present.

Figure 11: Interpolations of the NACA0012 airfoil.

Figure 12: Zoom of the NACA0012 airfoil’s tail. GENO and spiral interpolations in thisregion are equal and are shown as solid line, cubic splines represented by dashed line.

14

Page 15: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

Figure 13: Pressure contours for a flow around the NACA0012 airfoil.

5.4 Example 4

This example compares the interpolations resulting from the three methods applied to aset of randomly generated data. The x coordinates are 0, 1, . . . , 30, and the y coordinateswere obtained using the rand() function in MATLAB. The results are plotted in fig. 14,the solutions are translated vertically for easy comparison. In this example it is difficult toclaim that one method provides a more accurate solution than another. The cubic splineinterpolation (top) is very smooth and features oscillatory behavior, most noticeablyaround x = 10 and x = 25. The GENO interpolation (bottom) has sharp corners, butno oscillatory behavior. In the middle is the interpolation consisting of spiral segments.We see one point (x = 19) featuring a discontinuity in tangent as discussed in Section 4.It appears that the spiral approximation possesses positive attributes of the other twomethods because the interpolation is smooth and oscillations are not visible.

0 5 10 15 20 25 30−1

0

1

2

3

Cubic Spline Spiral Interpolation GENO

Figure 14: Cubic Spline (top), spiral (middle) and GENO (bottom) interpolations appliedto a random set of sample points

15

Page 16: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

5.5 Example 5

This example demonstrates the robustness of spiral approximations for two dimensionaldata. We apply cubic splines and spiral interpolations to a set of ordered points repre-senting the outline of a hand [14]. We demonstrate that the choice of parametrizationinfluences accuracy of spline approximations.

We use two parameterizations. The first, naive parametrization is to use the index jof point Pj as a parameter value, i.e. (x(j), y(j)) = Pj, j = 1, 2, . . . , N . For the secondparametrization we use polar coordinates. This approach uses the starlike property ofthis data set to provide a single valued function r(θ) where ri is the distance measuredfrom a fixed point PF = (P1 + PN)/2 to each sample point and θi is the angle betweenthe positive x-axis and the line connecting the sample point Pi and PF . We apply cubicspline interpolation to points [θj , rj], j = 1, 2, . . . , N .

The first cubic splines approximation seems to be accurate. The “naive” parametriza-tion works well in this case because the points are relatively equally spaced. The poorapproximation comes from interpolating r(θ) because in some regions small changes in θresult in large changes in r. Splines tend to oscillate in regions like this.

The spiral algorithm does not require a parametrization or a single valued functionto interpolate since it relies on two dimensional geometric shapes. The largest differencebetween the successful cubic spline interpolation and the spiral interpolation seems to bein the regions between fingers. Again, the spirals allow the interpolation to come to apoint whereas the splines smooth out these areas. Given such few sample points, eitherbehavior at these points appears valid.

5.6 Example 6

In this example, we apply our algorithm to a realistic and complex geometry. We useit for reconstruction of the boundary and two-dimensional mesh generation for the lakeOpeongo located in the northeastern Ontario. The geometrical description of the lake wasobtained from bathymetry measurements by the Ontario Ministry of the Environmentand provided by Harkness Laboratory of Fisheries Research. The bathymetric data wassampled every 200m with the total area of the lake being 5.8 square kilometers. The inputfor the mesh generator is the zero-contour of the bathymetry which consists of 745 pointsincluding the points used to describe small islands inside the lake. Our Cartesian meshgenerator is similar to NASA’s Cart 3D mesh generator [2] and has adaptive capabilities.The mesh is needed to model lake dynamics. To accurately and efficiently resolve theproblem, we need to concentrate small cell in regions where the geometry and the solutionchange rapidly. By concentrating cells where they are needed the most we are able toreduce the total number of cells and, hence, the computing time. In this example, theregions marked for refinement would be the regions near the lake shore and islands.The adaptive process is driven by numerical estimation of the local curvature of thegeometry. In this example, we used five levels of refinement, i.e. we have cells of sizeh,h/2, . . . , h/32. In Figure 16, we show a spiral reconstruction of the lake shore and the

16

Page 17: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−0.2

0

0.2

0.4

0.6

0.8

1

1.2

Figure 15: Completions of a hand using spirals (left) and two different cubic splinemethods (right). In the right plot, the dashed line corresponds to the approximation usinga polar coordinates parametrization, and the solid line corresponds to the parametrizationusing indices.

overall view of the mesh. Darker regions on the plot correspond to a highly refined mesh.A close up of the mesh near one of the islands is shown in Figure 17, right. The meshgenerator starts from a uniform Cartesian grid and then cuts out the embedded geometryproducing small irregular cells in the process. Two more close-ups of reconstruction ofthe lake shore are shown in Figure 18 with dots corresponding to the data points andlines showing the reconstruction. We observe that Euler spiral approximation results ina good representation of the lake geometry. Even a small described by only four pointshas a reasonable shape Figure 18, right.

6 Discussion and Conclusions

The proposed algorithm reconstructs a two-dimensional curve from a set of ordered sam-ple points. The approximation is constructed independently on each segment (Pi−1, Pi)by using Euler spirals. The distinct features of the algorithm are the G1 continuity ofthe interpolant in the smooth regions and the lack of oscillations near function discon-tinuities. In fact, only the interpolation in the segments containing a discontinuity areaffected by it. This is achieved by employing an adaptive stencil and enforcing continuityof tangents at the sample points. In our numerical experiments, the convergence rate ofinterpolation was slightly below three. However, the method can be more accurate thansplines even for one-dimensional interpolation of a smooth function as was demonstrated

17

Page 18: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

−2000 0 2000 4000 6000 8000 10000 12000 14000

0

5000

10000

15000

Figure 16: Lake Opeongo. Left: outline of the lake. Right: adaptive Cartesian grid.

5500 6000 6500 7000

2500

3000

3500

4000

4500

Figure 17: Lake Opeongo, zoom near an island. Left: boundary reconstruction. Right:adaptive Cartesian grid.

in Example 3.Our main goal was to construct an accurate interpolation of a physical geometry given

a mesh around it. The ability of the method to provide an accurate approximation nearthe front and the tail of the airfoil is of a great importance as the flow simulations areespecially sensitive to the geometric errors produced in these regions. However, we believethat the proposed algorithm could find a wider use, for example in image reconstruction.Our method can be viewed as an extension of the GENO method which was shown toprovide excellent results in [18]. However, when sample points are placed less denselythe GENO interpolant may become noticeably less smooth. In this case, the smootherEuler spiral approximation may be more advantageous.

In this work we did not consider a situation where a sharp corner of the solution islocated between sample points as this does not occur in applications we are interested

18

Page 19: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

5000 5200 5400 5600 5800 6000 6200

6000

6200

6400

6600

6800

7000

7200

1.334 1.336 1.338 1.34 1.342 1.344 1.346 1.348

x 104

1.037

1.038

1.039

1.04

1.041

1.042

1.043

1.044

1.045

1.046

x 104

Figure 18: Lake Opeongo. Left: a close-up of a lake shore approximation. Right: ap-proximation of a small island.

in. Placing a shock inside of an element should be possible in the spirit of the subpixelinterpolation described in [18]. However, the step function example demonstrates thatthe spiral interpolation can handle this situation very well even without shock placement.

7 Acknowledgment

This research was supported in part by Natural Sciences and Engineering Research Coun-cil (NSERC) of Canada grants 341373-07 and 344630-06.

References

[1] M. Abramowitz and I.A. Stegun, editors. Handbook of Mathematical Functions.Dover, New York, 1965.

[2] M. J. Aftosmis, M. J. Berger, and J. E. Melton. Adaptive Cartesian Mesh Genera-tion. 1999.

[3] K.G. Baass. The use of Clothoid templates in highway design. Transportation Forum1, 1984.

[4] C. de Boor. A Practical Guide to Splines. Springer, 2001.

[5] K. J. Fidkowski and D. L. Darmofal. A triangular cut-cell adaptive method forhigh-order discretizations of the compressible Navier-Stokes equations. Journal ofComputational Physics, 225:1653–1672, 2007.

19

Page 20: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

[6] Z. Habib and M. Sakai. Fair path planning with a single cubic spiral segment. InFifth International Conference on Computer Graphics, Imaging and Visualisation,pages 121–125, Washington, DC, USA, 2008. IEEE Computer Society.

[7] Z. Habib and M. Sakai. g2 cubic transition between two circles with shape control.Journal of Computational and Applied Mathematics, 223(1):133–144, 2009.

[8] A. Harten, B. Engquist, S. Osher, and S. Chakravarthy. Uniformly high-order ac-curate essentially nonoscillatory schemes III. Journal of Computational Physics,71:231–303, 1987.

[9] M. Heald. Rational approximations for the Fresnel integrals. Mathematics of Com-putation, 170:459–461, 1985.

[10] A. Kelly and B. Nagy. Reactive nonholonomic trajectory generation via parametricoptimal control. The International Journal of Robotics Research, 22(7/8):583–601,2003.

[11] B. Kimia, I. Frankel, and A.-M. Popescu. Euler spiral for shape completion. Inter-national Journal of Computer Vision, 54:159–182, 2003.

[12] L. Krivodonova and M. Berger. High-order accurate implementation of solid wallboundary conditions in curved geometries. Journal of Computational Physics,221:492–512, 2006.

[13] D.S. Meek and D.J. Walton. A note on finding clothoids. Journal of Computationaland Applied Mathematics, 170:433–453, 2004.

[14] C. Moler. Numerical Computing with MATLAB. Society for Industrial and AppliedMathematics, 2004.

[15] W.H. Press, S.A. Teukolsky, W.T. Vetterling, and B.P. Flannery. NumbericalRecipes, Third Edition. Cambridge, 2007.

[16] R. Sevilla and S. Fernandez-Mendez. Numerical integration over 2D NURBS-shapeddomains with applications to NURBS-enhanced FEM. Finite Elements in Analysisand Design, 47:1209–1220, 2011.

[17] R. Sevilla, S. Fernandez-Mendez, and A. Huerta. NURBS-Enhanced finite elementmethod for Euler equation. International Journal for Numerical Methods in FLuids,87:1–28, 2007.

[18] K. Siddiqi, B. Kimia, and C.-W. Shu. Geometric shock-capturing ENO schemesfor subpixel interpolation, computation and curve evolution. Graphical Models andImage Processing, 59:278–301, 1997.

20

Page 21: Interpolation of Two-Dimensional Curves with Euler Spiralslgk/spirals.pdfWe propose an algorithm for interpolation of two-dimensional curves, i.e., curves that cannot be represented

[19] J. Stoer. Curve fitting with clothoidal splines. Journal of Research of the NationalBureau of Standards, 87:317–346, 1982.

[20] D. J. Walton and D. S. Meek. An improved Euler spiral algorithm for shape com-pletion. In CRV ’08: Proceedings of the 2008 Canadian Conference on Computerand Robot Vision, pages 237–244, Washington, DC, USA, 2008. IEEE ComputerSociety.

[21] D.J. Walton and D.S. Meek. G1 interpolation with a single Cornu spiral segment.Journal of Computational and Applied Mathematics, 223(1):86 – 96, 2009.

[22] Zhiyang Yao and Ajay Joneja. Path generation for high speed machining using spiralcurves. Computer-Aided Design & Applications, 4:191–198, 2007.

21