A method for generating interpolated two-dimensional closed curves based on NUBRS

Through the NUBRS-based interpolation two-dimensional closed curve generation method, the local adjustment difficulties and numerical stability problems of curve generation in the existing technology are solved, and the two-dimensional closed NURBS curves that meet specific geometric requirements are quickly generated, which is suitable for multiple design and manufacturing fields.

CN118965479BActive Publication Date: 2025-09-30ZHEJIANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411040297.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2025-09-30
Estimated Expiration
2044-07-31

AI Technical Summary

Technical Problem

Existing closed curve generation methods have shortcomings in local adjustment difficulties, numerical stability issues and parameterized form complexity, making it difficult to generate two-dimensional closed curves that meet specific geometric requirements.

Method used

A NUBRS-based interpolation two-dimensional closed curve generation method is adopted. By obtaining the interpolation points and orders, a parameter value sequence is generated, and a knots array is constructed. The control point coefficients are calculated using the Cox-de Boor recursive formula, and the closed path curve that meets the requirements is generated by combining the weights.

Benefits of technology

It realizes the rapid generation of two-dimensional closed NURBS curves that meet specific geometric requirements, has high geometric continuity and accuracy, and is suitable for computer-aided design, engineering analysis, manufacturing, animation production and other fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118965479B_ABST
    Figure CN118965479B_ABST
Patent Text Reader

Abstract

This invention discloses a method for generating two-dimensional closed curves using NUBRS interpolation, belonging to the field of computer-aided geometric design. The method first obtains parameter values ​​and a knot array using the interpolation points passed by the closed path curve and the order of the closed path curve. The coordinates of all control points of the closed path curve are then solved using a system of simultaneous equations. Finally, the parameter values ​​are constrained according to the NUBRS generation formula to generate a closed NUBRS curve. Based on NUBRS curves, the method accurately represents various complex free-form closed path curves.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of computer-aided geometric design, and in particular relates to a method for generating an interpolation two-dimensional closed curve based on NUBRS. Background Art

[0002] Generating closed, smooth two-dimensional curves is crucial in graphic design, computer-aided design, animation, and game development. In the terrain rendering capabilities of game engines, they are often used to generate paths for roads, rivers, or mountains. In the design field, closed curves are often used to create patterns, logos, and works of art. In engineering and architecture, closed curves are used to draw precise engineering drawings and architectural blueprints. In animated films or video games, closed curves can define character outlines, environmental boundaries, or animation paths. In medicine, closed curves can be used to mark the outlines of diseased areas or organs. In robotics, closed curves can be used to define the movement trajectory of a robot, ensuring it completes its tasks safely and efficiently.

[0003] Among other existing closed curves, all control points of Bezier-based closed curves have an impact on the entire curve, which may make local adjustment of the curve more difficult. Polynomial-based curves and high-order polynomial curves may oscillate in certain areas, which may lead to numerical stability problems and make it difficult to control the local characteristics of the curve because each part of the curve is affected by the polynomial coefficients. Although implicit curves can represent complex shapes, they usually do not provide parameterized forms, which makes sampling or path planning along the curve difficult.

[0004] NURBS curves are widely used in the field of CAD (Computer-Aided Design), mainly due to their flexibility, accuracy, and powerful ability to express complex geometric shapes. NURBS curves can accurately represent a variety of complex free-form curves and surfaces, including organic shapes and complex industrial designs, making them very suitable for advanced modeling tasks. NURBS curves support continuity from C0 (continuous function) to C∞ (infinite continuity), which allows them to maintain a high degree of smoothness at curve junctions, avoiding sharp corners or discontinuities. NURBS curves can approximate any continuous curve with arbitrary precision, which means they can be used in fields requiring high-precision design, such as aerospace and automotive design.

[0005] By adjusting the control points and nodes of NURBS curves, designers can finely control the local shape of the curve without affecting the overall shape. The parametric nature of NURBS curves makes them very suitable for parametric design. Designers can quickly adjust designs based on parameter changes. NURBS curves are a standardized geometric representation method that is widely supported by different CAD software and file formats, allowing design data to be easily exchanged between different systems and platforms. NURBS curves can be accurately converted into tool paths for use in CNC machining and other manufacturing processes.

[0006] Therefore, designing a closed curve generation method based on NURBS can allow the design of seamless continuous paths, which is crucial for creating ring structures, pipes, tires and other applications that require continuous closed shapes. NURBS provides a high degree of flexibility and can adjust control points, nodes and weights to generate the required closed shapes to meet specific design requirements.

[0007] The closed curve generation method based on NURBS can be easily exchanged with other CAD software and systems because NURBS is a widely supported standardized geometric representation method. Due to these advantages, NURBS curves have become a core component in modern CAD software and are widely used in product design, engineering analysis, architectural modeling and many other fields. Summary of the Invention

[0008] The purpose of the present invention is to solve the problems existing in the prior art and provide a method for generating an interpolated two-dimensional closed curve based on NUBRS.

[0009] In order to achieve the above-mentioned object of the invention, the present invention specifically adopts the following technical solutions:

[0010] A method for generating an interpolated two-dimensional closed curve based on NUBRS, comprising the following steps:

[0011] S1: In the terrain drawing of the game engine, obtain the interpolation points on the two-dimensional plane that the closed path curve needs to pass through and the order that the closed path curve needs to reach, and at the same time, the number of interpolation points n must be greater than or equal to the order that the closed path curve needs to reach;

[0012] S2: Generate parameter values ​​corresponding to interpolation points according to a specific parameterization method, form a parameter value sequence from all generated parameter values ​​and normalize them;

[0013] S3: Generate a knots array that conforms to the closed path curve using the normalized parameter value sequence according to a preset array generation method;

[0014] S4: Substitute the values ​​of each knot node in the knots array, the order required for the closed path curve, and the parameter values ​​corresponding to each interpolation point into the Cox-de Boor recursive formula to calculate the coefficients of each control point of the closed path curve;

[0015] S5: The coefficients of all control points form a left-multiplied matrix, the control points of the closed path curve are preset, and the number of control points is equal to the number of interpolation points in S1. The coordinates of the control points of the closed path curve form a right-multiplied vector, and the interpolation points in S1 form an interpolation point vector. A linear equation system is constructed by the left-multiplied matrix, the right-multiplied vector, and the interpolation point vector. After converting the linear equation system into an upper triangular or stepped form, the coordinates of all control points are obtained.

[0016] S6: Preset the weight of each control point, and in the knots array, use the knots node with the subscript of the order that the closed path curve needs to reach as the starting knots node, and the nth node after the starting knots node as the ending knots node. The value of the starting knots node and the value of the ending knots node constitute the parameter interval range, so that the NUBRS parameter changes continuously within the parameter interval range. Under each NUBRS parameter, an actual point on the closed path curve is generated by the coefficient of the control point, the weight of the control point and the coordinates of the control point. All the generated actual points constitute a closed path curve that meets the requirements. Finally, the generated closed path curve is used as the generated path for drawing roads, rivers or mountains using terrain tools in the game engine.

[0017] Based on the above solution, each step can be implemented in the following preferred specific manner.

[0018] Preferably, in step S2, the parameter value corresponding to the interpolation point is generated by using the cumulative chord length parameterization method, specifically:

[0019] S21. Selecting the first interpolation point as the parameterization starting point according to the preset interpolation point selection order, presetting the parameter value of the first interpolation point, and setting the parameter value of the first interpolation point as the first element of the parameter value sequence;

[0020] S22. Starting from the first interpolation point, sequentially calculate the Euclidean distance between two adjacent interpolation points, and use the calculated Euclidean distance as the approximate arc length of the curve segment formed by the two adjacent interpolation points;

[0021] S23. For each interpolation point other than the first interpolation point, add up all approximate arc lengths from each interpolation point to the first interpolation point as the cumulative arc length, and add the cumulative arc length corresponding to each interpolation point to the parameter value of the first interpolation point to obtain the parameter value corresponding to each of the remaining interpolation points;

[0022] S24. The generated parameter values ​​are sequentially stored in the parameter value sequence according to a preset interpolation point selection order. The approximate arc length from the last interpolation point to the first interpolation point and the parameter value of the last interpolation point are added together to obtain the approximate perimeter of the closed path curve. A new interpolation point is preset so that it coincides with the first interpolation point and serves as the parameterization termination point. The approximate perimeter of the closed path curve is used as the parameter value corresponding to the new interpolation point. The parameter value corresponding to the new interpolation point is used as the last element of the parameter value sequence to obtain a final parameter value sequence.

[0023] S25. Normalize the final parameter value sequence to obtain a normalized parameter value sequence.

[0024] Preferably, in step S3, the specific process of generating the knots array according to the preset array generation method is as follows: pre-constructing a knots array of size 2×degree+1+n, starting from the starting knots node, obtaining the value of each knot node in the knots array from the normalized parameter value sequence; wherein degree represents the order required to close the path curve, and n represents the number of interpolation points;

[0025] For the knots node with subscript m in the knots array, determine the range of the knots node subscript and calculate the value of the knots node according to the determination result:

[0026] When the subscript m of the knots node is between [degree, degree+n], the value of the knots node with subscript m, Knots[m], is:

[0027] Knots[m]=t m-degree

[0028] Where, t m-degree Represents the (m-degree+1)th element in the normalized parameter value sequence;

[0029] When the subscript m of the knots node is between [0, degree-1], the value of the knots node with subscript m, Knots[m], is:

[0030] Knots[m]=Knots[degree]-(t n -t n-degree+m )

[0031] Where, Knots[degree] represents the value of the starting knots node; t n Represents the n+1th element in the normalized parameter value sequence; t n-degree+mRepresents the (n-degree+m+1)th element in the normalized parameter value sequence;

[0032] When the subscript m of the knots node is between [degree+n+1,2×degree+n], the value of the knots node with subscript m, Knots[m], is:

[0033] Knots[m]=Knots[degree+n]-(t m-degree-n -t0)

[0034] Where, Knots[degree+n] represents the value of the knots node with the subscript (degree+n); m-degree-n It represents the (m-degree-n+1)th element in the normalized parameter value sequence; t0 represents the first element in the normalized parameter value sequence.

[0035] Preferably, in step S5, the linear equations are converted into an upper triangular or ladder type using LU decomposition method.

[0036] Preferably, in step S6, the weight of each control point is set to 1 by default.

[0037] Preferably, in step S6, an actual point P(K) on the closed path curve is generated as follows:

[0038]

[0039] Among them, N i,degree (u) indicates that the order is degree and the domain is [u i ,u i+1 ] and the value of the NUBRS basis function when the NUBRS parameter is u; R i represents the weight of the i-th control point; P i Represents the coordinates of the i-th control point.

[0040] Compared with the prior art, the present invention has the following beneficial effects:

[0041] The present invention relates to a NURBS-based interpolation two-dimensional closed curve generation method. This method uses a set of points on a given two-dimensional plane and corresponding geometric constraints to rapidly calculate the initial control points of a NURBS curve. This method can effectively generate a two-dimensional closed NURBS curve that meets specific geometric requirements. Furthermore, the NURBS closed path curve generation method of the present invention can be widely used in fields such as computer-aided design (CAD), engineering analysis, manufacturing, and animation production, exhibiting excellent practicality and broad application prospects. The NURBS closed path curve generated by this method has a high degree of geometric continuity and accuracy, meeting the requirements of complex engineering design and high-precision manufacturing. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 is a flow chart of the steps of the present invention;

[0043] Figure 2 A schematic diagram of generating a closed NUBRS curve from control points according to an embodiment of the present invention;

[0044] Figure 3 Schematic diagram of computer simulation results of an embodiment of the present invention. DETAILED DESCRIPTION

[0045] In order to make the above-mentioned objects, features and advantages of the present invention more clearly understood, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways than those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below. The technical features in the various embodiments of the present invention can be combined accordingly without conflicting with each other.

[0046] In the description of the present invention, it should be understood that the terms "first" and "second" are used solely for descriptive purposes and are not to be construed as indicating or implying relative importance or implicitly specifying the number of technical features being described. Therefore, features defined as "first" or "second" may explicitly or implicitly include at least one of such features.

[0047] like Figure 1 As shown, in a preferred implementation of the present invention, the above-mentioned NUBRS-based interpolation two-dimensional closed curve generation method includes the following steps S1 to S6. The specific implementation process is described in detail below.

[0048] 1. Get the curve interpolation point

[0049] Step S1: In the terrain drawing of the game engine, obtain the interpolation points of the two-dimensional plane that the closed path curve needs to pass through and the order that the closed path curve needs to reach, and at the same time, the number of interpolation points must be greater than or equal to the order that the closed path curve needs to reach.

[0050] The specific process of step S1 is: obtaining the interpolation points (two-dimensional plane points) (x1, y1), (x2, y2) ... (x n ,y n ), and obtain the degree that the closed path curve needs to reach (that is, the geometric continuity that the closed path curve needs to achieve). At the same time, the number of interpolation points must be greater than or equal to the degree of the closed path curve, that is, n≥degree. In the formula, (x1,y1),(x2,y2)......(x n ,y n ) represent the two-dimensional plane coordinates of the 1st, 2nd, ...nth interpolation points respectively; x1, x2, ...x n Respectively represent the horizontal coordinates of the 1st, 2nd, ...nth interpolation points in the two-dimensional plane coordinates; y1, y2, ..., y n They represent the vertical coordinates of the 1st, 2nd,...nth interpolation points in the two-dimensional plane; n represents the number of interpolation points.

[0051] It's important to note that in two-dimensional space, the geometric path of a curve begins with a set of discrete control points. These control points are the foundation of curve design and determine the basic shape of the curve. To ensure that the generated closed path curve meets specific geometric continuity requirements, the curve's degree must be specified. This is the degree of the curve's polynomial, which directly affects the curve's smoothness and differentiability, determining its smoothness and bendability.

[0052] In the context of NURBS (Non-Uniform Rational B-Splines) curves, the order is often associated with the curve's level of continuity; for example, a curve of order 2 provides C1 continuity (first-order derivative continuity), while a curve of order 3 provides C2 continuity (second-order derivative continuity). When specifying the order, one must ensure that the number of control points is at least equal to the curve's order requirement. This is because each additional order requires more control points to maintain the curve's local control properties. For example, a NURBS curve with n control points requires at least order p control points to define it, where n = p + 1.

[0053] 2. Generate parameter values

[0054] S2: Generate parameter values ​​corresponding to interpolation points according to a specific parameterization method, and form a parameter value sequence with all generated parameter values ​​and normalize them.

[0055] It should be noted that after the interpolation points of the closed path curve and the order that the closed path curve needs to reach are preset, in step S2, the cumulative chord length parameterization method is used to calculate the parameter value of each interpolation point. Specifically:

[0056] S21. Parameter initialization: according to the preset interpolation point selection order, the first interpolation point is selected as the parameterization starting point, and the parameter value t0 of the first interpolation point is preset to 0, and the parameter value of the first interpolation point is used as the first element of the parameter value sequence.

[0057] S22. Calculation of straight-line distance: Starting from the first interpolation point, calculate the Euclidean distance between two adjacent interpolation points in sequence, and use the calculated Euclidean distance result as the approximate arc length of the curve segment formed by the two adjacent interpolation points.

[0058] In this embodiment, two interpolation points are taken as an example to illustrate the calculation method of the Euclidean distance d, which is specifically as follows:

[0059]

[0060] S23. Cumulative arc length: For each interpolation point except the first interpolation point, all approximate arc lengths from each of the remaining interpolation points to the first interpolation point are accumulated as the cumulative arc length, and the cumulative arc length corresponding to each of the remaining interpolation points is added to the parameter value of the first interpolation point to obtain the parameter value corresponding to each of the remaining interpolation points.

[0061] In this embodiment, for the n interpolation points (x1, y1), (x2, y2) ... (x n ,y n), except for the first interpolation point, each of the remaining interpolation points has its corresponding cumulative arc length added to the parameter value of the first interpolation point as its corresponding parameter value. Specifically, for the first interpolation point (x1, y1), the parameter value of the first interpolation point is initialized according to the above process to obtain the parameter value t0 = 0 corresponding to the first interpolation point. Then, the straight-line distance d0 between the first interpolation point and the second interpolation point is calculated and used as the approximate arc length of the curve segment formed by the first and second interpolation points. For the second interpolation point (x2, y2), the straight-line distance d0 between it and the first interpolation point is directly added to the parameter value t0 of the first interpolation point to obtain the parameter value t1 = t0 + d0 of the second interpolation point (x2, y2). Similarly, calculate the straight-line distance d1 between the second interpolation point and the third interpolation point. The distance from the third interpolation point to the first interpolation point needs to pass through the second interpolation point, so the cumulative arc length corresponding to the third interpolation point is d0+d1. Then the parameter value of the third interpolation point (x3, y3) is t2=t0+d0+d1. Continue calculating in this way to obtain the parameter values ​​corresponding to each of the remaining interpolation points.

[0062] In addition to the above method of calculating parameter values, after obtaining the approximate arc length of each curve segment, you can also first obtain the parameter value t1=t0+d0 of the second interpolation point (x2, y2). Then, starting from the third interpolation point, you only need to get the parameter value of the previous interpolation point and add it to the approximate arc length corresponding to the current interpolation point as the parameter value of the current interpolation point. For example, the approximate arc length between the third interpolation point and the second interpolation point is d1, the previous interpolation point is the second interpolation point, and the parameter value of the second interpolation point is t1. Then add it to the approximate arc length d1 corresponding to the third interpolation point to obtain the parameter value of the third interpolation point, that is, t2=t1+d1. And so on, the nth interpolation point (x n ,y n ) corresponds to the parameter value t n-1 =t n-2 +d n-2 . t n-2 Indicates the n-1th interpolation point (x n-1 ,y n-1 ) corresponding parameter value; d n-2 Represents the approximate arc length between the nth interpolation point and the n-1th interpolation point.

[0063] S24. Special processing of closed path curves: save the generated parameter values ​​in the parameter value sequence in sequence according to the preset interpolation point selection order, add the approximate arc length from the last interpolation point to the first interpolation point and the parameter value of the last interpolation point as the approximate perimeter of the closed path curve, preset a new interpolation point so that it coincides with the first interpolation point and serves as the parameterization termination point, use the approximate perimeter of the closed path curve as the parameter value corresponding to the new interpolation point, and use the parameter value corresponding to the new interpolation point as the last element of the parameter value sequence to obtain the final parameter value sequence.

[0064] In this embodiment, a new interpolation point is added and aligned with the first interpolation point to ensure parameter continuity of the closed path curve. This ensures a smooth transition between the last interpolation point and the first interpolation point in the parameter value sequence, forming a seamless loop. By accumulating parameter values ​​in this way, each interpolation point receives a corresponding parameter value. The final parameter value sequence contains a total of n+1 parameter values.

[0065] like Figure 2 As shown in Figure 1, a new interpolation point, p6, is added, which coincides with the first interpolation point p0.

[0066] S25. Normalization: Normalize the final parameter value sequence to obtain a normalized parameter value sequence.

[0067] In this embodiment, each parameter value in the final parameter value sequence is divided by the last parameter value to normalize the final parameter value sequence. For a closed path curve, the last interpolation point coincides with the first interpolation point. Therefore, the parameter value of the second-to-last interpolation point will take into account its distance from the end point (i.e., the starting point). For the first interpolation point (i.e., the last interpolation point), that is, the starting point or end point of the sequence, its parameter value will be set to 1, indicating the beginning or end of the parameterized curve.

[0068] 3. Generate knots array

[0069] S3: Generate a knots array that conforms to the closed path curve using the normalized parameter value sequence according to a preset array generation method.

[0070] In step S3, the specific process of generating the knots array according to the preset array generation method is as follows:

[0071] Pre-build a knots array of size 2×degree+1+n. In the knots array, the knot node with the subscript of the order required to close the path curve is used as the starting knots node. Starting from the starting knots node, the value of each knot node in the knots array is obtained from the normalized parameter value sequence.

[0072] It should be noted that for the knots node with subscript m in the knots array, the range of the knots node subscript is determined and the value of the knots node is calculated accordingly:

[0073] When the subscript m of the knots node is between [degree, degree+n], the value of the knots node with subscript m, Knots[m], is:

[0074] Knots[m]=t m-degree

[0075] Where, t m-degree Represents the (m-degree+1)th element in the normalized parameter value sequence;

[0076] When the subscript m of the knots node is between [0, degree-1], the value of the knots node with subscript m, Knots[m], is:

[0077] Knots[m]=Knots[degree]-(t n -t n-degree+m )

[0078] Where Knots[degree] represents the value of the starting knots node (the subscript is the value of the knots node of the order required to close the path curve); t n Represents the n+1th element in the normalized parameter value sequence; t n-degree+m Represents the (n-degree+m+1)th element in the normalized parameter value sequence;

[0079] When the subscript m of the knots node is between [degree+n+1,2×degree+n], the value of the knots node with subscript m, Knots[m], is:

[0080] Knots[m]=Knots[degree+n]-(t m-degree-n -t0)

[0081] Where, Knots[degree+n] represents the value of the knots node with the subscript (degree+n); m-degree-n It represents the (m-degree-n+1)th element in the normalized parameter value sequence; t0 represents the first element in the normalized parameter value sequence.

[0082] In this example, after determining the interpolation points and parameterization of the closed NURBS curve, the next step is to construct the knots array of the closed path curve. The knots array, also known as the knot vector, is a key parameter used in NURBS curves to weight control points and define the local control range. The knot vector must satisfy the non-decreasing property, and its length and distribution will affect the geometric continuity of the curve.

[0083] The construction principle of the knots array is described in detail below to facilitate those skilled in the art to understand the present invention.

[0084] 1) Knot array construction: According to the NURBS curve generation rules, the knot array must meet specific conditions to ensure the correctness and continuity of the curve. The size of the knot array is determined by the number of interpolation points (n) and the degree required to close the path curve.

[0085] 2) The size of the knots array: The size of the knots array should satisfy 2×degree+1+n to ensure that the closed path curve has the required geometric continuity and flexibility.

[0086] 3) Initialization of the knots array: The subscript of the knots array starts at 0. According to the parameter value generated in step S2, the value of each element of the knots array can be determined.

[0087] 4) Fill the knots array: Starting at the position indexed by degree in the knots array, fill in the n+1 parameter values ​​generated by the normalized parameter value sequence in step S2. This ensures that the closed path curve has a well-defined geometry at these parameter values.

[0088] 5) Filling the ends of the knots array: For the first degree nodes of the knots array, generate them based on the last parameter value generated in step S2 and the interval between these parameter values. This can be determined by equal intervals or based on the geometric characteristics of the curve.

[0089] 6) Equally spaced node generation: At the front of the knots array, degree nodes can be generated in a uniformly distributed manner to meet the continuity requirement of the starting part of the closed path curve.

[0090] 7) Node processing of closed path curve: Since the final generated curve is closed, the last degree nodes of the knots array need to correspond to the first degree nodes to ensure the closure and continuity of the closed path curve.

[0091] 8) Closure of the knots array: The last degree nodes of the knots array can be generated by copying the values ​​of the first degree nodes, or determined according to the closure characteristics and parameterization requirements of the curve.

[0092] 9) Verification of knots array: After constructing the knots array, it is necessary to verify that it meets all the conditions of the NURBS curve, including non-decreasing, closed, and consistent with the control points and order.

[0093] Since the final generated is a closed path curve, in which the last degree unknown control points are consistent with the first degree control points, it can be considered that the number of unknown control points is n. Therefore, it is assumed that degree+n unknown control points are required to generate this closed path curve, the number of interpolation points is n, and the corresponding number of parameter values ​​of the interpolation points is also n. According to the generation rules of NUBRS, when the order required for the closed path curve is degree and the number of unknown control points is n, the size of the knots array is 2×degree+1+n. When the subscript is between [degree, degree+n], the values ​​of the knots nodes in this range are consistent with the interpolation point parameter values. Starting from the knots node with the subscript degree, the n+1 parameter values ​​generated by the normalized parameter value sequence in step S2 are filled in sequentially, that is, Knots[degree]=t0,...,Knots[degree+n]=t n Specifically, for the first degree nodes of the knots array, keep the interval between the last degree nodes of the n+1 nodes generated in step S2, that is, Knots[degree-1]=Knots[degree]-(t n -t n-1 ),Knots[degree-2]=Knots[degree-1]-(t n-1 -t n-2)...and so on. For the last degree nodes in the knots array, keep the interval between the first degree nodes of the n+1 nodes generated in step S2, that is, Knots[degree+n+1]=Knots[degree+n]-(t1-t0), Knots[degree-2]=Knots[degree+n+2]-(t2-t1)...and so on. In the formula, Knots[degree-1] represents the value of the knots node with the subscript (degree-1); Knots[degree-2] represents the value of the knots node with the subscript (degree-2); Knots[degree+n+1] represents the value of the knots node with the subscript (degree+n+1); Knots[degree+n+2] represents the value of the knots node with the subscript (degree+n+2).

[0094] 4. Solving the control point coefficients

[0095] S4: Substitute the values ​​of each knot node in the knots array, the order required for the closed path curve, and the parameter values ​​corresponding to each interpolation point into the Cox-de Boor recursive formula to calculate the coefficients of each control point of the closed path curve.

[0096] It should be noted that in step S4, the Cox-de Boor recursive formula is as follows:

[0097]

[0098] Where u i ,u i+1 Respectively represent the values ​​of the i-th and i+1-th nodes in the knots array; N i,0 (u) indicates that the order is 0 and the domain is [u i ,u i+1 ] and the value of the NUBRS basis function when the NUBRS parameter is u; N i,degree (u) indicates that the order is degree and the domain is [u i ,u i+1 ] and the value of the NUBRS basis function when the NUBRS parameter is u; u i+degree Indicates the i+degree node in the knots array; N i,degree-1 (u) indicates that the order is degree-1 and the domain is [u i ,u i+1 ] and the value of the NUBRS basis function when the NUBRS parameter is u; u i+degree+1Indicates the i+degree+1th node in the knots array; N i+1 ,degre -1 (u) indicates that the order is degree-1 and the domain is [u i+1 ,u i+2 ] and the value of the NUBRS basis function when the NUBRS parameter is u.

[0099] In this embodiment, the basis functions of the NURBS curve are defined by the knot vectors and the curve order. The generation of the basis functions follows the Cox-de Boor recursive formula or the definition of B-spline basis functions. Each basis function has a maximum of degree non-zero values ​​within the entire domain of the parameter definition. This means that under any parameter value, only the same number of basis functions as the order will simultaneously contribute to the curve point. The parameter values ​​corresponding to each interpolation point are sequentially substituted into the Cox-de Boor recursive formula, and the value of each basis function under that parameter is calculated. This yields n vectors, each representing the basis function value under a specific parameter, i.e., the coefficients of each control point. Specifically, the parameter value t0 corresponding to the first interpolation point is substituted as the variable (NUBRS parameter) u into the above Cox-de Boor recursive formula to obtain the coefficient of the first control point, cof1 = (a1, b1, c1, ...). This coefficient is a vector of dimension n. Due to the characteristics of the basis function, each coordinate coefficient of this vector has a maximum of degree non-zero values. The parameter values ​​t1, t2, ..., t corresponding to the remaining interpolation points are sequentially n-1 Substitute the above COX-DE BOOR recursive formula to obtain the coefficients of the remaining control points, which are cof2, cof3, ..., cof n , and finally obtain the coefficients of n control points.

[0100] 5. Solving control point coordinates

[0101] S5: The coefficients of all control points form a left multiplication matrix A = (cof1, cof2, ..., cof n ) T , preset the control points of the closed path curve, the number of control points is equal to the number of interpolation points in S1, and the coordinates of the control points of the closed path curve form the right multiplication vector X=((p x1 ,p y1 ),(p x2 ,p y2 ),...,(p xn ,p yn )) T , the interpolation point vector b=((x1,y1),(x2,y2)......(x n ,y n)) T , construct a linear equation system AX=b by multiplying the matrix A on the left, the vector X on the right, and the interpolation point vector b. After transforming the linear equation system into an upper triangular or ladder form, the coordinates of all control points are obtained. Where T represents transpose; (p x1 ,p y1 ),(p x2 ,p y2 )......(p xn ,p yn ) represent the two-dimensional plane coordinates of the 1st, 2nd, ... nth control points respectively; p x1 ,p x2 ,......p xn They represent the horizontal coordinates of the 1st, 2nd, ...nth control points in the two-dimensional plane coordinates; p y1 ,p y2 ,.....,p yn They represent the vertical coordinates of the 1st, 2nd,...nth control points in the two-dimensional plane coordinates respectively.

[0102] It should be noted that, in this embodiment, the vectors representing the coefficients of the control points are combined into a left-multiplied matrix, which will be used to calculate the coordinates of the control points of the closed path curve. Then, n unknown control points are preset, and the coordinates of all unknown control points are aggregated in sequence into a right-multiplied vector. This vector contains the coordinate information of all control points required to form the NURBS curve. Then, all the interpolation points of step S1 are aggregated into an interpolation point vector. The coordinates of these interpolation points are known, and the closed path curve must pass through these interpolation points. According to the definition of the NURBS curve, a linear combination of basis functions and control points is used to establish a linear equation system, which links the control points to the interpolation points. Finally, a numerical method such as the LU decomposition method is used to transform this linear equation system into an upper triangle or ladder type, thereby obtaining the coordinates of all unknown control points.

[0103] 6. Closed NUBRS curve generation

[0104] S6: Preset the weight of each control point, and in the knots array, use the knots node with the subscript of the order that the closed path curve needs to reach as the starting knots node, and the nth node after the starting knots node as the ending knots node. The parameter interval range is composed of the value Knots[degree] of the starting knots node and the value Knots[degree+n] of the ending knots node, so that the NUBRS parameter changes continuously within the parameter interval. Under each NUBRS parameter, an actual point on the closed path curve is generated by the coefficient of the control point, the weight of the control point and the coordinates of the control point. All the generated actual points constitute a closed path curve that meets the requirements. Finally, the generated closed path curve is used as the generated path for drawing roads, rivers or mountains using terrain tools in the game engine.

[0105] It should be noted that in step S6, an actual point on the closed path curve is generated using the following NUBRS generation formula through the calculated control point coordinates. Considering that the valid parameter value space is the knots array subscript starting from degree and ending with the subscript degree+n. Therefore, the knots range is trimmed, and the value range of the NUBRS parameter is limited to between two specific nodes in the knots array, that is, between the value Knots[degree] of the starting knots node and the value Knots[degree+n] of the ending knots node. This range ensures that the curve is well defined within the span of the node vector. For the generated closed path curve, in fact, its first degree control points and its last degree control points coincide in coordinates, and the first degree nodes and the last degree nodes of the knots array are wrapped according to the actual knots nodes. These restrictions ensure that the generated curve is closed.

[0106] The way to get an actual point P(K) on the closed path curve from the NUBRS generation formula is as follows:

[0107]

[0108] Among them, R i represents the weight of the i-th control point; P i Represents the coordinates of the i-th control point.

[0109] It should also be noted that in step S6, the weight of each control point is set to 1 by default. This means that the control points contribute equally to the shape of the closed path curve. Different weight settings can be used to adjust the curvature of the closed path curve near the control points.

[0110] Computer simulation results are as follows Figure 3 As shown, the NURBS-based two-dimensional closed curve interpolation generation method proposed in the present invention can generate a very smooth smooth closed path curve without sharp corners or discontinuous points, and provides the ability to accurately control the shape of the curve. By adjusting the control points and weights, the shape of the curve can be accurately adjusted. At the same time, the modification of the curve is local, that is, modifying one part of the curve will not affect other parts, which is very useful in complex designs.

[0111] The present invention relates to a NURBS-based two-dimensional closed curve interpolation generation method. This method uses a set of points on a given two-dimensional plane and corresponding geometric constraints to rapidly calculate the initial control points of the NURBS curve. This method can effectively generate a two-dimensional closed NURBS curve that meets specific geometric requirements. Furthermore, the NURBS closed path curve generation method of the present invention can be widely used in fields such as computer-aided design (CAD), engineering analysis, manufacturing, and animation production, exhibiting excellent practicality and broad application prospects. The NURBS closed path curve generated by this method has a high degree of geometric continuity and accuracy, meeting the requirements of complex engineering design and high-precision manufacturing.

[0112] The embodiment described above is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Persons skilled in the art may make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, any technical solution obtained by equivalent substitution or equivalent transformation falls within the scope of protection of the present invention.

Claims

1. A method for generating an interpolated two-dimensional closed curve based on NUBRS, characterized in that: The following steps are involved: S1: In the terrain drawing of the game engine, obtain the interpolation points on the two-dimensional plane that the closed path curve needs to pass through and the order that the closed path curve needs to reach, and at the same time, the number of interpolation points n must be greater than or equal to the order that the closed path curve needs to reach; S2: Generate parameter values ​​corresponding to interpolation points according to a specific parameterization method, form a parameter value sequence from all generated parameter values ​​and normalize them; S3: Generate a knots array that conforms to the closed path curve using the normalized parameter value sequence according to a preset array generation method; S4: Substitute the values ​​of each knot node in the knots array, the order required for the closed path curve, and the parameter values ​​corresponding to each interpolation point into the Cox-de Boor recursive formula to calculate the coefficients of each control point of the closed path curve; S5: The coefficients of all control points form a left-multiplied matrix, the control points of the closed path curve are preset, and the number of control points is equal to the number of interpolation points in S1. The coordinates of the control points of the closed path curve form a right-multiplied vector, and the interpolation points in S1 form an interpolation point vector. A linear equation system is constructed by the left-multiplied matrix, the right-multiplied vector, and the interpolation point vector. After converting the linear equation system into an upper triangular or stepped form, the coordinates of all control points are obtained. S6: Preset the weight of each control point, and in the knots array, use the knots node with the subscript of the order that the closed path curve needs to reach as the starting knots node, and the nth node after the starting knots node as the ending knots node. The value of the starting knots node and the value of the ending knots node constitute the parameter interval range, so that the NUBRS parameter changes continuously within the parameter interval range. Under each NUBRS parameter, an actual point on the closed path curve is generated by the coefficient of the control point, the weight of the control point and the coordinates of the control point. All the generated actual points constitute a closed path curve that meets the requirements. Finally, the generated closed path curve is used as the generated path for drawing roads, rivers or mountains using terrain tools in the game engine.

2. The method for generating a two-dimensional interpolation closed curve based on NUBRS according to claim 1, wherein: In step S2, the parameter value corresponding to the interpolation point is generated by using the cumulative chord length parameterization method, specifically: S21. Selecting the first interpolation point as the parameterization starting point according to the preset interpolation point selection order, presetting the parameter value of the first interpolation point, and setting the parameter value of the first interpolation point as the first element of the parameter value sequence; S22. Starting from the first interpolation point, sequentially calculate the Euclidean distance between two adjacent interpolation points, and use the calculated Euclidean distance as the approximate arc length of the curve segment formed by the two adjacent interpolation points; S23. For each interpolation point other than the first interpolation point, add up all approximate arc lengths from each interpolation point to the first interpolation point as the cumulative arc length, and add the cumulative arc length corresponding to each interpolation point to the parameter value of the first interpolation point to obtain the parameter value corresponding to each of the remaining interpolation points; S24. The generated parameter values ​​are sequentially stored in the parameter value sequence according to a preset interpolation point selection order. The approximate arc length from the last interpolation point to the first interpolation point and the parameter value of the last interpolation point are added together to obtain the approximate perimeter of the closed path curve. A new interpolation point is preset so that it coincides with the first interpolation point and serves as the parameterization termination point. The approximate perimeter of the closed path curve is used as the parameter value corresponding to the new interpolation point. The parameter value corresponding to the new interpolation point is used as the last element of the parameter value sequence to obtain a final parameter value sequence. S25. Normalize the final parameter value sequence to obtain a normalized parameter value sequence.

3. The method for generating a two-dimensional interpolation closed curve based on NUBRS according to claim 1, wherein: In step S3, the specific process of generating the knots array according to the preset array generation method is as follows: a knots array of size 2×degree+1+n is pre-built, and starting from the starting knots node, the value of each knot in the knots array is obtained from the normalized parameter value sequence; where degree represents the order required to close the path curve, and n represents the number of interpolation points; For the knots node with subscript m in the knots array, determine the range of the knots node subscript and calculate the value of the knots node according to the determination result: When the subscript m of the knots node is between [degree, degree+n], the value of the knots node with subscript m, Knots[m], is: Knots[m]=t m-degree Where, t m-degree Represents the (m-degree+1)th element in the normalized parameter value sequence; When the subscript m of the knots node is between [0, degree-1], the value of the knots node with subscript m, Knots[m], is: Knots[m]=Knots[degree]-(t n -t n-degree+m ) Where, Knots[degree] represents the value of the starting knots node; t n Represents the n+1th element in the normalized parameter value sequence; t n-degree+m Represents the (n-degree+m+1)th element in the normalized parameter value sequence; When the subscript m of the knots node is between [degree+n+1,2×degree+n], the value of the knots node with subscript m, Knots[m], is: Knots[m]=Knots[degree+n]-(t m-degree-n -t0) Where, Knots[degree+n] represents the value of the knots node with the subscript (degree+n); m-degree-n It represents the (m-degree-n+1)th element in the normalized parameter value sequence; t0 represents the first element in the normalized parameter value sequence.

4. The method for generating a two-dimensional interpolation closed curve based on NUBRS according to claim 1, wherein: In step S5, the linear equations are converted into upper triangular or ladder form using LU decomposition method.

5. The method for generating a two-dimensional interpolation closed curve based on NUBRS according to claim 1, wherein: In step S6, the weight of each control point is set to 1 by default.

6. The method for generating a two-dimensional interpolation closed curve based on NUBRS according to claim 4, wherein: In step S6, an actual point P(K) on the closed path curve is generated as follows: Among them, N i,degree (u) indicates that the order is degree and the domain is [u i ,u i+1 ] and the value of the NUBRS basis function when the NUBRS parameter is u; R i represents the weight of the i-th control point; P i Represents the coordinates of the i-th control point.

Citation Information

Patent Citations

  • Closed non-uniform rational B-spline curve fairing method based on genetic algorithm

    CN103413175A

  • Blade modeling method for hydraulic torque converter

    CN114117666A