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
where
(
typically) denote the control points, and
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:
where
for
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
Consequently, a B-spline curve of degree
p is formulated as the linear combination of its basis functions,
, for
, and the corresponding control points,
, where
with
. Thus, a B-spline curve can be expressed as:
Figure 2 shows quadratic B-spline basis functions defined over the knot vector
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 . 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 and represent two polynomials of degree m and n, respectively. The resultant of and , , is defined by a determinant that encapsulates the coefficients of these polynomials, i.e., 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 and . The resultant defined by with respect to variable x iswhich is essentially a polynomial of the variable y. Consider a polynomial
with real coefficients and free of any square factors. The Sturm sequence for
is constructed as follows
where
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
. The Sturm sequence, denoted as
, serves as an effective tool for identifying the count of zeros that the polynomial
possesses within a given interval.
Consider the sequence
. Denote by
the number of sign-preserving occurrences within
. This is quantified by examining each pair of consecutive values,
and
. If these values share the same sign, the pair
is counted as contributing 1 to
. Notably, a term
is treated as though it possesses the opposite sign of its immediate predecessor
[
27,
28].
Example 2. Suppose and . Then, we have the numbers of sign-preserving occurrences and .
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 . Let and be two bivariate polynomials with the degrees of x as and , respectively. Define a polynomial in terms of α bywhere and .Let stand for the Sturm sequence of the polynomial of α. Here, represents the count of sign-preserving occurrences in the Sturm sequence when , , and . Consequently, the total number of real roots for the system of equations within the compact set can be determined by Remark 1. In cases where the first term in a sequence is 0, it is stated that , as detailed in [29]. This convention implies that roots located on the boundaries of a specified compact set are represented by in Equation (8). Similarly, roots situated at the vertices of the compact set are attributed a value of . Theorem 1 provides a theoretical foundation for determining the exact number of roots for a pair of bivariate polynomial equations within a specified compact set . 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 for clarity and brevity.
Given two Bézier curves
and
where
,
are their control points. Computing the intersection of
and
involves identifying the parameter pair (
,
) that fulfills the condition
.
From the partition of the unity property of Bernstein basis functions, we have
To simplify the notation and facilitate computation, let us denote
and
where
.
Therefore, Equation (
9) can be expressed in a matrix form as
Subsequently, according to the relationship between the Bernstein basis functions and power basis functions, we have
where
is the basis transformation matrix and
is the collection of power basis functions. Therefore, we have
Recall that computing the intersections between
and
is equivalent to solving the roots of
. That is,
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
Denote by
and
the first two lines and the last two lines of
, respectively. Similarly, we have
where
with
. Accordingly, the Equation (
17) to compute the intersection of
and
can thus be reformulated as follows
Remark 2. Referring to Equation (7) from Theorem 1, the computation of the polynomial necessitates initially deriving the resultant of the polynomials () 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 and , 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 |
|
Example 3. Let , , and , , be the control points of two quadratic Bézier curves and , as shown in Figure 3, respectively. Thus computing the intersections between and is equivalent to the roots of the following bivariate polynomialsNow, we propose the detailed procedure for determining the roots of in by Theorem 1. First, compute , , , and in Theorem 1, respectively. A comprehensive description of the process for calculating is shown below, which can also be applied to appraising , , and .
- 1.
Let , then . Similar to Example 1, we can state that the resultant and in Equation (7) asand The outer resultant in Equation (7) is computed byand - 2.
The Sturm sequence of can be obtained by the method of successive division. That is - 3.
By substituting into Equation (24), we obtain the sequence . It is observed that , corresponding to the sign-preserving of Γ.
Analogously, we find that , , and , respectively. Consequently, according to Equation (8), it is concluded that the Bézier curves and 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
To ascertain the total curvature energy across the curve, one integrates the point-wise curvature as follows:
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
, we define its pseudo-curvature as:
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
(
) in comparison to the segment formed by the first and last control points
.
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
, 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 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 to .
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 |
|
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
. The essence of the projected Gauss-Newton method is captured by a two-fold iterative process. Initially, we calculate an intermediate point
using the classic Gauss-Newton iteration formula
where
is the Moore-Penrose inverse of the Jacobian matrix of the nonlinear system
at iteration
k. The Moore-Penrose inverse
can be computed using the singular value decomposition (SVD).
Subsequently, we refine our estimate by projecting
onto the feasible set
, optimizing for proximity to the initial estimate
where
denotes the projection operator. In our implementation, we adopt the following projection operator
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
The corresponding Jacobian matrix, a
matrix, can be computed as follows:
For the 2D case, the nonlinear system becomes
The corresponding Jacobian matrix, a
matrix, is computed by
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 |
|
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,
, was set to
; residual tolerance, tol_res, was defined at
; variation tolerance for
, denoted as
, was also set at
; and the limit for the maximum number of iterations,
, 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
, with
denoting the number of Bézier segments. For instance, in Example 3, curve
comprises 60 Bézier segments, as illustrated in
Figure 6, whereas curve
contains 21 segments. Consequently, the process of determining Bézier intersections must be executed as many as
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
, 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.