Next Article in Journal
Spatio-Temporal Gradient Enhanced Surrogate Modeling Strategies
Next Article in Special Issue
Simulation of a Thermal Recuperative Incinerator of VOCs with a Special Focus on the Heat Exchanger
Previous Article in Journal
Fourier Image Analysis of Multiphase Interfaces to Quantify Primary Atomization
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A Computational Method with Maple for Finding the Maximum Curvature of a Bézier-Spline Curve

1
Korteweg-de Vries Institute for Mathematics, University of Amsterdam, Science Park 105-107, 3rd Floor (Entrance via Nikhef), 1098 XG Amsterdam, The Netherlands
2
Department of Mathematics, College of Natural Sciences, Cantho University, 3/2 Street, Cantho City 900000, Vietnam
*
Author to whom correspondence should be addressed.
Math. Comput. Appl. 2023, 28(2), 56; https://doi.org/10.3390/mca28020056
Submission received: 3 March 2023 / Revised: 30 March 2023 / Accepted: 3 April 2023 / Published: 8 April 2023

Abstract

:
In this paper, we propose two Maple procedures and some related utilities to determine the maximum curvature of a cubic Bézier-spline curve that interpolates an ordered set of points in R 2 or R 3 . The procedures are designed from closed-form formulas for such open and closed curves.

1. Introduction

We recall here the definition of curvature of a smooth curve. This is a fundamental concept in differential geometry that has been studied deeply in applied mathematics, engineering, and computer graphics. The problem of finding the curvature extremum has been investigated by many authors. We can point out some of their results on establishing necessary and sufficient conditions for the regularity of offset curves or tubular surfaces, designing various types of aesthetic curves from constrained conditions, representing and modifying curves to adapt principles of interpolation and animation, etc. In the following, we give a short description of the method for solving this problem and its limitations.
If r : [ a , b ] R 3 is the position vector of a smooth curve L , then the point r ( t ) of L at t [ a , b ] is written as a 3-tuple ( x ( t ) , y ( t ) , z ( t ) ) , or a column vector x ( t ) , y ( t ) , z ( t ) = ( x ( t ) , y ( t ) , z ( t ) ) T when used in a matrix expression; hence r ( t ) T is the row matrix x ( t ) y ( t ) z ( t ) . The image of r or the map r itself is called a parametrization of L . Along L , we consider the coordinates of the Frenet frame { T ^ , N ^ , B ^ } whose origin is located at points of L . From differential geometry and calculus (see [1,2]), we know that
T ^ = v v , B ^ = v × a v × a , N ^ = B ^ × T ^ ,
where v ( t ) = r ( t ) = ( x ( t ) , y ( t ) , z ( t ) ) T and a ( t ) = r ( t ) = ( x ( t ) , y ( t ) , z ( t ) ) T are usually called the velocity vector and the acceleration vector of L at t (or at r ( t ) ).
Let r = r ( t ) = ( x ( t ) , y ( t ) , z ( t ) ) T be a parametrization of a smooth space curve L with a = r C ( [ a , b ] ) . Then, the curvature of L at t is given by
κ = v × a v 3 ,
where v = v ( t ) = r ( t ) , a = a ( t ) = r ( t ) , and v = v ( t ) . Under this assumption, we usually find the maximum value of κ ( t ) on [ a , b ] by choosing the largest value of κ at the points where κ ( t ) = 0 . However, how to solve the equation κ ( t ) = 0 exactly or approximately? In general, we cannot do it. Moreover, apart from this, the expression for κ ( t ) is complicated! Let us take K = κ 2 and write it out in the components of v × a . This gives
K = ( y z z y ) 2 + ( z x x z ) 2 + ( x y y x ) 2 [ ( x ) 2 + ( y ) 2 + ( z ) 2 ] 3 .
On the other hand, if r = r ( s ) is the parametrization of L by the arc length s, then from the relation T ^ ( s ) = κ ( s ) N ^ ( s ) we obtain
T ^ ( s ) = κ ( s ) N ^ ( s ) + κ ( s ) N ^ ( s ) .
This gives a simple expression for κ ( s ) :
T ^ ( s ) · N ^ ( s ) = κ ( s ) .
However, we again encounter another hard problem: how to convert a parametrization of a smooth space curve L by a general parameter t into the parametrization by the arc length s. In general, this is impossible.
To overcome those obstacles, many researchers restricted their attention to the class of Bézier curves and their variants. Recently, the papers related to maximizing or minimizing the curvature of these curves provided a lot of theoretical results and useful algorithms, as well as practical tools. We highlight some representative papers with a brief note. Ref. [3] presents a unique design on a piecewise quadratic Bézier curve that interpolates its local maximum curvature points that are also its control points. Ref. [4], adopted from [3], proposes new methods to modify local curvature at the interpolation points by taking basis functions of higher degree. Ref. [5] provides conditions for the curvature of a quadratic rational Bézier curve to be monotone or to have a local minimum and maximum. Ref. [6] establishes conditions for Bézier plane curves generated by a matrix to have monotone curvature. Ref. [7] also establishes conditions for Bézier curves to have monotone curvature, based on control points of the position vector of the curve and its derivatives. Ref. [8] treats typical Bézier plane curves with one curvature extremum that can be easily calculated, which can help to divide the curve into two typical curves with monotone curvature.
Traditionally, the papers noted above and many others paid much attention to control points and polygons. Actually, these objects have direct effects on the shape of the curves, so they have been modified in order to obtain a curve with properties needed in design applications. However, we have some changes in mind when relating this widespread trend to our result in [9]. The formula in [9] (Theorem 3.1) can be seen as a way of approximation by interpolation with Bézier-spline curves. Therefore, we prefer to place emphasis on interpolated points. These points can be chosen in a way to design curves in R 2 or R 3 with desired shapes or can be taken from special partitions of the parameter interval of a smooth curve with given parametrization to approximate its curvature extremum.
Now, we go back to our main purpose: making a Maple procedure to compute the maximum value κ max of the curvature. We restrict our attention to Bézier-spline curves. This objective is based on the power of Maple on symbolic computation and on solving polynomial equations of high degree and on the explicit piecewise cubic parametrization of these special curves.
The present paper is organized as follows. In Section 2, we construct the Maple procedures to represent Bézier-spline space curves for both open and closed curves. In Section 3, we propose a pseudo-algorithm for computing κ max , then we provide the full code of the procedures corresponding to the algorithm. In Section 4, we discuss some modifications to obtain procedures to represent Bézier-spline plane curves and to compute their maximum curvature. In Section 5, we give some concluding remarks.

2. Bézier-Spline Space Curves with Maple Parametrization

In this section, we consider a Bézier-spline curve, which is obtained from a closed-form solution to the inverse problem, which interpolates an ordered set of points s 0 , s 1 , …, s n , given in [9]. Such a plane curve can be obviously extended to a space curve C given by a piecewise cubic function f of C 2 ( [ 0 , n ] ) . According to the construction of such curves in [9], we present here a more convenient way to derive their parametrization.
First, f ( t ) is composed of the cubic functions f k given by
f k ( t ) = ( 1 t ) 3 s k 1 + 3 t ( 1 t ) 2 p k 1 + 3 t 2 ( 1 t ) q k + t 3 s k ,
where k = 1 , , n and t [ 0 , 1 ] , and f k is the parametrization of the cubic Bézier curve C k with the control points s k 1 , p k 1 , q k , and s k . These points satisfy the known relations
p k 1 = 2 3 b k 1 + 1 3 b k , q k = 1 3 b k 1 + 2 3 b k ,
and
s k = q k + p k 2 .
On the other hand, from [9] (Theorem 3.1), the points b k , s k , k = 0 , , n , are now in R 3 with b 0 = s 0 and b n = s n , and for k = 1 , , n 1 , we have
b k = β n 1 k β n 1 ( 1 ) k s 0 + 6 j = 1 k 1 ( 1 ) k j β j 1 s j + β k 1 β n 1 6 j = k n 1 ( 1 ) j k β n 1 j s j + ( 1 ) n k s n ,
where β k ( k = 0 , , n 1 ) is evaluated by the formula
β k = 2 k m = 0 k / 2 k + 1 k 2 m ( 3 / 4 ) m .
Finally, we can give a simple process to obtain a so-called relaxed, uniform B-spline space curve  C that interpolates an ordered set of points s 0 , s 1 , …, s n (see [10]). The parametrization f of C is a piecewise cubic function on [ 0 , n ] whose components f k , k = 1 , , n , derived from (2) and (3), can be now given by
f k ( t ) = ( k t ) 3 s k 1 + ( t k + 1 ) ( k t ) 2 ( 2 b k 1 + b k ) + ( t k + 1 ) 2 ( k t ) ( b k 1 + 2 b k ) + ( t k + 1 ) 3 s k ,
where t [ k 1 , k ] , and the b k are obtained from (5) for k = 1 , , n 1 , and b 0 = s 0 and b n = s n . Since f 1 ( 0 ) = f n ( n ) = 0 , the curvatures of C at t = 0 and t = n are both zero and we call C a relaxed Bézier-spline space curve.
We are interested in the implementation of the above parametrization by a Maple procedure. We list here some Maple commands that will appear in our procedures. They are all very important and frequently used in graphic and computation programming: args, nargs, op, nops, ERROR, RETURN, convert, evalf, diff, expand, floor, for, fsolve, map, max, min, piecewise, plot, plot3d, proc, seq, solve, unapply, and while; in addition, LinearAlgebra and plots are the great packages containing many procedures for specific purposes. A declaration to create a function, e.g., f, such as f:=x->F(x) or f:=unapply(F(x),x) (sub-procedures in F(x) are evaluated first), where F(x) is an expression or a list of expressions in x, is a very useful and convenient tool. In addition, the conditional structures if-then-else and if-then-elif-else are indispensable in branch programming, whereas the type “list” is a flexible ordered arrangement of operands (or components, elements) inside the square brackets [, ]. See [11,12] and Maple help pages in each session to know more details about meaning, syntax, and usage of these commands, structures, and types. The implementation of some specific task by calling a procedure name together with appropriate arguments is usually said to be a calling sequence. As a convention, we choose type list for elements of R 2 or R 3 .
Now, let us make a procedure to compute f ( t ) on [ 0 , n ] from (5)–(7), with b 0 = s 0 and b n = s n . It takes S = { s 0 , s 1 , , s n } as its input and gives f ( t ) as its output in the form of [ F ( t ) , G ( t ) , H ( t ) ] such that F , G , H are the piecewise functions in t on [ 0 , n ] . This procedure is called BScurve3d and its full code is given in the following.
BScurve3d
BScurve3d:=proc(Lst::list(list(realcons)))
local n,S,b,B,f,F,G,H,j,k;
n:=nops(Lst)-1:
for k from 0 to n do
S[k]:=Lst[k+1]:
end do:
for j from 0 to n-1 do
 B[j]:=2^j*add(binomial(j+1,j-2*m)*(3/4)^m,m=0..floor(j/2)):
end do:
for k from 1 to n-1 do
 b[k]:=(B[n-1-k]/B[n-1])*((-1)^k*S[0]+6*add((-1)^(k-j)*B[j-1]*S[j],j=1..k-1))
    +(B[k-1]/B[n-1])*((-1)^(n-k)*S[n]+6*add((-1)^(j-k)*B[n-1-j]*S[j],j=k..n-1)):
end do:
b[0]:=S[0]:
b[n]:=S[n]:
for k from 1 to n do
 f[k]:=unapply(expand((k-t)^3*S[k-1]+(t-k+1)*(k-t)^2*(2*b[k-1]+b[k])
    +(t-k+1)^2*(k-t)*(b[k-1]+2*b[k])+(t-k+1)^3*S[k]),t):
end do:
F:=t->piecewise(-1<=t and t<1,f[1](t)[1],
    seq([(k-1)<=t and t<k,f[k](t)[1]][],k=2..n-1),(n-1)<=t and t<n+1,f[n](t)[1]):
G:=t->piecewise(-1<=t and t<1,f[1](t)[2],
    seq([(k-1)<=t and t<k,f[k](t)[2]][],k=2..n-1),(n-1)<=t and t<n+1,f[n](t)[2]):
H:=t->piecewise(-1<=t and t<1,f[1](t)[3],
    seq([(k-1)<=t and t<k,f[k](t)[3]][],k=2..n-1),(n-1)<=t and t<n+1,f[n](t)[3]):
RETURN(unapply([F(t),G(t),H(t)],t));
end proc:
To declare a finite sequence of indexed expressions, we can use the operator [ ] to extract the contents of a list. For example, the command [ 1 , 2 , 3 ][ ] results in 1 , 2 , 3 , and the declaration of the sequence
1 t and t < 2 , f 2 ( t ) , 2 t and t < 3 , f 3 ( t ) , , n 2 t   and t < n 1 , f n 1 ( t )
can be written as: seq([k-1<=t and t<k,f[k](t)][],k=2..n-1). We have used this declaration in BScurve3d.
If we have an ordered set of ( n + 1 ) distinct points in R 3 that are declared in Maple as a list of lists
S : = [ [ a 0 , b 0 , c 0 ] , [ a 1 , b 1 , c 1 ] , , [ a n , b n , c n ] ] ,
then we can obtain the position vector of the Bézier−spline curve C that interpolates these points by calling f:=BScurve3d(S).The plot of C can be made by the procedure spacecurve in the plots package with the command
plots [ spacecurve ] ( f ( t ) , t = 0 n , opts ) ;
The ‘opts’ means plotting options. To implement these steps, for instance, we set
L : = [ [ 2 , 5 , 1 ] , [ 0 , 1 , 0 ] , [ 3 , 1 , 2 ] , [ 1 , 2 , 3 ] , [ 5 , 2 , 1 ] , [ 2 , 4 , 5 ] , [ 0 , 1 , 7 ] , [ 6 , 3 , 2 ] ]
and f : = BScurve 3 d ( L ) . Then, the plot of the Bézier-spline curve C that interpolates L is given by the calling sequence
plots [ spacecurve ] ( f ( t ) , t   =   0 . . 7 , opts ) ;
Figure 1 shows the curve C and the points of L. We take one more example of interpolating an ordered set of points on a given space curve to see how well a Bézier-spline curve fits this curve. Let L 1 be a curve whose parametrization is r ( t ) = ( t cos t , 0.8 t sin t , t cos t sin t ) T , t [ 2.4 , 5 ] , with the declaration
r : = t > [ t * cos ( t ) , ( 0 . 8 ) * t * sin ( t ) , t * cos ( t ) sin ( t ) ] :
Consider a partition of [ 2.4 , 5 ] by the points t 0 : = 2.4 , t 1 : = 1.2 , t 2 : = 0.0 , t 3 : = 1.4 , t 4 : = 2.7 , t 5 : = 3.8 , t 6 : = 5.0 , and set
L 1 : = [ r ( t 0 ) , r ( t 1 ) , , r ( t 6 ) ] :
The curve L 1 and its approximation by a Bézier-spline curve C 1 are also given in Figure 1.
We will make some changes to obtain a so-called closed, uniform B-spline space curve  C that interpolates an ordered set of points s 0 , s 1 , …, s n , with s n = s 0 (see [10]). We call such a curve a closed Bézier-spline space curve. In this case, we choose appropriate settings to have again the relations (3) and (4) at the common point. The first setting should be b n = b 0 . Then, C is still composed of the cubic Bézier curves C k , k = 1 , , n , as above. Specifically, at the interpolated point s n = s 0 , (4) becomes
s 0 = p 0 + q n 2 ,
where we have from (3) that
p 0 = 2 3 b 0 + 1 3 b 1 , q n = 1 3 b n 1 + 2 3 b n = 1 3 b n 1 + 2 3 b 0 .
Now, from (8) and (9), we get the last setting
b 0 = 1 4 ( 6 s 0 b n 1 b 1 ) .
It is easy to have another Maple procedure, say BScurve3dC, for representing a closed Bézier-spline space curve C from the dataset { s 0 , s 1 , , s n } with s n = s 0 , and the settings (10) and b n = b 0 . From the above discussion, the parametrization f of C has the components f k given by (7), and we can check that
f 1 ( 0 ) = f n ( n ) = 3 s 0 + 2 b 0 + b 1 , f 1 ( 0 ) = f n ( n ) = 6 ( s 0 b 0 ) .
Therefore, f is in C 2 ( [ 0 , n ] ) again and C 1 , C n have the same curvature at their common point.
Let us take some examples on using BScurve3dC. As the steps to display closed Bézier-spline space curves are the same as for BScurve3d, we just give the graphical results of these examples. Note that the initial and terminal points of the input list for BScurve3dC have to be the same. Let L be the list
L : = [ [ 0 , 3 , 1 ] , [ 1 , 2 , 2 ] , [ 2 , 0 , 5 ] , [ 2 , 4 , 3 ] , [ 1 , 2 , 4 ] , [ 6 , 1 , 0 ] , [ 0 , 3 , 1 ] ] .
The display of the closed Bézier-spline curve C L that interpolates L is given in Figure 2. Let r be the parametrization of a closed space curve L called a trefoil knot (see [1] (p. 897)) with
r ( t ) : = [ ( 1 + 0.3 cos ( 3 t ) ) cos ( 2 t ) , ( 1 + 0.3 cos ( 3 t ) ) sin ( 2 t ) , 0.35 sin ( 3 t ) ] ( t [ 0 , 2 π ] ) .
The endpoints of L coincide with the point [ 1.3 , 0 , 0 ] . Let T be a set of points on L such that
T : = [ [ 1.3 , 0 , 0 ] , r ( 0.5 ) , r ( 1.2 ) , r ( 1.8 ) , r ( 2.5 ) , r ( 3.2 ) , r ( 3.9 ) , r ( 4.5 ) , r ( 5.1 ) , r ( 5.8 ) , [ 1.3 , 0 , 0 ] ] .
In Figure 2, we also give the display of L together with its approximation C T that interpolates T.

3. Computation of the Maximum Curvature of a Bézier-Spline Curve

Let C be a Bézier-spline curve that interpolates an ordered set T of points s 0 , s 1 , …, s n in R 3 . Then r ( t ) , the position vector of C , is a piecewise cubic function of C 2 ( [ 0 , n ] ) , given by its components f k ( t ) in (7).
Avoiding the square root function, we have from (1):
K : = κ 2 = v × a 2 v 6 = ( v × a ) · ( v × a ) ( v · v ) 3 .
Then, we have that   
K = [ ( v × a ) · ( v × a ) ] ( v · v ) 3 [ ( v × a ) · ( v × a ) ] 3 ( v · v ) 2 2 ( v · v ) ( v · v ) 6 = 2 [ ( v × a ) · ( v × a ) ] ( v · v ) 6 [ ( v × a ) · ( v × a ) ] ( v · a ) ( v · v ) 4 .
As κ attains its maximum value on [ 0 , n ] only at solutions of the equation K = 0 or
( v · v ) [ ( v × a ) · ( v × a ) ] 3 [ ( v × a ) · ( v × a ) ] ( v · a ) = 0
in the intervals ( i 1 , i ) and at their endpoints i 1 , i , with i = 1 , , n , we can find κ max on [ 0 , n ] by the procedure MaxCurvature3d. However, at first, we present the procedure in the form of a pseudo-code algorithm. It would be easy to translate statements in such algorithms into Maple codes or other programming languages. Moreover, our discussion on how to use appropriate commands for a specific purpose will give a clear description of our procedures. In addition, we sometimes use built-in Maple procedures in those algorithms with their most simple form for convenience and simplicity.
Note that the left-hand side of (11) is a polynomial of degree at most 7. Letting Q be such a polynomial (in one variable, say, t), we will use a powerful tool of Maple to find numerically all the zeros of Q in a given interval. That is the procedure fsolve and it has been called in Algorithm 1 by the command: fsolve(Q,t, α β ). The output of this calling is a sequence of all real zeros of Q in [ α , β ] . Moreover, the expressions of dot and cross products are given by the great package of Maple: LinearAlgebra. We also select points in [ 0 , n ] at which κ attains its maximum value. Thus, the output of Algorithm 1 consists of κ max and the set κ 1 ( κ max ) in [ 0 , n ] . Now, for relaxed Bézier-spline curves, we give the full code of MaxCurvature3d at the end of this section.
Algorithm 1: Finding the maximum curvature of a Bézier-spline curve
Input: 
a set T of ( n + 1 ) points in R 3 ;
Output: 
The maximum curvature κ max of the Bézier-spline curve interpolating T;
1:
S p : = { } ;
2:
for i = 1 ndo
3:
    v : = f i ( t ) , a : = f i ( t )     // f i from BScurve3d;
4:
    Q : = the left - hand side of ( ) ;
5:
    P : = { fsolve ( Q,t,i-1 .. i ) } // Solving (11) for t [ i 1 , i ] ;
6:
    S p : = S p P ;
7:
    S : = { F i ( t ) : t P } { F i ( i 1 ) , F i ( i ) } // F i : = t κ ( t ) = v × a / v 3 , v : = v ;
8:
    m i : = max S ;
9:
end for
10:
κ max : = max { m 1 , , m n } ;
11:
M : = S p { 0 , 1 , , n } ; T p : = F 1 ( κ max ) M // F : = t κ ( t ) on [ 0 , n ] , F = F i on [ i 1 , i ] ;
12:
return  κ max and T p ;
MaxCurvature3d
MaxCurvature3d:=proc(L::list(list(realcons)))
local a,ad,A,AD,m,n,S,b,B,f,H,E,F,G,R,k,i,j,v,V,M,Kmax,N,P,Q,Sp,Tp,Tpoint;
n:=nops(L)-1:
for k from 0 to n do
S[k]:=L[k+1]:
end do:
for j from 0 to n-1 do
 B[j]:=2^j*add(binomial(j+1,j-2*m)*(3/4)^m,m=0..floor(j/2)):
end do:
for k from 1 to n-1 do
 b[k]:=(B[n-1-k]/B[n-1])*((-1)^k*S[0]+6*add((-1)^(k-j)*B[j-1]*S[j],j=1..k-1))
    +(B[k-1]/B[n-1])*((-1)^(n-k)*S[n]+6*add((-1)^(j-k)*B[n-1-j]*S[j],j=k..n-1)):
end do:
b[0]:=S[0]:
b[n]:=S[n]:
for k from 1 to n do
 f[k]:=unapply(expand((k-t)^3*S[k-1]+(t-k+1)*(k-t)^2*(2*b[k-1]+b[k])
    +(t-k+1)^2*(k-t)*(b[k-1]+2*b[k])+(t-k+1)^3*S[k]),t):
end do:
Sp:={}:
for i from 1 to n do
 v:=unapply(diff(f[i](t),t),t):
 a:=unapply(diff(f[i](t),t$2),t):
 ad:=unapply(diff(f[i](t),t$3),t):
 V:=convert(v(t),Vector):
 A:=convert(a(t),Vector):
 AD:=convert(ad(t),Vector):
 M:=expand(LinearAlgebra[DotProduct](V,V,conjugate=false)):
 N:=expand(LinearAlgebra[DotProduct](V,A,conjugate=false)):
 G:=map(expand,LinearAlgebra[CrossProduct](V,A)):
 H:=LinearAlgebra[CrossProduct](V,AD):
 E:=expand(LinearAlgebra[DotProduct](G,H,conjugate=false)):
 R:=expand(LinearAlgebra[DotProduct](G,G,conjugate=false)):
 Q:=expand(M*E-3*R*N):
 F[i]:=unapply(sqrt(abs(R))/abs(M)^(3/2),t):
 P:={fsolve(Q,t,i-1..i)}:
 m[i]:=max(seq(F[i](P[j]),j=1..nops(P)),F[i](i-1),F[i](i)):
 Sp:=Sp union P:
end do:
Kmax:=max(seq(m[j],j=1..n)):
Tpoint:={}:
for i from 1 to n do
 if (abs(F[i](i-1)-Kmax)=0) or (abs(F[i](i-1)-Kmax)=0.) then
  Tpoint:= Tpoint union {i-1}:
 elif (abs(F[i](i)-Kmax)=0) or (abs(F[i](i)-Kmax)=0.) then
  Tpoint:= Tpoint union {i}:
 end if:
end do:
if nops(Sp)=0 then
 RETURN(Kmax,Tpoint);
end if:
for j from 1 to nops(Sp) do
 if (floor(Sp[j])=n) then
  if (abs(F[n](Sp[j])-Kmax)=0 or abs(F[n](Sp[j])-Kmax)=0.) then
   Tpoint:= Tpoint union {n}:
  end if:
 elif (abs(F[floor(Sp[j])+1](Sp[j])-Kmax)=0 or
              abs(F[floor(Sp[j])+1](Sp[j])-Kmax)=0.) then
  Tpoint:= Tpoint union {Sp[j]}:
 end if:
end do:
RETURN(Kmax,Tpoint);
end proc:
Here we give an explanation of how to determine the set κ 1 ( κ max ) = { t [ 0 , n ] : κ ( t ) = κ max } . We first check whether i ( { 0 , 1 , , n } ) belongs to this set, then we check the same for all solutions of the equation Q = 0 . In addition, when we need the value f ( t ) for a point t [ 0 , n ] , we should take an appropriate component f k of f ; if t = n , then we take k = n , else we take k = t + 1 , since t t < t + 1 .
We use MaxCurvature3d to determine κ max in the examples whose graphical results are given in Figure 1. From the lists L and L 1 in these examples, the calling sequences MaxCurvature3d(L) and MaxCurvature3d( L 1 ) result in
11.87724489 , { 2.913967861 } and 3.135008280 , { 2 } ,
respectively. If the parametrization of C 1 is h , then
f ( 2.913967861 ) = [ 1.06704678 , 2.13642213 , 2.94912425 ] , h ( 2 ) = [ 0.8322936730 , 1.454875883 , 1.741591100 ]
are the maximum curvature points on the curves C and C 1 , respectively.
The new version of MaxCurvature3d for closed Bézier-spline curves, say, MaxCurvature3dC, can be derived easily from Algorithm 1 with the modification “ f i from BScurve3dC”. Then, we use MaxCurvature3dC to find κ max of C L displayed in Figure 2 and we obtain the result
1.652746390 , { 1.979287163 } .
Let g be the parametrization of C L . The point
g ( 1.979287163 ) = [ 2.02583824 , 0.094336298 , 4.99371046 ]
is given in Figure 3 and this maximum point of curvature of C L is very close to the interpolated point [ 2 , 0 , 5 ] .
To avoid a comparison error between fractions and decimal numbers, we may use the decimal point ‘.’ for at least one component of the points in the list argument of MaxCurvature3d. Note that the result of fsolve only contains decimal numbers, so it will give us ‘ 2 . ’, for instance, if it contains the integer ‘2’. To cover this case, we add a condition such as ‘ A B = 0 . ’ in the definition of MaxCurvature3d, and it should be sometimes ‘ | A B | < 10 m ’ with some positive integer m when we need to obtain an expected result.

4. Remarks on the Two-Dimensional Case

For a relaxed Bézier-spline plane curve L that interpolates a dataset M of points s 0 , s 1 , …, s n in R 2 , we have already a procedure to obtain its position vector f ( t ) . That is just removing the lines H:=t->⋯ and modifying the lines RETURN(t->[F(t),G(t),H(t)]) to RETURN(t->[F(t),G(t)]) in BScurve3d, and the remaining part is for BScurve2d, the Maple parametrization of L . Maple provides the plot procedure to display plane curves with their parametrization [ x ( t ) , y ( t ) ] , t [ a , b ] , by the declaration
plot ( [ ( t ) , y ( t ) , t   =   a b ] , opts ) ;
Accordingly, we first set f : = BScurve 2 d (M), then we call
plot ( [ op ( f ( t ) ) , t   =   0 n ] , opts ) ; or plot ( [ f ( t ) [ ] , t   =   0 n ] , opts ) ;
to display L . Similarly, we get BScurve2dC, the new version of BScurve2d for closed Bézier−spline plane curves, from BScurve3dC.
MaxCurvature3d can be modified to use only sets of points in R 2 and we call its new version MaxCurvature2d. Let L be a smooth plane curve with parametrization r . From the formula κ ( s ) = T ^ ( s ) · N ^ ( s ) with arc length parameter s, we can write
κ = T ^ v · N ^ = 1 v 1 v v + 1 v a · N ^ = 1 v 2 a · ( J T ^ ) = a · u v 3
for a general parameter t, where
v = r , v = v , u = J v , a = v , J = 0 1 1 0 .
We also consider K : = κ 2 = ( a · u ) 2 / ( v · v ) 3 and derive the following equation from K = 0 :
( v · v ) ( a · u ) ( a · u ) 3 ( a · u ) 2 ( v · a ) = 0 .
This equation has the same role as (11), so we can make a new version of MaxCurvature3d, say, MaxCurvature2d, following the steps in Algorithm 1 with some modification: there is no cross product in this version. The expression of the local variable Q in the definition of MaxCurvature2d is given by the left-hand side of (12). Note that the function F i in the pseudo-code algorithm of MaxCurvature2d is now
F i : = | a · u | v 3 .
In the definition of MaxCurvature2d, the matrix J is declared at right above Sp:={} by
J : = Matrix ( 2 , 2 , [ 0 , 1 , 1 , 0 ] ) :
and, then, we set U:=J.V inside the for loop at right below.
We give two more examples on getting the maximum curvature of a relaxed Bézier-spline plane curve and its maximum curvature points. Let M be the list
M : = [ [ 0.5 , 1 ] , [ 0 , 2 ] , [ 0.8 , 3 ] , [ 1.7 , 2.25 ] , [ 2.5 , 1.8 ] , [ 3.5 , 2.2 ] , [ 3.2 , 2.8 ] ]
and C be the Bézier-spline curve that interpolates M. Then, we obtain the parametrization of C by setting
f : = BScurve 2 d ( M ) .
On the other hand, the calling sequence MaxCurvature2d(M) gives us the result
5.011177204 , { 5.168088495 } .
Thus, the maximum curvature of C is κ max = 5.011177204 and this value is attained at the point f ( 5.168088495 ) = [ 3.53273441 , 2.298980995 ] .
Let L be a curve with the parametrization r : t [ 3 sin t , t cos ( 3 t ) ] , t [ 1 , 2 ] , and let
t 0 : = 1 , t 1 : = 0.6 , t 2 : = 0.2 , t 3 : = 0.2 , t 4 : = 0.6 , t 5 : = 0.9 , t 6 : = 1.3 , t 7 : = 1.7 , t 8 : = 2
be a partition of [ 1 , 2 ] . We set N : = [ r ( t 0 ) , r ( t 1 ) , r ( t 2 ) , , r ( t 8 ) ] . Letting C 1 be the Bézier-spline curve that interpolates N, we get its parametrization
h : = BScurve 2 d ( N ) .
Then, we derive
7.637332459 , { 5.720743580 }
from the calling sequence MaxCurvature2d(N). It follows that C 1 attains the maximum curvature κ max = 7.637332459 at the point h ( 5.720743580 ) = [ 2.76963535 , 1.07851249 ] .
The results from the two examples above are given in Figure 4.
The next examples are dealing with closed Bézier-spline curves. The datasets A and B in the first two examples are chosen to be symmetric to an axis, namely
A : = [ [ 3 , 1 ] , [ 5 , 3 ] , [ 4 , 4 ] , [ 3 , 3 ] , [ 2 , 4 ] , [ 1 , 3 ] , [ 3 , 1 ] ] ; B : = [ [ 1 , 4 ] , [ 0.6 , 2 ] , [ 2 , 0.4 ] , [ 3.4 , 1 ] , [ 2.6 , 2.8 ] , [ 2.2 , 2.4 ] , [ 4 , 1.6 ] , [ 4.6 , 3 ] , [ 3 , 4.4 ] , [ 1 , 4 ] ] .
The curves C A and C B that interpolate A and B, respectively, are given in Figure 5. The shapes of C A and C B can already be seen if we first display the interpolated points on the plane.
In the last two examples, we compute the maximum curvature of two closed Bézier-spline curves and show the maximum curvature points on these curves. The results are given in Figure 6. The interpolated points (on the right) in Figure 6 are chosen on the ellipse x 2 / 9 + y 2 / 4 = 1 (depicted in cyan).
We sometimes want to compute the curvature of a Bézier-spline curve at a p [ 0 , n ] , so we should have a tool to do that. Algorithm 2 can be used to make such a tool.
Algorithm 2: Finding the curvature of a Bézier-spline curve at its given point
Input: 
a set T of ( n + 1 ) points in R 2 , a point p [ 0 , n ] ;
Output: 
The curvature κ at p of the Bézier-spline curve interpolating T;
1:
if p = n then
2:
    i : = n ;
3:
else
4:
    i : = p + 1 ;
5:
end if
6:
v : = f i ( t ) , a : = f i ( t )     // f i from BScurve2d or BScurve2dC;
7:
u : = J v     // J = 0 1 1 0 ;
8:
F : = | a · u | / v 3     // v : = v , F : t κ ( t ) ;
9;
return  F ( p ) ;
It is easy to derive the Maple procedure from Algorithm 2 that we call Curvature2d or Curvature2dC, depending on whether f i is from BScurve2d or from BScurve2dC. Similarly, the extension of this procedure for the three-dimensional case can be obtained with the curvature function from Algorithm 1.

5. Conclusions

Our procedures may also be convenient tools for non-Maple users to estimate the maximum curvature of parametric smooth curves and to approximate a curve from its interpolated points by a Bézier-spline curve, as similarly done in [13,14,15,16]. They could be used for doing calculations to establish conditions for non-singularity of tubular surfaces and offset curves associated to a Bézier-spline curve, according to the issues profoundly presented in [17,18]. Moreover, our parametrization derived from the closed-form solution to a linear system for the interpolation problem would be better than those derived from the existing direct or iterative methods to solve the system, as noted in [19,20].

Author Contributions

H.P. constructed the parametrization of Bézier-spline curves and the algorithms. L.P.Q. wrote the Maple procedures. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Acknowledgments

The authors want to thank the referees for their careful reading and their valuable corrections and suggestions. They also want to thank the Maplesoft experts for their great work in developing Maple, a powerful and user-friendly product.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Adams, R.A.; Essex, C. Calculus: A Complete Course, 9th ed.; Pearson Canada Inc.: Ontario, ON, Canada, 2018. [Google Scholar]
  2. Montiel, S.; Ros, A. Curves and Surfaces, 2th ed. In Graduate Studies in Mathematics; American Mathematical Society: Rhode Island, RI, USA, 2009; Volume 69. [Google Scholar]
  3. Yan, Z.; Schiller, S.; Wilensky, G.; Carr, N.; Schaefer, S. κ-Curves: Interpolation at local maximum curvature. ACM Trans. Graph. 2017, 36, 129. [Google Scholar] [CrossRef]
  4. Miura, K.T.; Gobithaasan, R.U.; Salvi, P.; Wang, D.; Sekine, T.; Usuki, S.; Inoguchi, J.; Kajiwara, K. εκ-Curves: Controlled local curvature extrema. Vis. Comput. 2022, 38, 2723–2738. [Google Scholar] [CrossRef]
  5. Ahn, Y.J.; Kim, H.O. Curvatures of the Quadratic Rational Bézier Curves. Comput. Math. Appl. 1998, 36, 71–83. [Google Scholar] [CrossRef] [Green Version]
  6. Cantón, A.; Fernández-Jambrina, L.; Vázquez-Gallo, M.J. Curvature of planar aesthetic curves. J. Comput. Appl. Math. 1998, 381, 113042. [Google Scholar] [CrossRef]
  7. Wang, A.; Zhao, G.; Hou, F. Constructing Bézier curves with monotone curvature. J. Comput. Appl. Math. 2019, 355, 1–10. [Google Scholar] [CrossRef]
  8. He, C.; Zhao, G.; Wang, A.; Li, S.; Cai, Z. Planar Typical Bézier Curves with a Single Curvature Extremum. Mathematics 2021, 9, 2148. [Google Scholar] [CrossRef]
  9. Quan, L.P.; Nhan, T.A. A Closed-Form Solution to the Inverse Problem in Interpolation by a Bézier-Spline Curve. Arab. J. Math. 2020, 9, 155–165. [Google Scholar] [CrossRef] [Green Version]
  10. Michael, S. Cubic B-Splines Using PSTricks (A Guiding Document for the Package Pst-Bspline (Version 1.62 2016-04-21)). Available online: https://ctan.org/pkg/pst-bspline (accessed on 30 January 2023).
  11. Monagan, M.B.; Geddes, K.O.; Heal, K.M.; Labahn, G.; Vorkoetter, S.M.; McCarron, J.; DeMarco, P. MAPLE Introductory Programming Guide; Waterloo MAPLE Inc.: Ontario, ON, Canada, 2008. [Google Scholar]
  12. Monagan, M.B.; Geddes, K.O.; Heal, K.M.; Labahn, G.; Vorkoetter, S.M.; McCarron, J.; DeMarco, P. MAPLE Advanced Programming Guide; Waterloo MAPLE Inc.: Ontario, ON, Canada, 2008. [Google Scholar]
  13. Chen, X.D.; Ma, W.; Paul, J.C. Cubic B-spline curve approximation by curve unclamping. Comput.-Aided Des. 2010, 42, 523–534. [Google Scholar] [CrossRef] [Green Version]
  14. Cheng, F.; Barsky, B.A. Interproximation: Interpolation and approximation using cubic spline curves. Comput.-Aided Des. 1991, 23, 700–706. [Google Scholar] [CrossRef]
  15. Hoschek, J. Spline approximation of offset curves. Comput. Aided Geom. Des. 1988, 5, 33–40. [Google Scholar] [CrossRef]
  16. Kozak, J.; Krajnc, M. Geometric interpolation by planar cubic polynomial curves. Comput. Aided Geom. Des. 2007, 24, 67–78. [Google Scholar] [CrossRef] [Green Version]
  17. Maekawa, T.; Patrikalakis, N.M. Computation of singularities and intersections of offsets of planar curves. Comput. Aided Geom. Des. 1990, 7, 101–127. [Google Scholar] [CrossRef]
  18. Maekawa, T.; Patrikalakis, N.M.; Sakkalis, T.; Yu, G. Analysis and applications of pipe surfaces. Comput. Aided Geom. Des. 1998, 15, 437–458. [Google Scholar] [CrossRef]
  19. Farin, G. Curves and Surfaces for Computer Aided Geometric Design: A Practical Guide, 5th ed.; Morgan Kaufmann: California, CA, USA, 2001. [Google Scholar]
  20. Hartmut, P.; Wolfgang, B.; Marco, P. Bézier and B-Spline Techniques; Springer: Berlin/Heidelberg, Germany; New York, NY, USA, 2002. [Google Scholar]
Figure 1. On the (left): The Bézier-spline curve C interpolates the list L. On the (right): The Bézier-spline curve C 1 (in red) interpolates the data points r ( t 0 ) , r ( t 1 ) , …, r ( t 6 ) on the curve L 1 (in cyan). opts: axes=boxed, numpoints=2000, thickness=2, scaling=constrained.
Figure 1. On the (left): The Bézier-spline curve C interpolates the list L. On the (right): The Bézier-spline curve C 1 (in red) interpolates the data points r ( t 0 ) , r ( t 1 ) , …, r ( t 6 ) on the curve L 1 (in cyan). opts: axes=boxed, numpoints=2000, thickness=2, scaling=constrained.
Mca 28 00056 g001
Figure 2. On the (left): The closed Bézier-spline curve C L interpolates the list L. On the (right): The closed Bézier-spline curve C T (in red) interpolates the set T of points on the curve L (in cyan).
Figure 2. On the (left): The closed Bézier-spline curve C L interpolates the list L. On the (right): The closed Bézier-spline curve C T (in red) interpolates the set T of points on the curve L (in cyan).
Mca 28 00056 g002
Figure 3. The value of κ max = 1.652746390 is attained at the blue point on C L .
Figure 3. The value of κ max = 1.652746390 is attained at the blue point on C L .
Mca 28 00056 g003
Figure 4. On the (left): The Bézier-spline curve C interpolates the dataset M. On the (right): The Bézier-spline curve C 1 (in red) interpolates the set N of points on L (in cyan). The red points A and B are the points of maximum curvature of C and C 1 , respectively.
Figure 4. On the (left): The Bézier-spline curve C interpolates the dataset M. On the (right): The Bézier-spline curve C 1 (in red) interpolates the set N of points on L (in cyan). The red points A and B are the points of maximum curvature of C and C 1 , respectively.
Mca 28 00056 g004
Figure 5. The Bézier-spline curves C A (left) and C B (right).
Figure 5. The Bézier-spline curves C A (left) and C B (right).
Mca 28 00056 g005
Figure 6. On the (left): κ max = 5.045872521 . On the (right): κ max = 0.9591183657 . These maximum curvatures are attained at the red points.
Figure 6. On the (left): κ max = 5.045872521 . On the (right): κ max = 0.9591183657 . These maximum curvatures are attained at the red points.
Mca 28 00056 g006
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Pijls, H.; Quan, L.P. A Computational Method with Maple for Finding the Maximum Curvature of a Bézier-Spline Curve. Math. Comput. Appl. 2023, 28, 56. https://doi.org/10.3390/mca28020056

AMA Style

Pijls H, Quan LP. A Computational Method with Maple for Finding the Maximum Curvature of a Bézier-Spline Curve. Mathematical and Computational Applications. 2023; 28(2):56. https://doi.org/10.3390/mca28020056

Chicago/Turabian Style

Pijls, Henk, and Le Phuong Quan. 2023. "A Computational Method with Maple for Finding the Maximum Curvature of a Bézier-Spline Curve" Mathematical and Computational Applications 28, no. 2: 56. https://doi.org/10.3390/mca28020056

APA Style

Pijls, H., & Quan, L. P. (2023). A Computational Method with Maple for Finding the Maximum Curvature of a Bézier-Spline Curve. Mathematical and Computational Applications, 28(2), 56. https://doi.org/10.3390/mca28020056

Article Metrics

Back to TopTop