This section presents the G1 interpolation algorithm based on typical curves. First, the G1 interpolation problem based on typical curves is introduced briefly. The given endpoint-orientation pairs are then divided into two cases, and a novel algorithm for constructing a typical curve under the given boundary constraints is proposed.

### G1 Hermite interpolation problem

In many interpolation problems, not only positions, but also the corresponding derivative values or higher-order derivatives at endpoints are required to be equal, which is called Hermite interpolation. If the interpolation curve matches the given unit tangent vectors at the two endpoints, it is a two-point G1 Hermite interpolation. Additionally, if the given curvatures at the two endpoints are also matched, it is called two-point G2 Hermite interpolation [1].

Although G2 interpolation has better continuity, it also introduces stronger constraints for the interpolation curve and the high-order continuity at endpoints is sometimes difficult to guarantee. In some applications, G1 interpolation is preferable to G2 interpolation when considering cost effectiveness, such as curve completion or path planning using Euler spirals [1]. Consider two different points *P*_{A} = (*x*_{A}, *y*_{A})^{T} and *P*_{B} = (*x*_{B}, *y*_{B})^{T} with the corresponding unit tangent vectors *T*_{A} = (cos*θ*_{A}, sin*θ*_{A})^{T} and *T*_{B} = (cos*θ*_{B}, sin*θ*_{B})^{T}, where the three vectors *T*_{A}, *T*_{B}, and *P*_{A}*P*_{B} = *P*_{B} − *P*_{A} are not all parallel. G1 Hermite interpolation is used to find a fairing curve that joins *P*_{A} and *P*_{B} on the condition that the tangent vectors at the endpoints match *T*_{A} and *T*_{B}, respectively.

Walton et al. [1, 34] proposed an improved Euler spiral algorithm for shape completion. However, the Euler spiral is not compatible with NURBS. Therefore, the paper proposes a more intuitive algorithm for the G1 interpolation problem based on a typical curve, which is easier to construct.

### G1 interpolation problem based on a typical curve

#### Proposition 1

Consider the positions of two endpoints *P*_{A} = (*x*_{A}, *y*_{A})^{T} and *P*_{B} = (*x*_{B}, *y*_{B})^{T}, and their associated unit tangent vectors *T*_{A} = (cos*θ*_{A}, sin*θ*_{A})^{T} and *T*_{B} = (cos*θ*_{B}, sin*θ*_{B})^{T}, where *θ*_{A} and *θ*_{B} are orientation angles with multiple values. When *θ*_{A} or *θ*_{B} are increased or reduced by 2*m* ⋅ π(*m* ∈ Z), the unit tangent vector remains unchanged. The sufficient condition for the existence of a *k*-degree typical curve matching the boundary constraints is that the following equation has real number solutions satisfying *s* ⋅ cos *θ* ≥ 1 (*s* ≥ 1) or *s* ≤ cos *θ* (0 < *s* < 1):

$$ \left\{\begin{array}{l}{x}_A+\sum \limits_{i=1}^k\left\Vert {\boldsymbol{V}}_0\right\Vert \cdot {s}^{i-1}\cdot \cos \left[{\theta}_A+\left(i-1\right)\cdot \theta \right]={x}_B\\ {}{y}_A+\sum \limits_{i=1}^k\left\Vert {\boldsymbol{V}}_0\right\Vert \cdot {s}^{i-1}\cdot \sin \left[{\theta}_A+\left(i-1\right)\cdot \theta \right]={y}_B\end{array}\right. $$

(4)

where ‖*V*_{0}‖ and *s* are free variables with positive values and *θ* = (*θ*_{B} − *θ*_{A})/(*k* − 1).

#### Proof

When the degree *k* is fixed, *θ* = (*θ*_{B} − *θ*_{A})/(*k* − 1) is the rotation angle of the typical curve. If there are real number solutions such that *s* ⋅ cos *θ* ≥ 1 (*s* ≥ 1) or *s* ≤ cos *θ* (0 < *s* < 1), which are the sufficient and necessary conditions for the monotonic curvature of a typical curve, the curvature of the Bézier curve constructed using this method must be monotonous.

Now we are going to analyze the sufficient conditions for the existence of solutions for Eq. (4). Considering the degree *k* as a free variable in Eq. (4), there are three free variables *k* ∈ *Z*^{+}, *s* > 0, and ‖*V*_{0}‖ > 0. Eliminating ‖*V*_{0}‖ yields

$$ \sum \limits_{i=1}^k{s}^{i-1}\cdot \left[\left({y}_B-{y}_A\right)\cdot \cos \left({\theta}_A+\left(i-1\right)\cdot \theta \right)-\left({x}_B-{x}_A\right)\cdot \sin \left({\theta}_A+\left(i-1\right)\cdot \theta \right)\right]=0 $$

(5)

Because Bézier curves are invariant under affine transformations, one can place the first endpoint *P*_{A} = (*x*_{A}, *y*_{A})^{T} at the origin and the second endpoint *P*_{B} = (*x*_{B}, *y*_{B})^{T} at the positive half of the *x* axis using a pre-transformation, which leads to *x*'_{A} = 0, *y*'_{A} = 0, *x*'_{B} > 0 and *y*'_{B} = 0 (Fig. 3). Then, Eq. (5) is converted into

$$ \sum \limits_{i=1}^k{s}^{i-1}\cdot \left[-x{\hbox{'}}_B\cdot \sin \left(\theta {\hbox{'}}_A+\left(i-1\right)\cdot \theta \right)\right]=0 $$

(6)

The superscript ' indicates a new variable obtained from the pre-transformation. The pre-transformation can be used to construct a new local coordinate system. Equation (6) is a polynomial of degree *k* and one can infer the number of positive roots from the Descartes rule of signs [35]. The number of sign changes in the coefficients is equal to the number of sign changes in sin[*θ*'_{A} + (*i* − 1) ⋅ *θ*], *i* = 1, …, *k*. Therefore, a sufficient condition to guarantee that Eq. (6) has at least one positive solution is that sin[*θ*'_{A} + (*i* − 1) ⋅ *θ*] changes signs an odd number of times, meaning that after pre-transformation, the sign of the sine angle for all control edges changes an odd number of times.

#### Angle sign change condition

Consider *P*_{A} as the origin and *P*_{A}*P*_{B} as the positive direction of the *x* axis. In this new local coordinate system, the function sin*α* (*θ*'_{A} ≤ *α* ≤ *θ*'_{B}) only changes its sign an odd number of times.

#### Proposition 2

If the ASC condition is satisfied, then one can always find an appropriate degree *k* such that the solutions of Eq. (4) or (6) satisfy Eq. (3).

#### Proof

Because the affine transformation does not change the solution of the curve, Eqs. (4, 6) have the same solution and the ASC condition guarantees a positive solution for Eq. (4). When the degree *k* gradually increases in Eq. (6) and the rotation angle \( \theta =\frac{\theta_B-{\theta}_A}{k-1}\to 0 \) cos*θ* → 1, there is an *s*_{k} > 0 such that *s*_{k} ⋅ cos *θ* ≥ 1 (*s*_{k} ≥ 1) or *s*_{k} ≤ cos *θ* (0 < *s*_{k} < 1), meaning the solutions of Eq. (4) or (6) satisfy Eq. (3).

#### Corollary 1

For Eq. (4) or (6), if there is a typical curve satisfying the constraints when *k* = *m* ≥ 2, then there are also typical curve solutions when *k* ≥ *m* + 1. This means that the G1 interpolation problem has multiple solutions consisting of typical curves and the limit of the solutions increases *θ* → 0 with an increase in the degree *k*.

The ASC condition is a sufficient condition for the positive solution of Eq. (6). Even if the ASC condition is not satisfied, Eq. (4) or (6) may still have a positive root. In contrast, the ASC condition cannot guarantee solutions satisfying Eq. (3) under a fixed degree.

### Two cases of G1 constraints

For convenience of expression, homogeneous coordinates will be used to represent points and vectors for the remainder of this paper. For a 2D point (*x*, *y*)^{T}, its homogeneous coordinate can be written as (*ωx*, *ωy*, *ω*)^{T}, where *ω* ≠ 0. This study used *ω* = 1. For a 2D vector (*x*, *y*)^{T}, the homogeneous coordinate can only be expressed as (*x*, *y*, 0)^{T}.

For an arbitrary *P*_{A} = (*x*_{A}, *y*_{A}, 1)^{T}, *P*_{B} = (*x*_{B}, *y*_{B}, 1)^{T}, *T*_{A} = (cos*θ*_{A}, sin*θ*_{A}, 0)^{T}, and *T*_{B} = (cos*θ*_{B}, sin*θ*_{B}, 0)^{T}, one can divide the G1 constraints into two cases according to the relationship between the relative positions of the three vectors *T*_{A} = (cos*θ*_{A}, sin*θ*_{A}, 0)^{T}, *T*_{B} = (cos*θ*_{B}, sin*θ*_{B}, 0)^{T}, and *P*_{A}*P*_{B} = (*x*_{B} − *x*_{A}, *y*_{B} − *y*_{A}, 0)^{T}. This analysis does not consider the degenerate case in which all three vectors are parallel.

Let −π ≤ *φ*_{A} ≤ π denote the angle from vector *T*_{A} to vector *P*_{A}*P*_{B} (Fig. 4). The sign of *φ*_{A} indicates the direction and *φ*_{A} > 0 indicates that *T*_{A} is on the right side of *P*_{A}*P*_{B}. Similarly, −π ≤ *φ*_{B} ≤ π denotes the angle from vector *P*_{A}*P*_{B} to vector *T*_{B}.

Considering the signs of these two angles, one can divide all potential constraints into two cases as follows:

**Case I** *φ*_{A} ⋅ *φ*_{B} > 0, meaning *T*_{A} and *T*_{B} are located on opposite sides of *P*_{A}*P*_{B} (Fig. 5).

**Case II** *φ*_{A} ⋅ *φ*_{B} < 0, meaning that *T*_{A} and *T*_{B} are located on the same side of *P*_{A}*P*_{B} (Fig. 6).

Because *θ*_{A} and *θ*_{B} can be increased or decreased by 2*m* ⋅ π (*m* ∈ Z) while keeping the unit tangent vectors *T*_{A} and *T*_{B} unchanged, the rotation angle *θ* = (*θ*_{B} − *θ*_{A})/(*k* − 1) can be either positive or negative, and the labeling of the given endpoint-orientation pairs can be swapped. Based on these features, there are different constructions for typical curves under the given conditions. This paper presents a practical method for choosing a suitable curve based on the position relationship between the unit tangent vectors *T*_{A} *T*_{B} and the vector *P*_{A}*P*_{B}.

### Proposed algorithm

Given two endpoint-orientation pairs, the G1 interpolation algorithm is used to find the optimal solution to Eq. (4), where the degree *k* ≥ 2 is an integral and the rotation angle *θ* may have multiple values. *s* > 0 and ‖*V*_{0}‖ > 0 are the variables to be determined. The value of *k* can be increased from two to a set maximum value *k*_{max}. For a fixed *k*, one must determine the value of *θ* = (*θ*_{B} − *θ*_{A})/(*k* − 1), which is equivalent to determining Δ*θ* = *θ*_{B} − *θ*_{A}. The proposed algorithm provides a rule for determining Δ*θ* automatically. For case I, let Δ*θ* = *φ*_{A} + *φ*_{B}. For case II, let Δ*θ* = *φ*_{A} + *φ*_{B} − sign(*φ*_{A}) ⋅ 2π, where sign(*φ*_{A}) is the sign of *φ*_{A}. In this manner, the algorithm can find the typical curve with the lowest degree and smallest total angle between *T*_{A} and *T*_{B}.

Once *k* and Δ*θ* are determined, one can use an optimization process to obtain *s* and ‖*V*_{0}‖ such that

$$ {\displaystyle \begin{array}{l}f\left(s,\left\Vert {\boldsymbol{V}}_0\right\Vert \right)={\left\{{x}_A+\sum \limits_{i=1}^k\left\Vert {\boldsymbol{V}}_0\right\Vert \cdot {s}^{i-1}\cdot \cos \left[{\theta}_A+\left(i-1\right)\cdot \theta \right]-{x}_B\right\}}^2+\\ {}\kern3.75em {\left\{{y}_A+\sum \limits_{i=1}^k\left\Vert {\boldsymbol{V}}_0\right\Vert \cdot {s}^{i-1}\cdot \sin \left[{\theta}_A+\left(i-1\right)\cdot \theta \right]-{y}_B\right\}}^2\end{array}} $$

(7)

becomes zero. If *s* > 0, ‖*V*_{0}‖ > 0, and Eq. (3) is satisfied, then a typical curve segment can be constructed using these values. Otherwise, the steps of the iteration should be repeated by increasing the degree *k*.

The pseudo code for the proposed algorithm is presented in Algorithm 1.

The algorithm first calculates an angle Δ*θ*, which is determined by the position relationship between, *T*_{A}, *T*_{B}, and *P*_{A}*P*_{B}. Then, Eq. (7) is minimized to a value of zero iteratively by the optimization process. This step was implemented using the interior point method, which can find the minimum value of a constrained nonlinear multivariable function. For the obtained *s* > 0 and ‖*V*_{0}‖ > 0, the algorithm checks whether Eq. (3) is satisfied. Once the solutions satisfy Eq. (3), iteration can be stopped and a typical curve can be generated from the obtained data.

The algorithm proposed above avoids outputting multiple solutions by choosing an appropriate rotation angle *θ* = (*θ*_{B} − *θ*_{A})/(*k* − 1), but this does not mean that there is only one typical curve solution under the given constraints. The main principle of the proposed algorithm is to select the minimum rotation angle Δ*θ* = *θ*_{B} − *θ*_{A} under the given conditions and then choose the lowest degree *k* to satisfy the constraints. Additional solutions can be obtained by increasing the value of the degree *k*, modifying the angle value Δ*θ* = *θ*_{B} − *θ*_{A} while leaving the unit tangents *T*_{A} and *T*_{B} unchanged, or even by exchanging the labels of *P*_{A} and *P*_{B} or *T*_{A} and *T*_{B}. These methods are discussed in detail in Results and discussion Section.