1 Introduction

In 1994, Harada et al., while investigating the mental images suggested by aesthetically pleasing shapes, set up an experiment to quantitatively analyze a curve’s character from the viewpoint of the observer [6]. Their main result may be described as follows: the curves that car designers regard as aesthetically pleasing have the common property that the frequency histogram of the radius of curvature follows a piecewise linear relation in a log-log scale. An analytic formulation of those curves was provided in [13] defining what will later be called the log-aesthetic curves (LAC), which promoted theoretical and practical studies of LAC towards their use in computer-aided geometric design as indicated by Levien and Séquin [10]. In this regard, several works have been written concerning the implementation and construction of LAC with fixed boundary conditions, see for example [3, 4, 16, 18]. Furthermore, extensions to surfaces have also been considered with an emphasis on providing practical tools for industrial design, see [12]. From a different point of view, LAC have been characterized as curves that are obtained via a variational principle in the framework of similarity geometry; moreover, they can also be seen as invariant curves under the integrable flow on plane curves governed by the Burgers equation [9]. This fact was also shown to be useful in providing an integrable discretization of the LAC that preserves the underlying geometric structure [8]. These previous contributions are mainly focused on providing tools for curve generation with fixed boundary conditions. In this paper, with reverse engineering applications in mind, we provide a method to characterize a given curve by its closest LAC. Although we considered the input data to be discrete (as a sequence of points), the idea behind our algorithm can be applied to smooth input data as well. In Sect. 2, we provide the basic framework, we show how a general LAC segment can be uniquely identified by seven parameters, and we solve the inverse problem of recovering the parameters that characterize a given general LAC segment. In Sect. 3, we construct a method of parametric approximation that finds the seven parameters of a smooth LAC that is the closest, in a \(L^2\)-distance sense, to the input curve. Finally, a demonstration of the applicability of the algorithm is shown by using the data points obtained from 3D scanning a model-car roof, where we identify their underlying LAC. The works [16] and [11] are the closest to the present contribution, where similar tools to characterize the family of LAC are shown. However, [11] provides local fairing techniques to sequence of points with noise, whereas we recover globally all the parameters that characterize an LAC. Our method is based on the one presented in [1], to approximate a given planar curve by an Euler’s elastica, and on its follow-up work [5], for the discrete Euler’s elastica.

2 Log-aesthetic curve

2.1 Basic formulation

First of all, let us review some definitions regarding planar curves. Let \(\gamma (s)\in \mathbb {R}^{2}\) be a planar curve parameterized by the arc length \(s \in [0, L]\), with total length L. The tangent and normal vectors are defined by \(T(s) = \gamma '(s)\) and \(N(s) = \,\textrm{R}_{\pi \!/2}\,T(s)\), respectively, where \(\,\textrm{R}_{\pi \!/2}\,\) is a \(\pi \!/2\) counterclockwise rotation matrix and \({\text { }}'=\text {d}/\text {d}{s}\). By definition, \(\left\Vert T(s)\right\Vert = 1\), so the tangent vector is parameterized by the turning angle \(\theta (s)\), such that

$$\begin{aligned} T(s) = \begin{pmatrix} \cos \theta (s)\\ \sin \theta (s) \end{pmatrix}, \end{aligned}$$
(1)

namely, the angle of the tangent vector measured from the horizontal axis. The curvature is defined by \(\kappa (s) = \theta '(s)\), and the radius of curvature by \(\rho (s) = 1/\kappa (s)\).

As it is shown in [13], by considering an analytic formulation of the work by Harada et al., it can be seen that log-aesthetic curves (or simply referred to as LAC) satisfy that

$$\begin{aligned} \log \left( \frac{\text {d}^{}s}{\text {d}R^{}}\right) = \alpha R - \log A, \end{aligned}$$
(2)

for some \(\alpha \in \mathbb {R}^{}\) and \(A > 0\), where \(R=\log \rho\). Equation (2) is usually presented as the defining equation of the LAC. In this work, while interested in characterizing geometrical properties of the LAC, let us consider the following equivalent expression:

Definition 1

(Log-aesthetic curve) An arc length parameterized curve \(\gamma (s) \in \mathbb {R}^{2}\) with strictly monotonic radius of curvature is called a em log-aesthetic curve (LAC) if its curvature satisfies

$$\begin{aligned} \kappa \kappa '' - (\alpha + 1) \left( \kappa '\right) ^2 = 0, \end{aligned}$$
(3)

for some constant \(\alpha \in \mathbb {R}^{}\).

Remark 1

Assuming that the functions are well-behaved, we have \(\frac{\text {d}^{}s}{\text {d}R^{}} = \rho /\rho '\), then (2) is rewritten as

$$\begin{aligned} \rho ' \rho ^{(\alpha - 1)} = A. \end{aligned}$$
(4)

Since \(\rho = \kappa ^{-1}\), we have from (4)

$$\begin{aligned} \kappa ' = -A \kappa ^{-(\alpha + 1)}. \end{aligned}$$
(5)

Then, the derivative of (5) gives (3).

Remark 2

Because we are considering curves with strictly monotonic radius of curvature, the turning angle function is invertible and thus it can be used to parameterize all the geometric objects. In particular, from (3) we obtain

$$\begin{aligned} \kappa \frac{\text {d}^{2}\kappa }{\text {d}\theta ^{2}} - \alpha \left( \frac{\text {d}^{}\kappa }{\text {d}\theta ^{}}\right) ^2 = 0, \end{aligned}$$
(6)

and by defining \(u(\theta ) = \frac{\text {d}^{}}{\text {d}\theta ^{}}\log (\kappa (\theta ))\), equation (6) is equivalent to the Riccati Eq.

$$\begin{aligned} \frac{\text {d}^{}u}{\text {d}\theta ^{}} = (\alpha - 1) u^2. \end{aligned}$$
(7)

In the context of similarity geometry, \(u(\theta )\) is known as the similarity curvature and (7) appears when studying an integrable flow on plane curves governed by the Burgers equation, see [9].

Let us see that the parameter \(\alpha\) of a given LAC is invariant under the similarity transformations and reflections. Firstly, note that because the curvature of a planar curve is invariant under the Euclidean transformations, we only check the invariance under scale transformations and the reflections over the diagonal \(\{(x,x) \in \mathbb {R}^{2} | x \in \mathbb {R}^{}\}\). For scale transformations, consider the arc length parameterized LAC \(\gamma (s)\) satisfying (3), for some \(\alpha \in \mathbb {R}^{}\), and define \(\tilde{\gamma }(\tilde{s}) := S \gamma (\tilde{s}/S),\) where \(S > 0\). Then \(\tilde{\kappa }(\tilde{s})\), the curvature of \(\tilde{\gamma }(\tilde{s})\), is given by \(\tilde{\kappa }(\tilde{s}) = S^{-1} \kappa (\tilde{s}/S)\) and it is easy to see that it satisfies (3). For the reflections over the diagonal, note that interchanging the \(x-\) and \(y-\)component of the curve is equivalent to changing the sign of the curvature, and (3) is invariant under that change.

The fundamental theorem of planar curves states that an arc length parameterized planar curve is uniquely determined by its curvature up to Euclidean transformations. In addition, the curvature of an LAC determined by (3) has two arbitrary parameters. In view of this, we introduce the basic LAC by fixing this freedom and then we show that one can recover a general LAC by applying similarity transformations and shifting the arc length parameter of a basic LAC.

Definition 2

(Basic LAC) Let \({\xi ^{\alpha }}(s) \in \mathbb {R}^{2}\) be an arc length parameterized LAC defined over an open interval \(I \subset \mathbb {R}^{}\), such that \(\{0\} \in I\). We call \({\xi ^{\alpha }}(s)\) a basic LAC if it satisfies that

$$\begin{aligned} {\left\{ \begin{array}{ll} \kappa '(s)= - (\kappa (s))^{(\alpha + 1)} < 0, \quad \kappa (s) > 0,\\ \kappa (0) = 1, \\ \theta (0) = 0,\\ {\xi ^{\alpha }}(0) = \left( {\begin{matrix}0\\ 0\end{matrix}}\right) , \end{array}\right. } \end{aligned}$$
(8)

where \(\kappa (s)\) and \(\theta (s)\) are its curvature and turning angle, respectively.

Let us see a more explicit expression for the basic LAC and its related quantities. In what follows, we use the sub-index \({\xi ^{\alpha }}\), as for example \(\kappa _{\xi ^{\alpha }}\), to denote those quantities associated to their respective basic LAC. Taking the initial condition into consideration, the explicit form of the curvature is given by

$$\begin{aligned} \kappa _{{\xi ^{\alpha }}}(s) = {\left\{ \begin{array}{ll} \exp (-s), &{} \alpha = 0,\\ (1 + \alpha s)^{-1/\alpha }, &{} \alpha \ne 0. \end{array}\right. } \end{aligned}$$
(9)

Then, the turning angle is obtained from the curvature by \((\theta _{{\xi ^{\alpha }}})' = \kappa _{{\xi ^{\alpha }}}\),

$$\begin{aligned} \theta _{{\xi ^{\alpha }}}(s) = {\left\{ \begin{array}{ll} 1 - \exp (-s), &{} \alpha = 0,\\ \log (s + 1), &{} \alpha = 1,\\ \frac{(1 + \alpha s)^{\frac{\alpha - 1}{\alpha }} - 1}{\alpha - 1}, &{} \alpha \ne 0, 1. \end{array}\right. } \end{aligned}$$
(10)

Although it is not used in this work, we note that the position vector \({\xi ^{\alpha }}(s)\) can be expressed in terms of the incomplete gamma function, see for example [18]. For a basic LAC, we have that \(\kappa > 0\), which implies that \(1 + \alpha s > 0\). Then, the maximal interval \(I_\alpha \subset \mathbb {R}^{}\) on which the basic LAC can be defined is

$$\begin{aligned} I_\alpha = {\left\{ \begin{array}{ll} \left( -\infty , -1/\alpha \right) , &{} \alpha < 0,\\ \left( -\infty , \infty \right) , &{} \alpha = 0,\\ \left( -1/\alpha , \infty \right) , &{} \alpha > 0, \end{array}\right. } \end{aligned}$$
(11)

and we assume that all basic LAC are defined over \(I_\alpha\). Finally, note that the image of \(\kappa _{\xi ^{\alpha }}\) is \(\kappa _{\xi ^{\alpha }}[I_\alpha ] = (0, \infty )\).

Proposition 1

Any LAC with \(\alpha \ne 1\) and positive decreasing curvature can be expressed as a basic LAC after applying similarity transformations and shifting the arc length parameter. In particular, if \(\gamma (s)\), \(s \in [0, L]\), is an LAC of length L, there exists a unique \(\gamma _0 \in \mathbb {R}^{2}\), \(\phi \in [0, 2\pi )\), \(S \in \mathbb {R}^{}\backslash \{0\}\), and \(s_0 \in \mathbb {R}^{}\), such that

$$\begin{aligned} \gamma (s) = \gamma _0 + S \,\textrm{R}_{\phi }\, {\xi ^{\alpha }}(s/S + s_0), \qquad s\in [0, L], \end{aligned}$$
(12)

where \({\xi ^{\alpha }}(s)\) is a basic LAC of length L/S.

Proof

For a given LAC \(\gamma (s)\), \(s \in [0, L]\) with \(\alpha \ne 1\) and positive decreasing curvature, we know that its curvature satisfies (3), which can be integrated once to obtain

$$\begin{aligned} \kappa '(s) = - A (\kappa (s))^{(\alpha + 1)}, \end{aligned}$$
(13)

for some \(A > 0\). Next, consider the curve \(\bar{\gamma }(\bar{s}) := S^{-1}\gamma (\bar{s}S)\), \(\bar{s} \in [0, L/S]\), and set \(S = A^{1/(\alpha -1)}\). Note that the curvature of \(\bar{\gamma }\) satisfies

$$\begin{aligned} {\left\{ \begin{array}{ll} \bar{\kappa }'(\bar{s})= -(\bar{\kappa }(\bar{s}))^{(\alpha + 1)},\\ \bar{\kappa }(0) = A^{1/(\alpha -1)} \kappa (0), \end{array}\right. } \end{aligned}$$
(14)

which can be integrated to obtain

$$\begin{aligned} \bar{\kappa }(\bar{s}) = {\left\{ \begin{array}{ll} \exp (-(\bar{s} - \log \bar{\kappa }(0))), &{} \alpha = 0,\\ \left[ 1 + \alpha \left( \bar{s} + \frac{(\bar{\kappa }(0))^{-\alpha } - 1}{\alpha }\right) \right] ^{-1/\alpha }, &{} \alpha \ne 0. \end{array}\right. } \end{aligned}$$
(15)

By comparing \(\bar{\kappa }\) with \(\kappa _{\xi ^{\alpha }}\) in (9), there exists a unique \(s_0 \in \mathbb {R}^{}\) such that \(\bar{\kappa }(\bar{s}) = \kappa _{{\xi ^{\alpha }}}(\bar{s} + s_0)\). From the fundamental theorem of planar curves, it follows that the curves \(\bar{\gamma }\) and \({\xi ^{\alpha }}\) are congruent up to rigid transformations, i.e.

$$\begin{aligned} \bar{\gamma }(\bar{s}) = \bar{\gamma }_0 + \,\textrm{R}_{\phi }\, {\xi ^{\alpha }}(\bar{s} + s_0), \qquad \bar{s}\in [0, L/S], \end{aligned}$$
(16)

for some \(\bar{\gamma }_0\in \mathbb {R}^{2}\) and \(\phi \in [0, 2\pi )\). Finally, we use that \(\gamma (s) = S \bar{\gamma }(s/S)\) to obtain (12) with \(\gamma _0 := S \bar{\gamma }_0\). \(\square\)

Remark 3

In the proof of Proposition 1, the scale transformation is used to change the value of A, in (13), without changing the value of \(\alpha\). However, in the case of \(\alpha = 1\) this technique cannot be exploited because it corresponds to the logarithmic spiral, which is a self-similar curve. Namely, the value of A for a given logarithmic spiral is invariant under scale transformations, thus the technique used in Proposition 1 cannot be used to recover the entire family of LAC with \(\alpha = 1\).

Remark 4

Let X be the reflection of \(\mathbb {R}^{2}\) defined by the map \((x,y) \mapsto (y,x)\). If \(\gamma (s)\), \(s \in [0, L]\), is an LAC, then also are

$$\begin{aligned} {\left\{ \begin{array}{ll} \gamma ^{(1)}(s) := \gamma (L - s),\\ \gamma ^{(2)}(s) := X\gamma (s),\\ \gamma ^{(3)}(s) := X\gamma (L -s). \end{array}\right. } \end{aligned}$$
(17)

Moreover, their respective curvatures satisfy

$$\begin{aligned} {\left\{ \begin{array}{ll} \kappa ^{(1)}(s) = -\kappa (L - s),\\ \kappa ^{(2)}(s) = -\kappa (s),\\ \kappa ^{(3)}(s) = \kappa (L -s), \end{array}\right. } \end{aligned}$$
(18)

which allow us to use Proposition 1 in those cases in which the curvature is not positive and decreasing, by applying one of the transformations (17) (Fig. 1).

Fig. 1
figure 1

Typical examples of log-aesthetic curves

2.2 Recovering the parameters of an LAC segment

We focus our attention on the problem of finding the parameters that uniquely identify a given LAC segment. We proceed in three steps, in which we solve several linear equations in the least-squares sense, with the objective of constructing an algorithm that can be applied to general curves. Before describing the method, let us consider the following remarks: In view of Remark 3 we omit the case \(\alpha = 1\), and for simplicity in the formulation of this method we further omit the case \(\alpha = 0\). Note that, removing these values does not hinder the quality of the algorithm, because they are only single points on the real line. At last, given an LAC segment \(\gamma (s)\), \(s \in [0, L]\), by possibly applying one of the transformations (17), we assume that its curvature is positive and decreasing.

From Proposition 1, it follows that for a given LAC segment \(\gamma (s)\), \(s \in [0, L]\), there exists a set of parameters \(\{\alpha , S, s_0, l, \phi , x_0, y_0\}\) such that

$$\begin{aligned} \gamma (s) = \begin{pmatrix} x_0\\ y_0 \end{pmatrix} + S \,\textrm{R}_{\phi }\, {\xi ^{\alpha }}(s/S + s_0), \qquad s\in [0, lS], \end{aligned}$$
(19)

which implies, by definition of the curvature function, that

$$\begin{aligned} \kappa (s) = S^{-1} \kappa _{{\xi ^{\alpha }}}(s/S + s_0). \end{aligned}$$
(20)

Let \(R = - \log \kappa\) and \(R_{\xi ^{\alpha }}= - \log \kappa _{\xi ^{\alpha }}\), then

$$\begin{aligned} R(s) = \log S + R_{{\xi ^{\alpha }}}(s/S + s_0). \end{aligned}$$
(21)

Finally, from the differential Eq. (8) we have that \(\log (R_{{\xi ^{\alpha }}}') + \alpha R_{{\xi ^{\alpha }}} = 0\); hence, from (21), we obtain

$$\begin{aligned} \log (R') + \alpha R = (\alpha - 1) \log S. \end{aligned}$$
(22)

Step 1: Let \(c_1 := \alpha\) and \(c_0:= (\alpha - 1) \log S\). Then, from (22), in the least squares sense we have

$$\begin{aligned} (c_0, c_1) = {\mathop {{{\,\mathrm{arg\,min}\,}}}\limits _{(\bar{c}_0,\bar{c}_1)}}\left\{ \frac{1}{2} \int _0^L (\log (R') + \bar{c}_1 R - \bar{c}_0)^2 \text {d}{s} \right\} , \end{aligned}$$
(23)

which leads to

$$\begin{aligned} c_1 = \frac{L \int _0^L R \log (R') \text {d}{s} - \int _0^L R \text {d}{s} \int _0^L \log (R') \text {d}{s}}{(\int _0^L R \text {d}{s})^2 - L \int _0^L R^2 \text {d}{s}}, \end{aligned}$$
(24)

and

$$\begin{aligned} c_0 = \frac{1}{L} \int _0^L (\log (R') + c_1 R) \text {d}{s}. \end{aligned}$$
(25)

Then, \(\alpha = c_1\) and \(S = \exp (c_0/(c_1 - 1))\). Step 2: From (9) and (20), we have that \(\kappa (s) = S^{-1} (1 + \alpha (s/S + s_0))^{-1/\alpha },\) which allows us to isolate the parameter \(s_0\) as

$$\begin{aligned} s_0 = \frac{(S \kappa (s))^{-\alpha }}{\alpha } - \frac{1}{\alpha } - \frac{s}{S}. \end{aligned}$$
(26)

Then,

$$\begin{aligned} s_0 := {\mathop {{{\,\mathrm{arg\,min}\,}}}\limits _{\bar{s}_0}}\left\{ \frac{1}{2} \int _0^L \left( \frac{1}{\alpha S^\alpha \kappa (s)^\alpha } - \frac{1}{\alpha } - \frac{s}{S} - \bar{s}_0\right) ^2 \text {d}{s}\right\} \end{aligned}$$
(27)

gives

$$\begin{aligned} s_0 = \frac{1}{\alpha L S^\alpha } \int _0^L (\kappa (s))^{-\alpha } \text {d}{s} - \frac{1}{\alpha } - \frac{1}{LS} \int _0^L s \text {d}{s}. \end{aligned}$$
(28)

Similarly, we compute \(s_{\textrm{end}} := L/S + s_0\) from \(\kappa ^{(3)}(s) = \kappa (L-s) = S^{-1} (1 + \alpha (s_{\textrm{end}} - s/S))^{-1/\alpha }\). In the least squares sense, we obtain

$$\begin{aligned} s_{\textrm{end}} = \frac{1}{\alpha L S^\alpha } \int _0^L (\kappa (L-s))^{-\alpha } \text {d}{s} - \frac{1}{\alpha } + \frac{1}{LS} \int _0^L s \text {d}{s}, \end{aligned}$$
(29)

Hence,

$$\begin{aligned} l = s_{\textrm{end}} - s_0 = L/S. \end{aligned}$$
(30)

Step 3: At this point, it rests to find the rotation and translation parameters. For the former, note that the angle function of \(\gamma\) and \({\xi ^{\alpha }}\) differ only by a constant \(\phi\), as

$$\begin{aligned} \theta (s) = \phi + \theta _{{\xi ^{\alpha }}}(s/S + s_0). \end{aligned}$$
(31)

Thus, in the least squares sense we obtain

$$\begin{aligned} \phi = \frac{1}{L} \int _0^L(\theta (s) - \theta _{{\xi ^{\alpha }}}(s/S + s_0))\text {d}{s}. \end{aligned}$$
(32)

Finally, for the translation \((x_0, y_0)\) we solve (12) in the least squares sense,

$$\begin{aligned} \begin{pmatrix} x_0\\ y_0 \end{pmatrix} = \frac{1}{L} \int _0^L \left( \gamma (s) - S \,\textrm{R}_{\phi }\, {\xi ^{\alpha }}(s/S + s_0)\right) \text {d}{s}. \end{aligned}$$
(33)

3 Approximation of planar curves

3.1 Methodology

Now we consider the case where a general curve segment is given and we want to find an LAC segment that is the closest in a \(L^2\)-distance sense. For the applications that we have in mind, the input is regarded as a discrete curve and thus we must consider a discretization of the LAC. From Proposition 1, we know that any LAC segment with \(\alpha \ne 1\), after a possible change of parameterization or reflection (Remark 4), can be expressed as

$$\begin{aligned} \xi ^{}(s) = \begin{pmatrix} x_0\\ y_0 \end{pmatrix} + S \,\textrm{R}_{\phi }\, {\xi ^{\alpha }}(s/S + s_0),\qquad s\in [0, L], \end{aligned}$$
(34)

where \({\xi ^{\alpha }}\) is a basic LAC with total length \(l := L/S\). Furthermore, \(\xi ^{}(s)\) is also rewritten as

$$\begin{aligned} \xi ^{p}(s) = \begin{pmatrix} x_0\\ y_0 \end{pmatrix} + S \int _0^s \begin{pmatrix} \cos (\theta _{\xi ^{\alpha }}(t/S+s_0) + \phi )\\ \sin (\theta _{\xi ^{\alpha }}(t/S+s_0) + \phi ) \end{pmatrix} \text {d}{t},\qquad s\in [0,L], \end{aligned}$$
(35)

where \(\theta _{\xi ^{\alpha }}\) is given by (10). From now on, let us consider a discretization of (35). Let \(N \in \mathbb {N}^{}\), and define

$$\begin{aligned} {\left\{ \begin{array}{ll} h := \frac{L}{N-1},\\ z := \frac{L}{S(N-1)} = \frac{l}{N-1}, \end{array}\right. } \end{aligned}$$
(36)

and the discrete curve \(\xi ^{\varTheta }_n \in \mathbb {R}^{2}\), \(n = 0, \dots , N-1\), such that

$$\begin{aligned} \left\{ \begin{array}{l} \xi ^{\varTheta }_n = \xi ^{\varTheta }_{n-1} + h \begin{pmatrix} \cos (\theta _{\xi ^{\alpha }}(z n+s_0) + \phi )\\ \sin (\theta _{\xi ^{\alpha }}(z n+s_0) + \phi ) \end{pmatrix}, \qquad n=1,\dots ,N-1,\\ \xi ^{\varTheta }_0 = \begin{pmatrix} x_0\\ y_0 \end{pmatrix}, \end{array} \right. \end{aligned}$$
(37)

where we introduced the notation \(\xi ^{\varTheta }_n\) for the discrete curve that depends on the parameters

$$\begin{aligned} \varTheta := \left( \alpha , h, s_0, z, \phi , x_0, y_0\right) . \end{aligned}$$
(38)

Note that the recursive expression (37) gives an approximation of \(\xi ^{}(s)\) of second order, in the sense that it satisfies

$$\begin{aligned} \xi ^{}(hn) = \xi ^{\varTheta }_n + \mathcal {O}(h^{2}), \qquad n = 0, \dots , N-1. \end{aligned}$$
(39)

The input data for the fairing process is assumed to be a list of N two-dimensional points, which we expresses as the discrete curve

$$\begin{aligned} \gamma _n = \begin{pmatrix} x_n\\ y_n \end{pmatrix},\qquad n=0,\dots , N-1. \end{aligned}$$
(40)

Given \(\gamma _n\), we look for \(\xi ^{\varTheta }_n\) that is the closest in a \(L^2\)-distance sense. Namely, we seek to find a set of parameters \(\varTheta ^*\) such that

$$\begin{aligned} \varTheta ^* = {\mathop {{{\,\mathrm{arg\,min}\,}}}\limits _{\varTheta \in U}} \left\{ \frac{1}{2} \sum _{n=0}^{N-1} \left\Vert \xi ^{\varTheta }_n - \gamma _n\right\Vert ^2 \right\} , \end{aligned}$$
(41)

with the admissible set U given by

$$\begin{aligned} U = \left\{ (\alpha , h, s_0, z, \phi , x_0, y_0) \in \mathbb {R}^{7} \,\bigg | \begin{array}{l} {\alpha \in \mathbb {R}^{}\backslash \{0, 1\}, h> 0, s_0 \in I_\alpha , z > 0,}\\ {\phi \in [0, 2\pi )\text { and }(x_0, y_0)\in \mathbb {R}^{2}} \end{array}\right\} . \end{aligned}$$
(42)

The optimization problem is solved using the Interior Point Optimizer package (IPOPT), which for our purpose can be seen as a gradient descent-like method for nonlinear optimizations (see [15]), so we need the gradient of the objective function,

$$\begin{aligned} \mathcal {L}(\varTheta ) := \frac{1}{2} \sum _{n=0}^{N-1} \left\Vert \xi ^{\varTheta }_n - \gamma _n\right\Vert ^2, \end{aligned}$$
(43)

and an initial guess to start the optimization. For the gradient of (43), we have

$$\begin{aligned} \frac{\partial ^{}}{\partial \varTheta _i^{}}\mathcal {L}(\varTheta ) = \sum _{n=0}^{N-1} \left<{\xi ^{\varTheta }_n - \gamma _n},{\frac{\partial ^{}}{\partial \varTheta _i^{}}\xi ^{\varTheta }_n}\right>, \qquad \varTheta _i = \alpha , h, s_0, z, \phi , x_0, y_0, \end{aligned}$$
(44)

which is computed recursively from Eq. (37), using that

$$\begin{aligned} \frac{\partial ^{}}{\partial \varTheta _i^{}}\xi ^{\varTheta }_n = \frac{\partial ^{}}{\partial \varTheta _i^{}}\xi ^{\varTheta }_{n-1} + {\left\{ \begin{array}{ll} 0 &{} \varTheta _i = x_0, y_0,\\ T_n &{} \varTheta _i = h,\\ h \frac{\partial ^{}}{\partial \varTheta _i^{}}T_n &{} \text {otherwise}, \end{array}\right. } \end{aligned}$$
(45)

with

$$\begin{aligned} \frac{\partial ^{}}{\partial \varTheta _i^{}}\xi ^{\varTheta }_0 = {\left\{ \begin{array}{ll} \left( {\begin{matrix}1\\ 0\end{matrix}}\right) &{} \varTheta _i = x_0,\\ \left( {\begin{matrix}0\\ 1\end{matrix}}\right) &{} \varTheta _i = y_0,\\ \left( {\begin{matrix}0\\ 0\end{matrix}}\right)&\text {otherwise}, \end{array}\right. } \end{aligned}$$
(46)

where we denoted \(T_n\) as

$$\begin{aligned} T_n := \begin{pmatrix} \cos (\theta _{\xi ^{\alpha }}(z n+s_0) + \phi )\\ \sin (\theta _{\xi ^{\alpha }}(z n+s_0) + \phi ) \end{pmatrix}. \end{aligned}$$
(47)

Then, using that \((\theta _{\xi ^{\alpha }})' = \kappa _{\xi ^{\alpha }}\), we obtain the gradient of \(T_n\) by

$$\begin{aligned} \frac{\partial ^{}}{\partial \varTheta _i^{}} T_n = \,\textrm{R}_{\pi /2}\, T_n \times {\left\{ \begin{array}{ll} 1, &{} \varTheta _i = \phi ,\\ \kappa _{\xi ^{\alpha }}(z n + s_0), &{} \varTheta _i = s_0,\\ n\kappa _{\xi ^{\alpha }}(z n + s_0), &{} \varTheta _i = z,\\ \frac{\partial ^{}}{\partial \alpha ^{}}\theta _{\xi ^{\alpha }}(z n + s_0), &{} \varTheta _i = \alpha , \end{array}\right. } \end{aligned}$$
(48)

where

$$\begin{aligned}{} & {} \frac{\partial ^{}}{\partial \alpha ^{}}\theta _{\xi ^{\alpha }}(s) \nonumber \\{} & {} \quad =\frac{(1+s\alpha )^{-\frac{1}{\alpha }}\Big ( (\alpha -1)(1+s\alpha )\log (1+s\alpha ) - \alpha \big (\alpha +2s\alpha -s\big )\Big )}{\alpha ^2(\alpha -1)^2} + \frac{1}{(\alpha -1)^2}, \end{aligned}$$
(49)

which is obtained by direct computation from (10).

For the initial guess, denoted as

$$\begin{aligned} \bar{\varTheta } = \left( \bar{\alpha }, \bar{h}, \bar{s}_{0}, \bar{z}, \bar{\phi }, \bar{x}_{0}, \bar{y}_{0}\right) , \end{aligned}$$
(50)

we use a discrete analogue of the three steps described in Sect. 2.2. Finally, after solving (41), the parameters of the smooth LAC that approximates the input curve are obtained as follows:

$$\begin{aligned} \begin{array}{c} \text {smooth}\\ \text {LAC}\\ \text {parameters}\end{array} {\left\{ \begin{array}{ll} \alpha = \alpha ^*, \\ S = h^* / z^*, \\ s_0 = s_0^*, \\ l = z^* (N - 1),\\ \phi = \phi ^*,\\ x_0 = x_0^*, \\ y_0 = y_0^*. \end{array}\right. } \end{aligned}$$
(51)

3.1.1 Initial guess pseudo-algorithm

For a given a discrete curve \(\gamma _n\), \(n = 0,\dots , N-1\), with constant step size

$$\begin{aligned} \left\Vert \gamma _{n+1} - \gamma _n\right\Vert = h, \qquad n = 0, \dots , N-2, \end{aligned}$$
(52)

we compute the following quantities: A discrete analogue of the tangent vector,

$$\begin{aligned} T_n = \frac{\gamma _{n+1} - \gamma _n}{h}, \qquad n = 0, \dots , N-2, \end{aligned}$$
(53)

a discrete analogue of the turning angle,

$$\left\{ \begin{gathered} \theta _{n} = \theta _{{n - 1}} + \arctan \left( {\det \left( {T_{{n - 1}} ,T_{n} } \right)/\left\langle {T_{{n - 1}} ,T_{n} } \right\rangle } \right),\quad n = 1, \ldots ,N - 2, \hfill \\ \theta _{0} = \arctan \left( {\det \left( {^{t} \left( {1,0} \right),T_{0} } \right)/\left\langle {^{t} \left( {1,0} \right),T_{0} } \right\rangle } \right), \hfill \\ \end{gathered} \right.$$
(54)

and a discrete analogue of the curvature,

$$\begin{aligned} \kappa _n = \frac{2}{h} \frac{\det (T_{n-1}, T_n)}{1 + \left<{T_{n-1}},{T_n}\right>},\qquad n = 1, \dots , N-2. \end{aligned}$$
(55)

As we are interested in approximating \(\gamma _n\) by a single LAC segment, we assume that the curve has no inflection point, implying that \(\kappa _n\) has constant sign. Furthermore, by applying a reflection or by inverting the parameterization (in analogy with Remark 4), we assume that \(\kappa _n\) is positive. After this considerations, we define

$$\begin{aligned} R_n = - \log \kappa _n,\qquad n = 1, \dots , N-2, \end{aligned}$$
(56)

and its discrete derivative by

$$\begin{aligned} \varDelta R_n = -\frac{\kappa _{n+1} - \kappa _n}{\kappa _n}, \qquad n = 1, \dots , N-3. \end{aligned}$$
(57)

Remark 5

In practice, noise on the input curve \(\gamma _n\) might cause \(\kappa _n\) to change signs. In this situation, we replace (56) by

$$\begin{aligned} R_n = - \log \left| \kappa _n\right| ,\qquad n = 1, \dots , N-2. \end{aligned}$$
(58)

\(\varvec{\blacktriangleright }\) Parameter \(\varvec{\alpha }\) Following Step 1, we solve

$$\begin{aligned} (\bar{c}_0, \bar{c}_1) = {\mathop {{{\,\mathrm{arg\,min}\,}}}\limits _{(c_0, c_1)}} \left\{ \frac{1}{2} \sum _{n=1}^{N-3} (\log (\varDelta R_n/h) + c_1 R_n - c_0)^2 h \right\} . \end{aligned}$$
(59)

Then, using that \(\bar{\alpha }= c_0\) and \(\bar{S} = \exp (c_0 / (c_1 - 1))\), we obtain

$$\begin{aligned} \bar{\alpha }= \frac{(N-3)\sum _{n=1}^{N-3}R_n\log \varDelta R_n-\sum _{n=1}^{N-3}R_n\sum _{n=1}^{N-3}\log \varDelta R_n}{\left( \sum _{n = 1}^{N-3}R_n\right) ^2 - (N-3) \sum _{n = 1}^{N-3}R_n^2}, \end{aligned}$$
(60)

and

$$\begin{aligned} \bar{S} = h^{\frac{1}{1 - \bar{\alpha }}}\exp \left( \frac{1}{(\bar{\alpha }- 1)(N-3)} \sum _{n = 1}^{N-3}\left( \log \varDelta R_n + \bar{\alpha }R_n\right) \right) . \end{aligned}$$
(61)

\(\varvec{\blacktriangleright }\) Parameter \(\varvec{s_0, z}\): From Step 2, and using that \(\bar{z} = \bar{l}/(N-1)\), we obtain

$$\begin{aligned} \bar{s}_0 = \frac{1}{\bar{\alpha } (N-2) \bar{S}^{\bar{\alpha }}} \sum _{n=1}^{N-2}(\kappa _n)^{-\bar{\alpha }} - \frac{1}{\bar{\alpha }} - \frac{(N-1) h}{2 \bar{S}}, \end{aligned}$$
(62)

and

$$\begin{aligned} \bar{z} = \frac{(N-1) h}{\bar{S}}. \end{aligned}$$
(63)

\(\varvec{\blacktriangleright }\) Parameter \(\varvec{\phi , x_0, y_0, h}\): Let \(\xi ^{\check{\varTheta }}_n\), \(n = 0, \dots , N-1\), be the discrete curve computed as in (37) with \(\check{\varTheta } = (0, 0, h, 0, \bar{z}, \bar{s}_{0}, \bar{\alpha })\). Then, its turning angle is \(\theta _{\xi ^{\bar{\alpha }}}(\bar{z}n + \bar{s}_0)\); hence, following Step 3, we obtain

$$\begin{aligned} \bar{\phi } = \frac{1}{N-1} \sum _{n=0}^{N-2} (\theta _n - \theta _{\xi ^{\bar{\alpha }}}(\bar{z}n + \bar{s}_0)), \end{aligned}$$
(64)

and

$$\begin{aligned} \begin{pmatrix} \bar{x}_0\\ \bar{y}_0 \end{pmatrix} = \frac{1}{N} \sum _{n=0}^{N-1} \left( \gamma _n - \xi ^{\check{\varTheta }}_n\right) . \end{aligned}$$
(65)

Finally, we set \(\bar{h} = h\).

As a first test for this algorithm, we used synthetic data: discrete curves with constant step size based on Bézier curves. These curves were split in segments with sign preserving monotonic curvature. Then, we faired each segment to an LAC, using the previous algorithm to compute the initial guess. Some examples are shown in Fig. 2. In the next section we apply this method to real data.

Fig. 2
figure 2

Examples of discrete curves approximated by LAC. Black curves are the input curves, blue curves are the first guesses obtained from our algorithm and the red curves are the final outputs of the IPOPT program

3.2 Application

Fig. 3
figure 3

Top: 3D model (STL data). Bottom: Position of sampled curves, obtained from the interception of the 3D model and vertical planes (Software: Rhino 6). The black lines represent the intercepting planes, and the red lines, in the highlighted area, represent the resulting curves. From the center to the bottom, curves are labelled as ps_1, ps_2, ps_3, ps_4 and ps_5

In order to test the fairing algorithm shown in the previous section, we characterize some simple profile lines of a model-car roof (Toyota Prius). A 3D model was obtained by measuring a model-car with a 3D laser scanner (Hexagon 8330-7, measurement accuracy of 0.078 mm). The 3D model was stored in STL (Standard Triangle/Tessellation Language) format, which encodes the geometry of the object in a triangular mesh. Using Rhinoceros 6, a computer-aided design software, we intercepted the 3D model with vertical planes, see Fig. 3. Finally, we projected the space curves into the plane and processed the discrete point to obtain a planar discrete curve with constant step size. We observed that the curvature of the keylines is highly irregular, as a product of the measuring technique employed. To reduce the noise, we proceeded as follows: Let the curve \(\gamma _n \in \mathbb {R}^{2}\), \(n = 0, \dots , N-1\) with a constant step size \(h > 0\), be the raw data; then:

0. Let \(\check{N} = 3\).

1. For \(\check{N} < N\), apply the Ramer–Douglas–Peucker algorithm to \(\gamma _n\), to obtain a new curve \(\check{\gamma }_n\), \(n = 0, \dots , \check{N}-1\), such that \(\check{\gamma }_0 = \gamma _{0}\) and \(\check{\gamma }_{\check{N} -1} = \gamma _{N-1}\).

2. Construct a cubic spline curve \(\gamma _{\textrm{cs}}(t)\), \(t \in [0, L]\), using \(\check{\gamma }_n\), \(n = 0, \dots , \check{N}-1\), as the control points; hence, \(\gamma _{\textrm{cs}}(0) = \gamma _0\) and \(\gamma _{\textrm{cs}}(L) = \gamma _{N-1}\).

3. Construct a discrete curve \(\bar{\gamma }_n\), \(n = 0, \dots , N-1\) with step size h, by sampling the cubic spline \(\gamma _{\textrm{cs}}(t_n)\) in a appropriate manner: Choose \(t_n\) such that \(\left\Vert \gamma _{\textrm{cs}}(t_{n+1}) - \gamma _{\textrm{cs}}(t_n)\right\Vert = h\) and \(\bar{\gamma }_n = \gamma _{\textrm{cs}}(t_n)\), \(n = 0, \dots , \check{N}-1\).

4. If the residual R is greater than a prescribed error \(\eta\),

$$\begin{aligned} R = \frac{1}{L^2} \sum _{n=0}^{N-1}\left\Vert \bar{\gamma }_n - \gamma _n\right\Vert h > \eta , \end{aligned}$$
(66)

repeat from step 1, with a greater value of \(\check{N}\). Otherwise, the process ends.

Fig. 4
figure 4

Input curves without smoothing. Left column: Each curve represent a different section of the car’s roof. Black lines are raw data and red lines are the smoothen data (the input curves after noise reduction). Left column: raw and smoothen curves in the plane, practically overlapping with each other. Middle column: Curvature plot vs arc length for their corresponding input curves, where the blue line is a reference for the constant \(\kappa = 0\). Right column: same as the middle column, with a close-up on the smoothen data

In our case, we used \(\eta = 10^{-3}\), and we observed that this produces a smoother plot for the curvature, see Fig. 4. Hence, we use \(\bar{\gamma }_{n}\), instead of \(\gamma _n\), as the input curve for the approximation algorithm. The admissible set U for the parameters \(\varTheta\), as defined in (42), was too broad and unexpected jumps in the value of the parameters produced unrealistic outputs. To keep the optimization relatively close to the initial guess, we decided to constrain the admissible set to \(\bar{U}_{0.1}\), defined by

$$\begin{aligned} \bar{U}_{0.1} := U \cap \left\{ \varTheta \in \mathbb {R}^{7} : \left| \varTheta _i - \bar{\varTheta }_{i}\right| < 0.1\bar{\varTheta }_{i}\right\} , \end{aligned}$$
(67)

where \(\bar{\varTheta }\) is the initial guess for the IPOPT method. In this way, \(\bar{U}_{0.1}\) constrain the final result to be in a \(10\%\) range of the initial guess. Final results are presented in Fig. 5. We note that the parameters that we obtained provide a good fit of the input curve. We can observe that, despite the curves being similar in shape to each other, the values of the parameter \(\alpha\) have big variations. However, the final result is still a good fit, after finding the remaining parameters. Let us note that, this algorithm allows us to input the parameter \(\alpha\) by hand (or by replacing (60) by an alternative expression or algorithm) and then we can continue with the next steps without any further change. The fact that we still obtained a good fit is attributed to the input curve having a soft varying curvature. We conclude that the method proposed has a good performance; however, further analysis on the recovery of the parameter \(\alpha\) is required.

Fig. 5
figure 5

Discrete curves approximated by LAC. Each curve represents a different section of half of the car roof, taken at 100 mm apart. Black lines: input curves. Red lines: LAC output

4 Concluding remarks

In the present work we briefly reviewed the notion of log-aesthetic curve, and showed how the family of LAC with a given parameter \(\alpha\) can be described as segments of a basic LAC after applying the similarity transformations and shift of the arc length parameter (Proposition 1). This characterization constitutes a key ingredient that allowed us to provide an algorithmic way to recover the parameters \(\alpha\), S, \(s_0\), \(\phi\), and \((x_0, y_0)\), that uniquely identify a given LAC segment. This method was later used to obtain the initial input for the gradient descent-like method used to approximate a general planar curve segment by an LAC, where the input was regarded as a sequence of points and the output expressed in terms of a smooth LAC, as shown in (51). Although the fairing process involves one single LAC segment, which has a strictly monotonic radius of curvature, it is possible to approximate non-monotonic varying curvature curves if they resemble a spiral segment (by having no inflection points, for example). As noted in [17], there are some cases in which an LAC cannot be drawn. In this regard, we expect good performance of our algorithm if the input curve fits a drawable region as studied in [17]. Regarding the applications, we expect that this algorithm will be used as a tool to characterize existing objects, which is particularly useful in reverse engineering. Moreover, because the LAC is regarded as having aesthetically pleasing shape, there exists an increasing interest from the industry to have algorithms like the ones presented in this work that can be used in computer-aided design softwares.

We note that, our algorithm could extend the one proposed in [11], where only the estimation of \(\alpha\) is considered. In this way, the ideas presented in this work can be used with the data points resulting from the log-aesthetic filter. In future works, further studies in the method employed to find the parameter \(\alpha\) will be considered, in order to characterize a given design by a concrete value of \(\alpha\).