Full-variable optimized B-spline geometric distance fitting method
Through the full variable optimization of B-spline geometric distance fitting method, the control points, nodes and parameters are alternately updated, which solves the problem of large fitting errors in the processing of sharp features in the existing technology, and realizes high-precision curve fitting and automated processing.
Patent Information
- Application Number
- CN202510480775.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-05-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing B-spline fitting method cannot globally optimize nodes and control points when processing sharp features, resulting in large fitting errors and requires manual intervention, which affects design efficiency.
A full variable optimization B-spline geometric distance fitting method is proposed. By alternately iterating the parameters of control points, nodes and data points, a linear system of equations is constructed, and the solution is used to ensure the optimization of all variables.
It significantly improves the fitting accuracy, can automatically process input data containing sharp features, generates B-spline curves with heavy nodes, reduces fitting errors, and improves design efficiency.
Smart Images

Figure CN120046249A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer-aided geometric design, and particularly to a geometric distance fitting method for B-spline curves with full variable optimization. Background Art
[0002] In the field of computer-aided geometric design, B-spline is the industrial standard for computers to process geometric information. Due to its good geometric properties, B-spline curves have been widely used in many fields such as computer-aided design, computer graphics, computer vision, image processing, and medical imaging. For example, B-spline curves and surfaces are the core tools for complex geometric modeling in the automotive manufacturing and aerospace fields. The streamlined surfaces of automobile bodies need to be achieved through high-precision fitting for aerodynamic optimization, while the design of aero-engine blades requires precise control of curves to reduce stress concentration. Traditional B-spline fitting methods often result in large fitting errors when dealing with sharp features (such as body ridges and blade edges) because they cannot globally optimize knots and control points, and manual intervention is required to adjust the knot distribution, which seriously affects the design efficiency.
[0003] B-spline curve fitting refers to calculating a B-spline curve for a given set of data points to approximate the data points under a given metric. According to the metric used in the fitting, B-spline curve fitting methods can be divided into algebraic distance fitting and geometric distance fitting. Algebraic distance fitting is the commonly used least squares fitting, that is, given the parameters of the data points and the knot vector, the control points of the curve are obtained by minimizing the distance (i.e., algebraic distance) between the data points and the corresponding parameter points on the curve. In least squares fitting, the parameters of the data points and the knot vector of the B-spline curve are obtained by various deterministic methods, such as the parametric uniform method, chord length accumulation method, centripetal method, Foley method, etc., and the uniform method and average method of the knot vector, etc. Only the control points are obtained through optimization calculations.
[0004] Geometric distance fitting aims to minimize the geometric distance, that is, the distance between the data points and the nearest points on the curve, so as to achieve a curve fitting with better approximation accuracy. In geometric distance fitting, the control points, the knot vector, and the parameters corresponding to the data points are all objects that can be optimized. Due to the complex coupling relationships between these variables, how to optimize all these variables simultaneously has always been a challenging problem in the CAGD field. The current geometric distance-based fitting methods mainly focus on optimizing one or two of the control points, the knot vector, and the parameters, and do not incorporate all free variables into the optimization framework of the geometric distance objective function, resulting in deficiencies in the accuracy and flexibility of the fitting results and making it difficult to meet the requirements for accuracy and automation in the above industrial scenarios. Summary of the Invention
[0005] The present invention proposes a geometric distance fitting method for B-spline curves with full variable optimization, which is applicable to the high-precision modeling problem of complex curves in industrial design and precision manufacturing scenarios. For a given set of data points, the present invention effectively solves the geometric distance fitting problem of B-spline curves by alternately iteratively updating the parameters of control points, knots, and data points. In particular, it can automatically process input data containing sharp features, generate B-spline curves with multiple knots, and significantly improve the fitting accuracy and industrial practicability.
[0006] The present invention is implemented through the following technical solutions:
[0007] A geometric distance fitting method for B-spline curves with full variable optimization includes the following steps:
[0008] (1) Initialize the parameters of the control points, knots, and data points of the B-spline curve;
[0009] (2) Set the error vector and calculate the objective function value and the Jacobi matrix of the error vector with respect to the control points, construct a linear equation system, and solve to obtain the change amount of the control points;
[0010] (3) Calculate the Jacobi matrix of the objective function value and the error vector with respect to the knots, construct a linear equation system, and solve to obtain the change amount of the knots;
[0011] (4) Limit the knots within the domain to the interval (0, 1) and sort them;
[0012] (5) Calculate the derivative of the B-spline curve for each parameter, use the local first-order approximation to approximate the projection points of the data points on the curve, and then update the parameters backward according to the vector from the projection points to the parameter points;
[0013] (6) Check the fitting convergence index. If the change values of all variables are lower than the specified tolerance, or the relative change value of the objective function value is lower than the specified tolerance, or the maximum number of iterations is reached, then the fitting of the geometric distance of the B-spline curve is completed.
[0014] Further, the initialization in step (1) is specifically as follows: By uniformly sampling the data points at intervals and setting the initial control points, using the chord length parameterization method to set the initial parameters corresponding to the data points, using the knot vector of endpoint interpolation, fixing the first p + 1 knots to 0, the last p + 1 knots to 1, and the internal n - p knots are obtained by symmetrically uniformly sampling at intervals in the parameter interval.
[0015] Specifically, for the uniform interval sampling of the data points to set the initial control points, the ordered data points can directly provide the initial control points in this setting process; for unordered data points, a sequence of initial control points of an initial B-spline curve with a target-like shape needs to be provided to complete.
[0016] Specifically, the error vector in step (2) is the Euclidean distance between all data points and the corresponding parameter points on the curve, and the objective function is the norm of the error vector.
[0017] Specifically, the expression of the Euclidean distance is as follows: ; where is the data point set; is the corresponding parameter point on the curve.
[0018] Specifically, the obtained control point variation and internal node variation in step (2) are obtained by using the Gauss-Newton algorithm.
[0019] Furthermore, in step (6), if the change values of all variables are lower than the specified tolerance, or the relative change value of the objective function value is lower than the specified tolerance, or the maximum number of iterations is reached, then it is necessary to return to step (2) and repeat steps (2)-(6) until the convergence index is satisfied, and the fitting of the geometric distance of the B-spline curve is completed.
[0020] The second aspect of the present invention: A device for fitting the geometric distance of a B-spline curve with full variable optimization, including the following steps:
[0021] Initialization module: Initialize the parameters of the control points, knots, and data points of the B-spline curve;
[0022] Solve control point variation module: Set the error vector and calculate the objective function value and the Jacobi matrix of the error vector with respect to the control points, construct a linear equation system, and solve to obtain the control point variation;
[0023] Solve knot variation module: Calculate the objective function value and the Jacobi matrix of the error vector with respect to the knots, construct a linear equation system, and solve to obtain the knot variation; and limit the knots within the domain to the interval (0,1) and perform an ascending sort;
[0024] Reverse update parameter module: Calculate the derivative of the B-spline curve with respect to each parameter, use the local first-order approximation to approximate the projection points of the data points on the curve, and thus reverse update the parameters according to the vectors from the projection points to the parameter points;
[0025] Complete curve fitting module: Check the fitting convergence index. If the change values of all variables are lower than the specified tolerance, or the relative change value of the objective function value is lower than the specified tolerance, or the maximum number of iterations is reached, then the fitting of the geometric distance of the B-spline curve is completed.
[0026] The third aspect of the present invention: An electronic device, including:
[0027] One or more processors;
[0028] A memory for storing one or more programs;
[0029] When the one or more programs are executed by the one or more processors, the one or more processors implement the full-variable optimized B-spline curve geometric distance fitting method.
[0030] A fourth aspect of the present invention: A computer-readable storage medium, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the full-variable optimized B-spline curve geometric distance fitting method are implemented.
[0031] Compared with the prior art, the beneficial effects of the present invention are:
[0032] The present invention realizes a B-spline curve geometric distance fitting method with a smaller approximation error, and can automatically generate a B-spline fitting curve with repeated knots and sharp features when the data point set contains sharp features by optimizing the knot vector, thereby reducing the fitting error and better depicting the geometric features of the data points. Description of the Drawings
[0033] Figure 1 It is a schematic diagram of the basic steps of the B-spline curve geometric distance fitting method based on the Gauss-Newton algorithm of the present invention; Figure 2 It is a graph of the given data points and the initialized B-spline curve in the first example of the present invention; Figure 3 It is a graph showing the final fitting result of the first example of the present invention; Figure 4 It is the initialized curve graph of the second example of the present invention; Figure 5 It is the fitting result graph of the second example of the present invention. Detailed Embodiments
[0034] To make the objectives, technical solutions and advantages of the present invention clearer, the present invention will be further described below in conjunction with the embodiments and their accompanying drawings.
[0035] Embodiment 1
[0036] Let the given data point set be , and the expression of the p-th order B-spline curve to be solved is: ;
[0037] are n + 1 control points, are B-spline basis functions defined on the knot vector , They are the parameters corresponding to m + 1 data points on the curve.
[0038] The B-spline curve geometric distance fitting method of the present invention includes the following steps:
[0039] S1, initialize the control points, knots, and parameters of the data points of the B-spline curve.
[0040] Step (1), by uniformly sampling the data points at intervals, set the initial control points: ; where represents the data points in the aforementioned data point set; represents the integer closest to x. This method can provide appropriate initial control points for ordered data points. For unordered data points, the user needs to provide a sequence of initial B-spline curve control points close to the target shape.
[0041] Step (2), use the chord length parameterization method to set the initial parameters corresponding to the data points: ;
[0042] For unordered data points, the user needs to provide an initial B-spline curve close to the target shape, and then perform data parameterization through the closest point projection.
[0043] Step (3), use the knot vector of endpoint interpolation, fix the first p + 1 knots to 0, the last p + 1 knots to 1, and the internal n - p knots are obtained by uniformly sampling in the parameter interval: ;
[0044] The above formula can be extended to and , which has symmetry and can be applicable to the case where the curve does not interpolate the first and last data points.
[0045] S2, alternately update the control points, knots, and parameters.
[0046] Step (1), the error vector is the Euclidean distance between all data points and the corresponding parameter points on the curve , and the objective function is the norm of the error vector (i.e., the objective function value).
[0047] Step (2), calculate the Jacobi matrix of the error vector with respect to all control points: ;
[0048] For two-dimensional plane control points, the size of this matrix is .
[0049] Step (3), according to the Gauss-Newton algorithm, to minimize the objective function f, the change amount of the control points satisfies the system of equations , where represents the transpose of the matrix . Solve this system of equations and update the control points: .
[0050] Step (4), calculate the Jacobi matrix of the error vector for all internal nodes: ;
[0051] where ; and is the B-spline basis function defined on the new knot vector . The size of this matrix is .
[0052] Step (5), according to the Gauss-Newton algorithm, to minimize the objective function f, the change amount of the knots satisfies the system of equations , solve this system of equations and update the knots: .
[0053] Step (6), restrict the internal knots within the interval and perform an ascending sort.
[0054] Step (7), calculate the derivative of the B-spline curve with respect to each parameter to obtain the tangent line of the local first-order approximation, project the data points onto the tangent line, and update the parameters backward according to the vector from the projection point to the parameter point: ;
[0055] Step (8), repeat Step (7) until the change amount of all parameters is less than , or the number of repetitions reaches 10 times.
[0056] S3, check the fitting convergence index. If the change values of all control points, knots, and parameters in Step S2 are all lower than , or the objective function value in the k-th iteration satisfies , or the number of iterations is greater than 200, then the algorithm ends and the fitted B-spline curve is obtained. If all criteria are not met, return to Step S2.
[0057] In the embodiment of the present invention, the method described in the above S1 to S3 can be processed according to the Figure 1 shown process. Figure 2Shows an example of fitting based on this method (the upper figure is the given data points of the car contour and the initialized B-spline curve, where the given data points are represented by scatter points, the initialized control points are represented by the vertices of the polygon, and the B-spline curve defined by the initialized control points and knots is represented by a curve; the lower figure is the B-spline curve fitting result of this example). In this example, the data points are from the contour of the car body, containing 493 points, and are fitted with a cubic B-spline curve with 32 control points. Figure 2 Is a graph of the given data points and the initialized B-spline curve, where the given data points are represented by scatter points, the initialized control points are represented by the vertices of the polygon, and the B-spline curve defined by the initialized control points and knots is represented by a curve. Figure 3 Is the final fitting result. The result shows that the method of the present invention can also fit the data points at the high-curvature part of the curve, achieving a high-precision fitting result. Based on this exemplary curve, the method of the present invention and the traditional L-BFGS method are respectively used for fitting, and the comparison of the average geometric distance error and the maximum geometric distance error between the two sets of data points and the curve is shown in Table 1:
[0058] Table 1
[0059] Method Average error Maximum error L-BFGS method <![CDATA[1.57*10 -3 > <![CDATA[1.27*10 -2 > The present invention <![CDATA[9.04*10 -4 > <![CDATA[3.71*10 -3 >
[0060] Both the average error and the maximum error of the method of the present invention are significantly better than the traditional L-BFGS method.
[0061] Figure 4 and Figure 5 Shows another example of fitting based on the method of the present invention, where Figure 4 Represents the initialized curve graph, Figure 5 Is the fitting result graph. The data points in this example are star-shaped with 4 cusps and are difficult to fit with a smooth B-spline curve. The method proposed by the present invention optimizes and generates multiple knots at the cusps: ;
[0062] Although the multiple knots reduce the smoothness of the curve, the generated fitting curve fully utilizes the characteristics of the B-spline curve, that is, it can represent both an overall smooth curve and a piecewise smooth C0 continuous curve, thus more accurately depicting the characteristics of the data points. Therefore, this method can more accurately depict the geometric characteristics and local details of the data points in complex industrial designs and precision manufacturing scenarios such as automotive exterior modeling, meeting the dual requirements of fitting accuracy and smoothness in industrial applications.
[0063] The present invention also provides a B-spline curve geometric distance fitting device with full variable optimization, including the following steps:
[0064] Initialization module: Initialize the parameters of the control points, knots, and data points of the B-spline curve;
[0065] Control point variation solving module: Set the error vector and calculate the objective function value and the Jacobi matrix of the error vector with respect to the control points, construct a linear equation system, and solve to obtain the control point variation;
[0066] Knot variation solving module: Calculate the objective function value and the Jacobi matrix of the error vector with respect to the knots, construct a linear equation system, and solve to obtain the knot variation; and limit the knots within the domain restricted to the interval (0, 1) and perform an ascending sort;
[0067] Reverse parameter update module: Calculate the derivative of the B-spline curve with respect to each parameter, use a local first-order approximation to approximate the projection points of the data points on the curve, and thus reverse-update the parameters according to the vector from the projection points to the parameter points;
[0068] Curve fitting completion module: Check the fitting convergence index. If the change values of all variables are lower than the specified tolerance, or the relative change value of the objective function value is lower than the specified tolerance, or the maximum number of iterations is reached, then complete the fitting of the geometric distance of the B-spline curve.
[0069] The present invention also discloses an electronic device, including: one or more processors; a memory for storing one or more programs; when the one or more programs are executed by the one or more processors, enabling the one or more processors to implement the B-spline curve geometric distance fitting method with full variable optimization. And a computer-readable storage medium is disclosed, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the B-spline curve geometric distance fitting method with full variable optimization are implemented.
[0070] The content described in the embodiments of this specification is only an enumeration of the implementation forms of the inventive concept. The protection scope of the present invention should not be regarded as limited to the specific forms stated in the embodiments. The protection scope of the present invention also extends to equivalent technical means that those skilled in the art can think of based on the inventive concept of the present invention.
Claims
1. A full variable optimized B-spline curve geometric distance fitting method, characterized in that: The following steps are involved: (1) Initialize the parameters of the control points, nodes and data points of the B-spline curve; (2) Set the error vector and calculate the Jacobi matrix of the objective function value and the error vector for the control point, construct a linear equation system, and solve it to obtain the change of the control point; (3) Calculate the Jacobi matrix of the objective function value and the error vector for the node, construct a system of linear equations, and solve them to obtain the node change; And restrict the nodes to the domain within the interval (0,1) and sort them in ascending order; (4) Calculate the derivative of the B-spline curve for each parameter, use a local first-order approximation to approximate the projection point of the data point on the curve, and then update the parameter in reverse based on the vector from the projection point to the parameter point; (5) Check the fitting convergence index. If the change value of all variables is lower than the specified tolerance, or the relative change value of the objective function value is lower than the specified tolerance, or the maximum number of iterations is reached, the fitting of the geometric distance of the B-spline curve is completed.
2. The B-spline curve geometric distance fitting method of full variable optimization according to claim 1 is characterized in that: The initialization in step (1) is specifically as follows: by sampling the data points at uniform intervals and setting the initial control points, the initial parameters corresponding to the data points are set by using the chord length parameterization method, the node vectors of endpoint interpolation are used, the first p+1 nodes are fixed to 0, the last p+1 nodes are fixed to 1, and the internal np nodes are obtained by sampling symmetrically and uniformly in the parameter interval.
3. The B-spline curve geometric distance fitting method of full variable optimization according to claim 2 is characterized in that: The data points are sampled at uniform intervals to set the initial control points. In this setting process, ordered data points can directly provide initial control points. If there are unordered data points, an initial B-spline curve control point sequence of a target-like shape is required to complete the process.
4. The B-spline curve geometric distance fitting method of full variable optimization according to claim 1, characterized in that: The error vector in step (2) is the Euclidean distance between all data points and the corresponding parameter points on the curve, and the objective function is the modulus of the error vector.
5. The B-spline curve geometric distance fitting method of full variable optimization according to claim 4 is characterized in that: The expression of the Euclidean distance is as follows: ;in, is a set of data points; is the corresponding parameter point on the curve.
6. The B-spline curve geometric distance fitting method of full variable optimization according to claim 1, characterized in that: The control point variation and internal node variation are both obtained by using the Gauss-Newton algorithm.
7. The B-spline curve geometric distance fitting method of full variable optimization according to claim 1, characterized in that: In step (5), if the change value of all variables is lower than the specified tolerance or the relative change value of the objective function value is lower than the specified tolerance or the maximum number of iterations is reached, it is necessary to return to step (2) and repeat steps (2) to (6) until the convergence index is met and the fitting of the geometric distance of the B-spline curve is completed.
8. A B-spline curve geometric distance fitting device with full variable optimization, characterized in that: The following steps are involved: Initialization module: initialize the parameters of control points, nodes and data points of B-spline curve; Control point variation solution module: set the error vector and calculate the Jacobi matrix of the objective function value and the error vector for the control point, construct a linear equation system, and solve the control point variation; Node variation solution module: calculates the Jacobi matrix of the objective function value and the error vector for the node, constructs a linear equation system, and solves the node variation; And restrict the nodes to the domain within the interval (0,1) and sort them in ascending order; Reverse parameter update module: Calculate the derivative of the B-spline curve for each parameter, use local first-order approximation to approximate the projection point of the data point on the curve, and then reversely update the parameter according to the vector from the projection point to the parameter point; Complete the curve fitting module: Check the fitting convergence index. If the change value of all variables is lower than the specified tolerance, or the relative change value of the objective function value is lower than the specified tolerance, or the maximum number of iterations is reached, the fitting of the B-spline curve geometric distance is completed.
9. An electronic device, characterized in that: include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the full variable optimized B-spline curve geometric distance fitting method as described in any one of claims 1 to 7.
10. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the instruction is executed by the processor, the steps of the full variable optimized B-spline curve geometric distance fitting method as described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Elastic sheet structure generation method and device, computer equipment and storage medium
CN120809026A
CAD curve fitting optimization method based on lineation scene
CN120850562A