Next Article in Journal
Abnormal Monitoring Data Detection Based on Matrix Manipulation and the Cuckoo Search Algorithm
Previous Article in Journal
Improving Oriented Object Detection by Scene Classification and Task-Aligned Focal Loss
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

On Intersections of B-Spline Curves

1
School of Mathematics, Liaoning Normal University, Dalian 116029, China
2
School of Mathematical Sciences, Dalian University of Technology, Dalian 116024, China
3
Delft Institute of Applied Mathematics, Delft University of Technology, 2628 CD Delft, The Netherlands
*
Author to whom correspondence should be addressed.
Mathematics 2024, 12(9), 1344; https://doi.org/10.3390/math12091344
Submission received: 28 March 2024 / Revised: 19 April 2024 / Accepted: 25 April 2024 / Published: 28 April 2024
(This article belongs to the Section Computational and Applied Mathematics)

Abstract

:
Bézier and B-spline curves are foundational tools for curve representation in computer graphics and computer-aided geometric design, with their intersection computation presenting a fundamental challenge in geometric modeling. This study introduces an innovative algorithm that quickly and effectively resolves intersections between Bézier and B-spline curves. The number of intersections between the two input curves within a specified region is initially determined by applying the resultant of a polynomial system and Sturm’s theorem. Subsequently, the potential region of the intersection is established through the utilization of the pseudo-curvature-based subdivision scheme and the bounding box detection technique. The projected Gauss-Newton method is ultimately employed to efficiently converge to the intersection. The robustness and efficiency of the proposed algorithm are demonstrated through numerical experiments, demonstrating a speedup of 3 to 150 times over traditional methods.

1. Introduction

Geometric modeling is a computer-based technology for the representation, manipulation, analysis, and design of solids [1]. Curves/surfaces modeling technology, which originated from shaping the outer appearance of products such as automobiles, ship fuselages, aircraft wings, and other products, is a significant research area in computer-aided design (CAD) and computer-aided geometric design (CAGD). Its applications span a broad spectrum of industrial engineering fields, encompassing CNC tooling, alignment of roads, robot path planning, design of luggage shells, and clearance detection for sheet metal parts, among others [2,3,4,5].
Hoffmann pointed out that computing the intersections of parametric curves and surfaces represents a foundational challenge within the field of CAGD and geometric modeling [6]. The resolution of intersections between curves and surfaces is critical in applications such as Boolean operations on solids [7], surface rendering via ray tracing [8,9], and collision detection [10]. In the process of geometric modeling, intersections play a significant role in determining the shape and structure of the model, so it is important to accurately identify and represent these features to ensure the model is correctly interpreted and manufactured [11,12]. As CAD/CAGD/CAM systems evolve and scientific and technological advancements continue, the computational demands and data volumes required to tackle intersection challenges are rapidly escalating. Therefore, the development of efficient and robust methods to address these challenges has become crucial.
Bézier curves defined by Bernstein basis functions and control points have a simple and intuitive mathematical expression and are easy to calculate [1]. B-spline curves, as an extension of Bézier curves, are a curve representation method renowned for their excellent local control capacity and smoothness. The flexibility to adjust the shape of B-spline curves through manipulation of knot vectors and control points has made them popular in computer graphics for curve and surface modeling, animation, interpolation and shape editing, and font design. With their different characteristics and advantages, Bézier curves and B-spline curves become important tools for representing and manipulating curves in computer graphics, and many scholars have conducted research on the intersection problems of Bézier [13,14] and B-spline curves/surfaces [15,16,17] .
In fact, the problem of curve/curve intersection is somewhat equivalent to finding the roots of polynomials, leading some researchers to tackle these issues concurrently. The Bézier clipping algorithm was first proposed by Sederberg to robustly and quickly calculate not only the intersection points but also the tangent points of two Bézier curves [18]. The convergence rate of the Bézier clipping algorithm was proved to be second-order in [19]. Since then, various improved algorithms based on the Bézier clipping algorithm have been developed to address both polynomial root finding and curve intersection challenges. Based on degree reduction, the quadratic and cubic polynomials were generated to enclose the graph of the polynomial within the interval of interest, respectively, by Bartoň and Jüttler [20] and Liu [21] et al. for computing the all roots of a univariate polynomial equation. Additionally, the cubic clipping was proved to have at least a second-order convergence rate and used to compute the intersections of two Bézier curves [22]. A geometric interval algorithm that can tightly bind a curve/surface or contain a point on a curve/surface was proposed by North [23]. Further advancements were made by Yuan [24], who developed the cubic hybrid clipping method with a fourth-order convergence rate for root finding of univariate polynomial equations. This method was subsequently adapted by Wu and Li to address curve intersection problems [25].
This study focuses on resolving the intricate challenge of identifying all intersection points between Bézier curves and B-spline curves. We introduce a robust and efficient approach for determining the intersections for both Bézier curves and B-spline curves. First, a robust algorithm for determining the number of intersections between two Bézier curves is proposed. The core of this problem lies in the task of determining the roots of a system of bivariate polynomial equations. To this end, the resultants of bivariate polynomials and Sturm’s sequence are employed. Second, a fast computation algorithm based on pseudo-curvature and subdivision is proposed in this paper. While Newton’s iteration is a well-known technique for solving non-linear equations, it is known to encounter difficulties, settling on local solutions in scenarios where multiple solutions exist. To address this, we subdivide the input curves by considering the pseudo-curvature of the curves and the intersection of their bounding boxes. Once segments are deemed to be sufficiently straight, we ensure that any two intersect at most once. Eventually, the Gauss-Newton method is employed to quickly converge on the intersection points. Numerical experiments validate the superior performance of our approach compared to traditional algorithms, achieving a speedup of 3 to 150 times.
The remainder of this paper is structured as follows: Section 2 presents essential definitions of Bézier and B-spline curves, along with Sturm’s theorem. In Section 3, we outline a method for computing the number of intersections between polynomial parametric curves, focusing primarily on Bézier curves within the unit square. Section 4 introduces our proposed subdivision-based method tailored for efficiently computing all intersections between B-spline curves. Section 5 presents numerical experiments assessing the performance of the proposed method. Finally, Section 6 offers concluding remarks summarizing our contributions and suggesting potential avenues for future research.

2. Preliminary

In this section, we commence with a brief overview of the concepts underlying Bézier and B-spline curves. Subsequently, we introduce Sturm’s theorem, an essential tool for isolating the real roots of higher-order polynomial equations.

2.1. Bézier and B-Spline Curves

A degree-n Bézier curve is expressed as
C ( ξ ) = i = 0 n P i B i n ( ξ ) , ξ [ 0 , 1 ] ,
where P i R d ( d = 2 , 3 typically) denote the control points, and B i n ( ξ ) = n i ξ i ( 1 ξ ) n i ( i = 0 , 1 , , n ) are Bernstein basis functions [1]. These curves are characterized by their high degree of smoothness, ease of computation, and the property that they are contained within the convex hull of their control points. Figure 1 illustrates quartic Bernstein basis functions and its associated Bézier curve.
Building on the concept of Bézier curves, B-spline curves offer increased flexibility and local modification capability through the introduction of a knot vector. The knot vector, a non-decreasing sequence denoted as:
Ξ = { ξ 0 , ξ 1 , , ξ n + p + 1 } ,
where ξ i ξ i + 1 for i = 1 , 2 , , n + p serves as the basis for defining B-spline curves [1].
The B-spline basis functions defined over Ξ can be derived recursively by the following de Boor-Cox formula
N i , 0 ( ξ ) = 1 , ξ [ ξ i , ξ i + 1 ) , 0 , otherwise , N i , p ( ξ ) = ξ ξ i ξ i + p ξ i N i , p 1 ( ξ ) + ξ i + p + 1 ξ ξ i + p + 1 ξ i + 1 N i + 1 , p 1 ( ξ ) , p 1 .
Consequently, a B-spline curve of degree p is formulated as the linear combination of its basis functions, N i , p ( ξ ) , for i = 1 , 2 , , n , and the corresponding control points, P i , where P i R d with d = 2 , 3 . Thus, a B-spline curve can be expressed as:
C ( ξ ) = i = 1 n P i N i , p ( ξ ) , ξ [ ξ p , ξ n + 1 ] .
Figure 2 shows quadratic B-spline basis functions defined over the knot vector Ξ = { 0 , 0 , 0 , 0.25 , 0.5 , 0.75 , 0.75 , 1 , 1 , 1 } and its associated B-spline curve.
B-spline basis functions are endowed with essential desirable properties such as non-negativity and partition of unity, which contribute significantly to the stability and manipulability of the curves they define. Therefore, B-spline curves, closely related to these basis functions, exhibit the so-called convex-hull property, ensuring they remain within the convex hull defined by their control points. These features contribute to their widespread application in CAGD and CG for their stability and ease of manipulation. Furthermore, a degree-p Bézier curve can be considered a specific form of a B-spline curve, characterized by a particular knot vector Ξ = { 0 , 0 , , 0 p + 1 , 1 , 1 , , 1 p + 1 } . This connection means that Bézier curves inherit many of the advantageous properties of B-spline curves, enhancing their utility and desirability in various applications.

2.2. Resultant and Sturm’s Theorem

To lay a solid theoretical foundation for the ensuing discussion, this subsection introduces the basic concept of the resultant of two polynomials, the Sturm sequence associated with a polynomial, and Sturm’s theorem.
Definition 1
([26]). Let f 1 ( x ) = i = 0 m a i x i and f 2 ( x ) = i = 0 n b i x i represent two polynomials of degree m and n, respectively. The resultant of f 1 and f 2 , R e s ( f 1 , f 2 ) , is defined by a determinant that encapsulates the coefficients of these polynomials, i.e.,
R e s ( f 1 , f 2 ) = a m a m 1 a 1 a 0 0 0 0 a m a m 1 a 1 a 0 0 0 a m a m 1 a 1 a 0 b n b n 1 b 1 b 0 0 0 0 b n b n 1 b 1 b 0 0 0 b n b n 1 b 1 b 0 row 1 row 2 row n row n + 1 row n + 2 row n + m .
On a natural extension of Definition 1, when considering the resultant of two bivariate polynomials concerning one of the variables, the other variable is treated as a constant. A simple example is given to illustrate below.
Example 1.
Given two bivariate polynomials f 1 ( x , y ) = 5 x 2 6 x y + 5 y 2 16 and f 2 ( x , y ) = 2 x 2 ( 1 + y ) x + y 2 y 4 . The resultant defined by f 1 , f 2 with respect to variable x is
R e s ( f 1 , f 2 ; x ) = 5 6 y 5 y 2 16 0 0 5 6 y 5 y 2 16 2 ( 1 + y ) y 2 y 4 0 0 2 ( 1 + y ) y 2 y 4 ,
which is essentially a polynomial of the variable y.
Consider a polynomial f ( x ) with real coefficients and free of any square factors. The Sturm sequence for f ( x ) is constructed as follows
Sturm ( 0 ) = f ( x ) Sturm ( 1 ) = f ( x ) Sturm ( i ) = rem Sturm ( i 2 ) , Sturm ( i 1 ) , for i = 2 , 3 , , r ,
where rem denotes the polynomial remainder operator. In this sequence, each successive term is the negated remainder from dividing the two preceding terms. The construction of this sequence concludes when a constant term or zero is reached at Sturm ( r ) . The Sturm sequence, denoted as Sturm = { Sturm ( 0 ) , Sturm ( 1 ) , , Sturm ( r ) } , serves as an effective tool for identifying the count of zeros that the polynomial f ( x ) possesses within a given interval.
Consider the sequence Γ = { γ 0 , γ 1 , , γ t } . Denote by p r e ( Γ ) the number of sign-preserving occurrences within Γ . This is quantified by examining each pair of consecutive values, γ i and γ i + 1 . If these values share the same sign, the pair ( γ i , γ i + 1 ) is counted as contributing 1 to p r e ( Γ ) . Notably, a term γ i = 0 is treated as though it possesses the opposite sign of its immediate predecessor γ i 1 [27,28].
Example 2.
Suppose Γ 1 = [ 1 , 2 , 1 , 2 , 1 , 2 ] and Γ 2 = [ 1 , 0 , 1 , 2 , 1 , 2 ] . Then, we have the numbers of sign-preserving occurrences p r e ( Γ 1 ) = 4 and p r e ( Γ 2 ) = 2 .
Integrating the definition of the resultant for two bivariate polynomials with the concept of sign-preserving within a Sturm sequence of a specified polynomial, Sturm’s theorem emerges as a powerful method to ascertain the count of real roots for a bivariate polynomial system within a defined interval.
Theorem 1
([29]). Consider a compact set D = [ x m i n , x m a x ] × [ y m i n , y m a x ] R 2 . Let f 1 ( x , y ) and f 2 ( x , y ) be two bivariate polynomials with the degrees of x as n 1 and n 2 , respectively. Define a polynomial in terms of α by
R E S ( α , α 1 , α 2 ) = R e s ( R e s ( f 1 , g ; x ) , R e s ( f 2 , g ; x ) ; y ) α n ,
where g ( x , y ) = α + ( x α 1 ) ( y α 2 ) and n = n 1 × n 2 .
Let { Sturm ( α , α 1 , α 2 ) } stand for the Sturm sequence of the polynomial R E S ( α , α 1 , α 2 ) of α. Here, N u m _ p r e ( a , b ) represents the count of sign-preserving occurrences in the Sturm sequence { Sturm ( α , α 1 , α 2 ) } when α = 0 , α 1 = a , and α 2 = b . Consequently, the total number of real roots for the system of equations f 1 = f 2 = 0 within the compact set D can be determined by
N u m ( f 1 , f 2 , D ) = 1 2 [ N u m _ p r e ( x m i n , y m i n ) N u m _ p r e ( x m i n , y m a x ) N u m _ p r e ( x m a x , y m i n ) + N u m _ p r e ( x m a x , y m a x ) ] .
Remark 1.
In cases where the first term in a sequence is 0, it is stated that p r e ( [ 0 , 1 ] ) = p r e ( [ 0 , 1 ] ) = 1 / 2 , as detailed in [29]. This convention implies that roots located on the boundaries of a specified compact set D are represented by 1 / 2 in Equation (8). Similarly, roots situated at the vertices of the compact set D are attributed a value of 1 / 4 .
Theorem 1 provides a theoretical foundation for determining the exact number of roots for a pair of bivariate polynomial equations f 1 ( x , y ) = f 2 ( x , y ) = 0 within a specified compact set D . In the subsequent discussion, we will apply Theorem 1 to ascertain the number of intersections between two polynomial parametric curves. This step can be regarded as a preparatory phase, essential for enhancing the precision and reliability of the subsequent calculation of intersections.

3. Determining the Number of Intersections

In this section, we provide a method for counting the number of intersections between two polynomial parametric curves, with an emphasis on Bézier curves within the interval [ 0 , 1 ] × [ 0 , 1 ] for clarity and brevity.
Given two Bézier curves
C A ( ξ ) = i = 0 n P i B i n ( ξ )
and
C B ( η ) = j = 0 m Q j B j m ( η ) ,
where P i = ( x i , y i , z i ) T , Q j = ( x ˜ j , y ˜ j , z ˜ j ) T are their control points. Computing the intersection of C A ( ξ ) and C B ( η ) involves identifying the parameter pair ( ξ , η ) that fulfills the condition C A ( ξ ) C B ( η ) = 0 .
From the partition of the unity property of Bernstein basis functions, we have
C A ( ξ ) C B ( η ) = i = 0 n P i B i n ( ξ ) j = 0 m Q j B j m ( η ) = j = 0 m B j m ( η ) · i = 0 n P i B i n ( ξ ) i = 0 n B i n ( ξ ) · j = 0 m Q j B j m ( η ) = i = 0 n j = 0 m ( P i Q j ) B i n ( ξ ) B j m ( η ) .
To simplify the notation and facilitate computation, let us denote
B n ( ξ ) = B 0 n ( ξ ) , B 1 n ( ξ ) , , B n n ( ξ ) T ,
B m ( η ) = B 0 m ( η ) , B 1 m ( η ) , , B m m ( η ) T ,
Δ i = P i Q 0 , P i Q 1 , , P i Q m T ,
and
R = R 0 , R 1 , , R n T ,
where R i = j = 0 m ( P i Q j ) B j m ( η ) = Δ i T · B m ( η ) .
Therefore, Equation (9) can be expressed in a matrix form as
C A ( ξ ) C B ( η ) = R T · B n ( ξ ) .
Subsequently, according to the relationship between the Bernstein basis functions and power basis functions, we have
B n ( ξ ) = M · ξ ,
where M is the basis transformation matrix and ξ = ( 1 , ξ , ξ 2 , , ξ n ) T is the collection of power basis functions. Therefore, we have
C A ( ξ ) C B ( η ) = x ( ξ , η ) y ( ξ , η ) z ( ξ , η ) = R T · M · ξ .
Recall that computing the intersections between C A ( ξ ) and C B ( η ) is equivalent to solving the roots of C A ( ξ ) C B ( η ) = 0 . That is,
x ( ξ , η ) = 0 y ( ξ , η ) = 0 z ( ξ , η ) = 0 .
Given that Theorem 1 is applicable solely for isolating the real roots of bivariate polynomials, Equation (16) can be equivalently converted into the following form
f 1 ( ξ , η ) = x 2 ( ξ , η ) + y 2 ( ξ , η ) = 0 f 2 ( ξ , η ) = y 2 ( ξ , η ) + z 2 ( ξ , η ) = 0 .
Denote by Δ i 1 and Δ i 2 the first two lines and the last two lines of Δ i , respectively. Similarly, we have
R φ = R 0 φ , R 1 φ , , R n φ T ,
where R i φ = Δ i φ T · B m ( η ) with φ = 1 , 2 . Accordingly, the Equation (17) to compute the intersection of C A ( ξ ) and C B ( η ) can thus be reformulated as follows
f 1 ( ξ , η ) = R 1 M ξ T R 1 M ξ = ξ T M T R 1 T R 1 M ξ , f 2 ( ξ , η ) = R 2 M ξ T R 2 M ξ = ξ T M T ( R 2 ) T R 2 M ξ .
Remark 2.
Referring to Equation (7) from Theorem 1, the computation of the polynomial R E S ( α , α 1 , α 2 ) necessitates initially deriving the resultant of the polynomials f i ( i = 1 , 2 ) and g with respect to the variable ξ, treating η as a constant during this process. Consequently, we reformulate Equation (17) into a quadratic equation in terms of ξ.
Remark 3.
In the case of plane polynomial parametric curves, the approach simplifies significantly. We can directly set f 1 ( ξ , η ) = x ( ξ , η ) and f 2 ( ξ , η ) = y ( ξ , η ) , thereby streamlining the process.
For clearer understanding, we present an algorithm that determines the number of intersections between two Bézier curves based on Theorem 1, followed by an illustrative example in Example 3. Moreover, the proposed algorithm may be naturally applicable to B-spline curves by combining with the Bézier extraction technique (Algorithm 1).
Algorithm 1: Number of intersections between two Bézier curves
Mathematics 12 01344 i001
Example 3.
Let P 0 = ( 0 , 0 ) , P 1 = ( 1 , 1 ) , P 2 = ( 2 , 0 ) and Q 0 = ( 0.5 , 0 ) , Q 1 = ( 1 , 1 ) , Q 2 = ( 0 , 2 ) be the control points of two quadratic Bézier curves C A ( ξ ) and C B ( η ) , as shown in Figure 3, respectively. Thus computing the intersections between C A ( ξ ) and C B ( η ) is equivalent to the roots of the following bivariate polynomials
f 1 ( ξ , η ) = 2 ξ + 3 2 η 2 η 1 2 f 2 ( ξ , η ) = 2 ξ 2 + 2 ξ 2 η .
Now, we propose the detailed procedure for determining the roots of f 1 ( ξ , η ) = f 2 ( ξ , η ) = 0 in [ 0 , 1 ] × [ 0 , 1 ] by Theorem 1.
First, compute N u m _ p r e ( 0 , 0 ) , N u m _ p r e ( 0 , 1 ) , N u m _ p r e ( 1 , 0 ) , and N u m _ p r e ( 1 , 1 ) in Theorem 1, respectively. A comprehensive description of the process for calculating N u m _ p r e ( 0 , 0 ) is shown below, which can also be applied to appraising N u m _ p r e ( 0 , 1 ) , N u m _ p r e ( 1 , 0 ) , and N u m _ p r e ( 1 , 1 ) .
1. 
Let α 1 = 0 , α 2 = 0 , then g ( ξ , η ) = α + ξ η = η ξ + α . Similar to Example 1, we can state that the resultant R e s ( f 1 , g ; ξ ) and R e s ( f 2 , g ; ξ ) in Equation (7) as
R e s ( f 1 , g ; ξ ) = 2 3 2 η 2 η 1 2 η α = 3 2 η 3 + η 2 + 1 2 η + 2 α ,
and
R e s ( f 2 , g ; ξ ) = 2 2 2 η η α 0 0 η α = 2 η 3 2 α η 2 α 2 .
The outer resultant in Equation (7) is computed by
R e s ( R e s ( f 1 , g ; ξ ) , R e s ( f 2 , g ; ξ ) ; η ) = 3 / 2 1 1 / 2 2 α 0 0 0 3 / 2 1 1 / 2 2 α 0 0 0 3 / 2 1 1 / 2 2 α 2 0 2 α 2 α 2 0 0 0 2 0 2 α 2 α 2 0 0 0 2 0 2 α 2 α 2 = 27 α 6 + 126 α 5 + 173 α 4 + 54 α 3 + 3 α 2 ,
and
R E S ( α , 0 , 0 ) = R e s ( R e s ( f 1 , g ; ξ ) , R e s ( f 2 , g ; ξ ) ; η ) α 1 × 2 = 27 α 4 + 126 α 3 + 173 α 2 + 54 α + 3 .
2. 
The Sturm sequence { Sturm ( α , 0 , 0 ) } of R E S ( α , 0 , 0 ) can be obtained by the method of successive division. That is
Sturm ( 0 ) = 0.017341 0.312139 α α 2 0.728324 α 3 0.156069 α 4 , Sturm ( 1 ) = 0.142857 0.915344 α α 2 0.285714 α 3 , Sturm ( 2 ) = 0.211034 α 0.393103 α 2 , Sturm ( 3 ) = 0.056683 + α , Sturm ( 4 ) = 1 .
3. 
By substituting α = 0 into Equation (24), we obtain the sequence Γ = [ 0.017341 , 0.142857 , 0.211034 , 0.056683 , 1 ] . It is observed that N u m _ p r e ( 0 , 0 ) = 3 , corresponding to the sign-preserving of Γ.
Analogously, we find that N u m _ p r e ( 0 , 1 ) = 2 , N u m _ p r e ( 1 , 0 ) = 2 , and N u m _ p r e ( 1 , 1 ) = 3 , respectively. Consequently, according to Equation (8), it is concluded that the Bézier curves P ( ξ ) and Q ( η ) intersect exactly once.

4. A Fast Subdivision-Based Intersection Algorithm

In the realm of geometric modeling and computer graphics, accurately determining the intersections between two parametric curves is a fundamental challenge with numerous applications. This task is particularly demanding due to the need for computational efficiency and high precision. In this section, we propose a novel subdivision-based approach specifically designed to compute all intersections between B-spline curves efficiently.

4.1. Pseudo-Curvature of B-Spline Curves

Central to our intersection algorithm lies an effective subdivision scheme, capitalizing on the curvature characteristics of B-spline curves for more efficient computation. This scheme introduces an effective curvature-based subdivision strategy, boosting computational efficiency and accuracy when identifying intersection points.
Generally, the point-wise curvature at any given parameter ξ along a parametric curve is determined by
κ p ( C ( ξ ) ) = C ( ξ ) × C ( ξ ) C ( ξ ) 3 .
To ascertain the total curvature energy across the curve, one integrates the point-wise curvature as follows:
κ tradition = κ p ( C ( ξ ) ) d ξ .
In practice, the above integration is typically executed using numerical quadrature techniques, such as Simpson’s rule or Gauss-Legendre quadrature.
Although the above traditional methods for calculating the curvature of parametric curves are accurate, they involve intricate calculations that can be computationally expensive. To address this, we introduce the concept of pseudo-curvature, with a particular focus on B-spline curves. This approach seeks to offer a less computationally intensive alternative while maintaining sufficient accuracy for intersection determination tasks.
For a B-spline curve represented as C ( ξ ) = i = 0 n P i N i ( ξ ) , we define its pseudo-curvature as:
κ ( C ) = i = 0 n 1 P i P i + 1 ¯ 2 P 0 P n ¯ 2 ,
where · stands for the Euclidean length of the vector. This formula effectively approximates the bending of the curve, as shown in Figure 4, by considering the relative lengths of segments formed by consecutive control points P i P i + 1 ¯ ( i = 0 , 1 , , n 1 ) in comparison to the segment formed by the first and last control points P 0 P n ¯ .
The principle underlying the pseudo-curvature defined in Equation (27) capitalizes on the convex hull property inherent to B-spline curves, which ensures that the B-spline curve lies entirely within the convex polygon formed by its control points. Leveraging the convex hull property, we ascertain that the bending of the B-spline curve approaches its minimum when the value of the pseudo-curvature in Equation (27) approaches 1.
The pseudo-curvature offers a significant reduction in computational complexity compared to traditional curvature metrics. By leveraging the geometric properties inherent in the control points of B-spline curves, we can obtain a useful approximation of the original curve with far less computational effort.

4.2. Subdivision-Based Potential Intersection Ranges Computation

Central to our methodology is a sophisticated subdivision scheme tailored to the unique characteristics of B-spline curves, which significantly enhances the efficiency and accuracy of intersection point identification. With the aforementioned pseudo-curvature concept established in Section 4.1, we have the essential tools for splitting curves effectively. In this section, we integrate subdivision techniques with bounding box intersection detection to compute potential intersection ranges between B-spline curves efficiently. The algorithmic framework for this process is presented in Algorithm 2.
The algorithm depicted in Algorithm 2 begins by computing the bounding boxes for the input curves. It then proceeds to check for bounding box intersections. If no intersection is detected, the algorithm concludes that the curves themselves cannot intersect, reducing unnecessary computation.
In cases where bounding boxes intersect, the algorithm evaluates the pseudo-curvature of the curves in Equation (27). If the curvature falls below a predefined threshold κ max , indicative of minimal bending, direct intersection checks between curve segments are performed. Conversely, if the curvature exceeds this threshold, suggesting potential complex intersections, the algorithm recursively applies itself to subdivided curve segments, iteratively refining the search space.
This iterative process continues until all potential intersection ranges have been exhaustively examined, ensuring a comprehensive identification of intersection points without omission.
In Algorithm 2, the selection of κ max is critical. Setting it too low may result in excessive subdivision, thereby prolonging computation time. Conversely, setting it too high may risk overlooking complex intersections. Striking the right balance for this parameter is essential to achieving optimal performance. In our numerical experiments, we set the default value of κ max to 1 + 5 × 10 6 .
While bounding boxes provide an initial filter for potential intersections, the precision of intersection detection relies on the subsequent subdivision and direct intersection checks. Maintaining geometric precision throughout the process is crucial. To enhance computational accuracy and efficiency, we employ the projected Gauss-Newton method in the following section.
Algorithm 2: Subdivision-based potential intersection ranges computation
Mathematics 12 01344 i002

4.3. Projected Gauss-Newton Method

Upon obtaining the output from Algorithm 2, we acquire pairs of potential intersection ranges where the curve segments exhibit very limited bending. According to Bézout’s theorem, as these segments closely resemble straight lines (degree-1 curves), only one intersection point is anticipated within each pair. Hence, leveraging Gauss-Newton iteration proves to be an efficient approach for intersection computation. However, it is essential to note that the computed results may extend beyond the parameter ranges of the current segments. To mitigate this issue, we implement the projected Gauss-Newton method, thereby ensuring that the computed intersections remain within the designated segments.
Consider a nonlinear system F ( ξ ) = 0 . The essence of the projected Gauss-Newton method is captured by a two-fold iterative process. Initially, we calculate an intermediate point ξ ˜ k + 1 using the classic Gauss-Newton iteration formula
ξ ˜ k + 1 = ξ k J k F ( ξ k ) ,
where J k = ( A T A ) 1 A T is the Moore-Penrose inverse of the Jacobian matrix of the nonlinear system F at iteration k. The Moore-Penrose inverse J k can be computed using the singular value decomposition (SVD).
Subsequently, we refine our estimate by projecting ξ ˜ k + 1 onto the feasible set D k = [ ξ min k , ξ max k ] × [ η min k , η max k ] , optimizing for proximity to the initial estimate
ξ k + 1 = P ξ D k ξ ˜ k + 1 ,
where P ξ D k denotes the projection operator. In our implementation, we adopt the following projection operator
P ξ D k ( ξ ˜ ) = min max ( ξ ˜ , ξ min k ) , ξ max k , min max η ˜ , η min k , η max k .
This projection ensures our solution remains within the parameter ranges of the curves, an essential consideration for maintaining geometric validity.
In the case of 3D scenarios, our approach to the curve intersection problem involves addressing the following nonlinear system
F ( ξ , η ) = C A ( ξ ) C B ( η ) = x A ( ξ ) x B ( η ) y A ( ξ ) y B ( η ) z A ( ξ ) z B ( η ) = 0 .
The corresponding Jacobian matrix, a 3 × 2 matrix, can be computed as follows:
J ( ξ , η ) = d C A ( ξ ) d ξ d C B ( η ) d η = d x A ( ξ ) d ξ d x B ( η ) d η d y A ( ξ ) d ξ d y B ( η ) d η d z A ( ξ ) d ξ d z B ( η ) d η .
For the 2D case, the nonlinear system becomes
F ( ξ , η ) = C A ( ξ ) C B ( η ) = x A ( ξ ) x B ( η ) y A ( ξ ) y B ( η ) = 0 .
The corresponding Jacobian matrix, a 2 × 2 matrix, is computed by
J ( ξ , η ) = d C A ( ξ ) d ξ d C B ( η ) d η = d x A ( ξ ) d ξ d x B ( η ) d η d y A ( ξ ) d ξ d y B ( η ) d η .
Different from the 3D case, the Moore-Penrose inverse in Equation (28) degenerates into the inverse of the Jacobian matrix (34).
The comprehensive algorithm is presented in Algorithm 3.
Algorithm 3: Projected Gauss-Newton method
Mathematics 12 01344 i003

5. Numerical Experiments

This section presents numerical experiments conducted to evaluate the effectiveness and efficiency of the proposed algorithm across both Bézier curves and B-spline curves. We implemented the algorithm in C++ using Clang-15 compiler and conducted the experiments on a MacBook Pro (14-inch, 2021) equipped with an Apple M1 Pro CPU and 16 GB of RAM. Matlab® 2023a and ParaView (version 5.10.1) were employed for visualization.
In all experiments, the parameter settings were standardized as follows: maximum curvature, κ max , was set to 1 + 5 × 10 6 ; residual tolerance, tol_res, was defined at 1 × 10 5 ; variation tolerance for ξ , denoted as tol ξ , was also set at 1 × 10 5 ; and the limit for the maximum number of iterations, m a x I t e r , was fixed at 20. Computing all the intersections between two Bézier curves is a topic that has received considerable attention in the CAGD community. The Bézier clipping algorithm, as proposed by Sederberg in 1990 [18], stands out for its second-order convergence rate, a finding further supported by Schulz in 2009 [19]. Since then, the algorithm has seen several enhancements aimed at improving its efficiency. Noteworthy among these are the quadratic and cubic clipping methods [20,22], which are based on degree reduction techniques; the geometry interval clipping algorithm [23]; and the cubic hybrid clipping method [25].
For B-spline curves, a prevalent strategy is to first convert them into Bézier segments using the Bézier extraction technique. This transformation allows the application of the previously mentioned clipping methods to each pair of Bézier segments, facilitating the computation of intersections. In this section, we compare our proposed method with these existing intersections computation techniques through detailed analysis. Specifically, different methods are conducted on four examples depicted in Figure 5, which include cubic Bézier curves with two intersections, a quadratic B-spline and a cubic B-spline each with two intersections, and two cubic B-splines with eight intersections, including a scenario where two intersection are notably proximal.
Table 1 presents a comprehensive comparison of the computational efficiency between our proposed method and several established techniques, including Bézier Clipping [18], Quadratic Degree Reduction [20], Cubic Degree Reduction [22], Geometry Interval Clipping [23], and Cubic Hybrid Clipping [25]. The evaluation encompasses a range of scenarios, as depicted in the table and Figure 5, characterized by varying numbers of control points, Bézier segments, and intersections, thereby offering a broad perspective on performance across different curve complexities.
The findings underscore the superior performance of our method, consistently achieving the lowest computation times (highlighted in bold) across all examples. Specifically, in Example 1 (Figure 5a), our method demonstrates a significant efficiency advantage, achieving a computation time of only 114 microseconds, which is substantially lower than the next fastest method, Bézier Clipping, by a factor of 1.84. This trend of outperformance persists across the other examples, with our method maintaining the position of optimal efficiency with the lowest relative times of 1.00 in all cases.
Example 2 (Figure 5b) further illustrates the robustness of our approach, handling complex curves (29 control points, 26/27 Bézier segments, and 2 intersections) with a computation time of merely 167 microseconds, whereas the competing methods exhibit significantly higher times, up to 43.78 times slower in the case of quadratic degree reduction.
In Examples 3 (Figure 5c) and 4 (Figure 5d), which involve an even greater number of intersections and control points, our method continues to exhibit unparalleled efficiency, further evidencing its potential as a superior computational tool for the intersection of Bézier and B-spline curves.
Traditional techniques require computing intersections for each pair of Bézier segments, leading to a computational complexity of O ( # B e z S e g 2 ) , with # B e z S e g denoting the number of Bézier segments. For instance, in Example 3, curve C A comprises 60 Bézier segments, as illustrated in Figure 6, whereas curve C B contains 21 segments. Consequently, the process of determining Bézier intersections must be executed as many as 60 × 21 = 1260 times. As the number of Bézier segments grows—reflecting an increase in the number of inner knot values—the computational demand escalates.
In contrast, our method is engineered to function independently of Bézier curve segmentation. As demonstrated in Figure 7, the computation time of our method remains constant regardless of the increase in Bézier segment count. However, the computation times of the other methods rise linearly with # B e z S e g 2 , which coincides with the theoretical computational complexity analysis. This design choice eliminates the necessity for intersection calculations between segment pairs, thereby significantly reducing computational overhead. This strategic departure from segment-pair dependency not only streamlines the process but also enhances efficiency, providing a robust solution for handling complex curve intersections with greater computational economy.
The comparative analysis not only highlights the computational merits of our proposed method but also underscores the significance of algorithmic efficiency in the realm of geometric computation, especially for applications requiring the rapid processing of complex B-spline curve intersections.
However, it is crucial to highlight that the selection of parameters in the algorithm presented in this paper is heuristic. A larger tolerance will result in the obtained intersection point deviating from the actual position. Conversely, a smaller tolerance will increase the number of iterations, thereby reducing the speed of the solution. The selection of the most suitable parameters is therefore imperative for users, following the specific circumstances of the problem. Furthermore, the subdivision method based on pseudo-curvature is only applicable to parametric curves formed by control points and basis functions.

6. Conclusions

In this paper, we develop a rapid and robust algorithm designed to address the intersection challenges of Bézier and B-spline curves, which are fundamental components in the realms of computer graphics and computer-aided geometric design. By incorporating Sturm’s theorem, we have established a methodical approach to determine the number of intersections within a predetermined region. To handle multiple intersections, a fast subdivision-based algorithm is proposed. The bounding box detection and the definition of pseudo-curvature for curve segmentation further refine the process, enabling the partitioning of curves into segments that closely emulate straight lines. The deployment of the projected Gauss-Newton method facilitates efficient convergence to intersection points, marking a significant advancement over traditional techniques.
For future work, the exploration of efficient and robust algorithms for the surface/surface intersection problem presents a more challenging and interesting frontier.

Author Contributions

Conceptualization, Y.-Y.Y. and Y.J.; methodology, Y.-Y.Y. and Y.J.; software, Y.-Y.Y., X.L. and Y.J.; validation, X.L.; formal analysis, Y.-Y.Y.; investigation, Y.-Y.Y., X.L. and Y.J.; writing—original draft preparation, Y.-Y.Y. and Y.J.; writing—review and editing, Y.-Y.Y., X.L. and Y.J.; visualization, Y.-Y.Y. and Y.J.; project administration, Y.-Y.Y.; funding acquisition, Y.-Y.Y. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the National Natural Science Foundation of China (No. 12301490), the Youth Foundation of Liaoning Provincial Department of Education (No. JYTQN2023262), and the Young Science and technology Talent Foundation of Dalian Science and Technology Bureau (No. 2023RQ088).

Data Availability Statement

The raw data supporting the conclusions of this article will be made available by the authors on request.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Farin, G. Curves and Surfaces for CAGD: A Practical Guide; Morgan Kaufmann Publishers Inc.: San Francisco, CA, USA, 2001. [Google Scholar]
  2. Choi, Y.K.; Wang, W.P.; Liu, Y.; Kim, M. Continuous collision detection for two moving elliptic disks. IEEE Trans. Robot. 2006, 22, 213–224. [Google Scholar] [CrossRef]
  3. Patrikalakis, N. Surface-to-surface intersections. IEEE Comput. Graph. Appl. 1993, 13, 89–95. [Google Scholar] [CrossRef]
  4. Kruppa, K.; Kunkli, R.; Hoffmann, M. A skinning technique for modeling artistic disk B-spline shapes. Comput. Graph. 2023, 115, 96–106. [Google Scholar] [CrossRef]
  5. Yousif, M.A.; Hamasalh, F.K. The fractional non-polynomial spline method: Precision and modeling improvements. Math. Comput. Simul. 2024, 218, 512–525. [Google Scholar] [CrossRef]
  6. Hoffmann, C.M. Geometric and Solid Modeling; Morgan Kaufmann: Burlington, MA, USA, 1989. [Google Scholar]
  7. Wyvill, B.; Kees, V.O. Polygonization of implicit surfaces with constructive solid geometry. Int. J. Shape Model. 1996, 2, 257–274. [Google Scholar] [CrossRef]
  8. Nishita, T.; Sederberg, T.W.; Kakimoto, M. Ray tracing trimmed rational surface patches. In Proceedings of the 17th Annual Conference on Computer Graphics and Interactive Techniques, Dallas, TX, USA, 6–10 August 1990; pp. 337–345. [Google Scholar]
  9. Efremov, A.; Havran, V.; Seidel, H.P. Robust and numerically stable Bézier clipping method for ray tracing NURBS surfaces. In Proceedings of the 21st Spring Conference on Computer Graphics, Budmerice, Slovakia, 12–14 May 2005; pp. 127–135. [Google Scholar]
  10. Lin, M.C.; Gottschalk, S. Collision detection between geometric models: A survey. In Proceedings of the IMA Conference on Mathematics of Surfaces; 1998; Volume 1, pp. 602–608. Available online: https://api.semanticscholar.org/CorpusID:9315916 (accessed on 1 April 2024).
  11. Patrikalakis, N.M.; Maekawa, T. Shape Interrogation for Computer Aided Design and Manufacturing; Springer: Berlin/Heidelberg, Germany, 2002; Volume 15. [Google Scholar]
  12. Ji, Y.; Yu, Y.Y.; Wang, M.Y.; Zhu, C.G. Constructing high-quality planar NURBS parameterization for isogeometric analysis by adjustment control points and weights. J. Comput. Appl. Math. 2021, 396, 113615. [Google Scholar] [CrossRef]
  13. Galligo, A.; Pavone, J.P. Self-intersections of a Bézier bicubic surface. In Proceedings of the International Symposium on Symbolic and Algebraic Computation, Beijing, China, 24–27 July 2005. [Google Scholar]
  14. Yu, Y.Y.; Li, X.; Ji, Y. On self-intersections of cubic Bézier curves. Mathemetics 2024, 12, 882. [Google Scholar] [CrossRef]
  15. Pekerman, D.; Elber, G.; Kim, M.S. Self-intersection detection and elimination in freeform curves and surfaces. Comput.-Aided Des. 2008, 40, 150–159. [Google Scholar] [CrossRef]
  16. Elber, G.; Grandine, T.; Kim, M.S. Surface self-intersection computation via algebraic decomposition. Comput.-Aided Des. 2009, 41, 1060–1066. [Google Scholar] [CrossRef]
  17. Yang, J.Y.; Jia, X.H.; Yan, D.M. Topology Guaranteed B-Spline Surface/Surface Intersection. ACM Trans. Graph. 2023, 42, 1–16. [Google Scholar] [CrossRef]
  18. Sederberg, T.W.; Nishita, T. Curve intersection using Bézier clipping. Comput.-Aided Des. 1990, 22, 538–549. [Google Scholar] [CrossRef]
  19. Schulz, C. Bézier clipping is quadratically convergent. Comput. Aided Geom. Des. 2009, 26, 61–74. [Google Scholar] [CrossRef]
  20. Bartoň, M.; Jüttler, B. Computing roots of polynomials by quadratic clipping. Comput. Aided Geom. Des. 2007, 24, 125–141. [Google Scholar] [CrossRef]
  21. Liu, L.; Zhang, L.; Lin, B.B.; Wang, G.J. Fast approach for computing roots of polynomials using cubic clipping. Comput. Aided Geom. Des. 2009, 26, 547–559. [Google Scholar] [CrossRef]
  22. Lou, Q.; Liu, L. Curve intersection using hybrid clipping. Comput. Graph. 2012, 36, 309–320. [Google Scholar] [CrossRef]
  23. North, N.S. Intersection Algorithms Based on Geometric Intervals. Ph.D. Thesis, Brigham Young University, Provo, UT, USA, 2007. [Google Scholar]
  24. Yuan, Q. Study on Hybrid Clipping Method for Solving Polynomial Roots. Ph.D. Thesis, Zhejiang University, Hangzhou, China, 2012. [Google Scholar]
  25. Wu, Y.; Li, X. Curve intersection based on cubic hybrid clipping. Vis. Comput. Ind. Biomed. Art 2022, 5, 17. [Google Scholar] [CrossRef] [PubMed]
  26. Mishra, B. Algorithmic Algebra; Springer Science & Business Media: Berlin/Heidelberg, Germany, 2012. [Google Scholar]
  27. Bensimhoun, M. Historical account and ultra-simple proofs of Descartes’s rule of signs, De Gua, Fourier, and Budan’s rule. arXiv 2013, arXiv:1309.6664. [Google Scholar]
  28. Shao, W.B.; Chen, F.L.; Liu, X.F. Robust Algebraic Curve Intersections with Tolerance Control. Comput.-Aided Des. 2022, 147, 103236. [Google Scholar] [CrossRef]
  29. Milne, P.S. On the solutions of a set of polynomial equations. In Symbolic and Numerical Computation for Artificial Intelligence; Academic Press: Cambridge, MA, USA, 1992; pp. 89–102. [Google Scholar]
Figure 1. Quartic Bernstein basis functions and Bézier Curve.
Figure 1. Quartic Bernstein basis functions and Bézier Curve.
Mathematics 12 01344 g001
Figure 2. Quadratic B-spline basis functions and curve defined over knot vector Ξ = { 0 , 0 , 0 , 0.25 , 0.5 , 0.75 , 0.75 , 1 , 1 , 1 } .
Figure 2. Quadratic B-spline basis functions and curve defined over knot vector Ξ = { 0 , 0 , 0 , 0.25 , 0.5 , 0.75 , 0.75 , 1 , 1 , 1 } .
Mathematics 12 01344 g002
Figure 3. Two quadratic Bézier curves C A ( ξ ) and C B ( η ) in Example 3.
Figure 3. Two quadratic Bézier curves C A ( ξ ) and C B ( η ) in Example 3.
Mathematics 12 01344 g003
Figure 4. Illustration of pseudo-curvature concept applied to a B-spline curve.
Figure 4. Illustration of pseudo-curvature concept applied to a B-spline curve.
Mathematics 12 01344 g004
Figure 5. Examples used for comparisons of different methods. (a) Example 1: cubic Bézier curves with 2 intersections. (b) Example 2: quadratic B-spline and cubic B-spline with 2 intersections. (c) Example 3: cubic B-splines with 8 intersections. (d) Example 4: cubic B-splines with 8 intersections.
Figure 5. Examples used for comparisons of different methods. (a) Example 1: cubic Bézier curves with 2 intersections. (b) Example 2: quadratic B-spline and cubic B-spline with 2 intersections. (c) Example 3: cubic B-splines with 8 intersections. (d) Example 4: cubic B-splines with 8 intersections.
Mathematics 12 01344 g005
Figure 6. Illustration of Bézier segments for curve C A in Example 3, which is composed of 60 segments.
Figure 6. Illustration of Bézier segments for curve C A in Example 3, which is composed of 60 segments.
Mathematics 12 01344 g006
Figure 7. Comparison of computation times across different methods w.r.t. the square of Bézier segment. This assessment encompasses Bézier clipping [18], quadratic degree reduction [20], cubic degree reduction [22], geometric interval clipping [23], cubic hybrid clipping [25], and our method.
Figure 7. Comparison of computation times across different methods w.r.t. the square of Bézier segment. This assessment encompasses Bézier clipping [18], quadratic degree reduction [20], cubic degree reduction [22], geometric interval clipping [23], cubic hybrid clipping [25], and our method.
Mathematics 12 01344 g007
Table 1. Computation results comparison of the proposed method against existing methods. The curves information includes the numbers of control points, Bézier segments, and intersections for clearer interpretation. Data highlighted in bold indicate the best performance.
Table 1. Computation results comparison of the proposed method against existing methods. The curves information includes the numbers of control points, Bézier segments, and intersections for clearer interpretation. Data highlighted in bold indicate the best performance.
ExampleCurves Info.MethodsTime ( μ s)Relative Time
Bézier Clipping [18]2101.84
Quadratic Degree Reduction [20]329328.89
Example 1 C A : 4/1/2Cubic Degree Reduction [22]17,074149.77
(Figure 5a) C B : 4/1/2Geometry Interval Clipping [23]294125.79
Cubic Hybrid Clipping [25]286125.10
Our Method1141.00
Bézier Clipping [18]643538.53
Quadratic Degree Reduction [20]731243.78
Example 2 C A : 29/26/2Cubic Degree Reduction [22]702842.08
(Figure 5b) C B : 29/27/2Geometry Interval Clipping [23]421925.26
Cubic Hybrid Clipping [25]187311.22
Our Method1671.00
Bézier Clipping [18]21763.74
Quadratic Degree Reduction [20]44407.63
Example 3 C A : 63/60/8Cubic Degree Reduction [22]33845.81
(Figure 5c) C B : 24/21/8Geometry Interval Clipping [23]20663.55
Cubic Hybrid Clipping [25]16672.86
Our Method5821.00
Bézier Clipping [18]18634.05
Quadratic Degree Reduction [20]39488.58
Example 4 C A : 63/60/8Cubic Degree Reduction [22]29706.46
(Figure 5d) C B : 24/21/8Geometry Interval Clipping [23]15583.39
Cubic Hybrid Clipping [25]11842.57
Our Method4601.00
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

Yu, Y.-Y.; Li, X.; Ji, Y. On Intersections of B-Spline Curves. Mathematics 2024, 12, 1344. https://doi.org/10.3390/math12091344

AMA Style

Yu Y-Y, Li X, Ji Y. On Intersections of B-Spline Curves. Mathematics. 2024; 12(9):1344. https://doi.org/10.3390/math12091344

Chicago/Turabian Style

Yu, Ying-Ying, Xin Li, and Ye Ji. 2024. "On Intersections of B-Spline Curves" Mathematics 12, no. 9: 1344. https://doi.org/10.3390/math12091344

APA Style

Yu, Y. -Y., Li, X., & Ji, Y. (2024). On Intersections of B-Spline Curves. Mathematics, 12(9), 1344. https://doi.org/10.3390/math12091344

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop