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 PA = (xA, yA)T and PB = (xB, yB)T with the corresponding unit tangent vectors TA = (cosθA, sinθA)T and TB = (cosθB, sinθB)T, where the three vectors TA, TB, and PAPB = PB − PA are not all parallel. G1 Hermite interpolation is used to find a fairing curve that joins PA and PB on the condition that the tangent vectors at the endpoints match TA and TB, 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 PA = (xA, yA)T and PB = (xB, yB)T, and their associated unit tangent vectors TA = (cosθA, sinθA)T and TB = (cosθB, sinθB)T, where θA and θB are orientation angles with multiple values. When θA or θB are increased or reduced by 2m ⋅ π(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 ‖V0‖ 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 ‖V0‖ > 0. Eliminating ‖V0‖ 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 PA = (xA, yA)T at the origin and the second endpoint PB = (xB, yB)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 PA as the origin and PAPB 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 sk > 0 such that sk ⋅ cos θ ≥ 1 (sk ≥ 1) or sk ≤ cos θ (0 < sk < 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 PA = (xA, yA, 1)T, PB = (xB, yB, 1)T, TA = (cosθA, sinθA, 0)T, and TB = (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 TA = (cosθA, sinθA, 0)T, TB = (cosθB, sinθB, 0)T, and PAPB = (xB − xA, yB − yA, 0)T. This analysis does not consider the degenerate case in which all three vectors are parallel.
Let −π ≤ φA ≤ π denote the angle from vector TA to vector PAPB (Fig. 4). The sign of φA indicates the direction and φA > 0 indicates that TA is on the right side of PAPB. Similarly, −π ≤ φB ≤ π denotes the angle from vector PAPB to vector TB.
Considering the signs of these two angles, one can divide all potential constraints into two cases as follows:
Case I φA ⋅ φB > 0, meaning TA and TB are located on opposite sides of PAPB (Fig. 5).
Case II φA ⋅ φB < 0, meaning that TA and TB are located on the same side of PAPB (Fig. 6).
Because θA and θB can be increased or decreased by 2m ⋅ π (m ∈ Z) while keeping the unit tangent vectors TA and TB 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 TA TB and the vector PAPB.
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 ‖V0‖ > 0 are the variables to be determined. The value of k can be increased from two to a set maximum value kmax. 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 TA and TB.
Once k and Δθ are determined, one can use an optimization process to obtain s and ‖V0‖ 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, ‖V0‖ > 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, TA, TB, and PAPB. 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 ‖V0‖ > 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 TA and TB unchanged, or even by exchanging the labels of PA and PB or TA and TB. These methods are discussed in detail in Results and discussion Section.