Interpolation two-dimensional closed curve generation method based on NUBRS
Through the NURBS-based interpolated two-dimensional closed curve generation method, the problems of local adjustment of curves and numerical stability in the prior art are solved, and closed path curves that meet specific geometric requirements are efficiently generated, which is suitable for complex engineering design and high-precision manufacturing.
Patent Information
- Application Number
- CN202411040297.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-07-31
AI Technical Summary
Existing closed curve generation methods have difficulties in local adjustment and numerical stability, especially when the Bezier curve and polynomial curve may oscillate in some areas, and the implicit curve does not provide parameterized forms, resulting in difficult path planning.
Using the NURBS-based interpolated two-dimensional closed curve generation method, the parameter value sequence is generated by obtaining interpolated points and orders, and the knots array is constructed. The control point coefficient is calculated using the Cox-de Boor recursive formula, and the linear equation system is constructed and converted into an upper triangle. , generate a closed path curve that meets specific geometric requirements.
It realizes the rapid calculation of the initial control point of the NURBS curve, generates highly continuity and accurate closed path curves, suitable for complex engineering design and high-precision manufacturing, meeting specific geometric requirements.
Smart Images

Figure CN118965479A_ABST
Abstract
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 and smooth two-dimensional curves is crucial in graphic design, computer-aided design, animation, and game development. In the terrain drawing function of game engines, it is often used to generate paths for roads, rivers, or mountains. In the field of design, closed curves are often used to create patterns, logos, and works of art. In the fields of 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 the field of 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 robots to ensure that they complete tasks safely and efficiently.
[0003] For other types of closed curves, all control points of Bezier-based closed curves have an impact on the entire curve, which may make local adjustments of the curve difficult. For polynomial-based curves, 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, which makes 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 the curve joints, avoiding sharp corners or discontinuities. NURBS curves can approximate any continuous curve with arbitrary precision, which means that they can be used in fields that require high-precision design, such as aerospace, automotive design, etc.
[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 the design according to parameter changes. It is a standardized geometric representation method that is widely supported in 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 CNC machining (CNC) 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 desired 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 invention object, the present invention specifically adopts the following technical solutions:
[0010] A method for generating an interpolated two-dimensional closed curve based on NUBRS comprises the following steps:
[0011] S1: In the terrain drawing of the game engine, 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 are obtained, and at the same time, the number of interpolation points n is 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, and form a parameter value sequence with 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 knots 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 multiplication matrix, the control points of the closed path curve are preset, 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 multiplication vector, the interpolation points in S1 form an interpolation point vector, and a linear equation system is constructed by the left multiplication matrix, the right multiplication vector and the interpolation point vector. After converting the linear equation system into an upper triangle or ladder type, 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 parameter range is composed of the value of the starting knots node and the value of the ending knots node, so that the NUBRS parameter changes continuously within the parameter 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. A closed path curve that meets the requirements is composed of all the generated actual points. 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 scheme, 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 cumulative chord length parameterization, specifically:
[0019] S21. According to the preset interpolation point selection order, the first interpolation point is used as the parameterization starting point, and the parameter value of the first interpolation point is preset, and the parameter value of the first interpolation point is used as the first element of the parameter value sequence;
[0020] S22. Starting from the first interpolation point, the Euclidean distance between two adjacent interpolation points is calculated in sequence, and the calculation result of the Euclidean distance is used as the approximate arc length of the curve segment formed by the two adjacent interpolation points;
[0021] S23. For each interpolation point except the first interpolation point, all approximate arc lengths from each interpolation point to the first interpolation point are accumulated as the cumulative arc length, and the cumulative arc length corresponding to each interpolation point is added to the parameter value of the first interpolation point to obtain the parameter value corresponding to each interpolation point;
[0022] S24. The generated parameter values are sequentially saved in the parameter value sequence according to the preset interpolation point selection order, the approximate arc length between the last interpolation point and the first interpolation point is added to the parameter value of the last interpolation point as 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, and 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 knots 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, a practical 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 method for generating a two-dimensional closed interpolation curve based on NURBS. The method uses a set of points on a given two-dimensional plane and corresponding geometric constraints to quickly calculate the initial control points of the NURBS curve. The method can effectively generate a two-dimensional closed NURBS curve that meets specific geometric requirements. In addition, the NURBS closed path curve generation method of the present invention can be widely used in computer-aided design (CAD), engineering analysis, manufacturing, animation production and other fields, and has good practicality and broad application prospects. The NURBS closed path curve generated by the method has a high degree of geometric continuity and accuracy, and can meet 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 by 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 purpose, features and advantages of the present invention more obvious and easy to understand, the specific implementation mode of the present invention is described in detail below in conjunction with 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 different from 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 each embodiment 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 only used for the purpose of distinguishing descriptions, and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the 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 satisfy that the number of interpolation points is 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 required for the closed path curve (that is, the geometric continuity required for the closed path curve), and 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 2D 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 respectively 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 should be noted that in two-dimensional space, the geometric path of a curve starts from a set of discrete control points. These control points are the basis of curve design and determine the basic shape of the curve. In order to ensure that the generated closed path curve meets specific geometric continuity requirements, the order of the curve must be specified. This is the degree of the curve polynomial, which directly affects the smoothness and differentiability of the curve and determines the smoothness and bending ability of the curve.
[0052] In the context of NURBS (Non-Uniform Rational B-Splines) curves, the order is often associated with the level of continuity of the curve, 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, you must ensure that the number of control points is at least equal to the requirement of the curve's order. This is because each additional order requires more control points to maintain the local control properties of the curve. 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 the interpolation points in a specific parameterization manner, and construct a parameter value sequence from all the 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 used as the parameterization starting point, and the parameter value t0=0 of the first interpolation point is preset, and the parameter value of the first interpolation point is used as the first element of the parameter value sequence.
[0057] S22. Straight-line distance calculation: Starting from the first interpolation point, the Euclidean distance between two adjacent interpolation points is calculated in sequence, and the calculation result of the Euclidean distance is used 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 interpolation point to the first interpolation point are accumulated as the cumulative arc length, and the cumulative arc length corresponding to each interpolation point is added to the parameter value of the first interpolation point as the parameter value corresponding to each interpolation point.
[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 adds its corresponding cumulative arc length 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 interpolation point and the second interpolation point. 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 as 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. The parameter value of the third interpolation point (x3, y3) is t2=t0+d0+d1. Continue to calculate 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, the parameter value t1=t0+d0 of the second interpolation point (x2, y2) can be obtained first. Then, starting from the third interpolation point, you only need to obtain 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. Similarly, 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: the generated parameter values are saved in the parameter value sequence in sequence according to the preset interpolation point selection order, the approximate arc length from the last interpolation point to the first interpolation point is added to the parameter value of the last interpolation point as 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, and the parameter value corresponding to the new interpolation point is used 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 made to coincide with the first interpolation point to ensure the parameter continuity of the closed path curve, so that the parameter values of the last interpolation point and the first interpolation point in the parameter value sequence smoothly transition to form a seamless loop. By accumulating parameter values in this way, each interpolation point will obtain a corresponding parameter value. The final parameter value sequence contains a total of n+1 parameter values.
[0065] like Figure 2 As shown, 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 the distance between it and 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] A knots array of size 2×degree+1+n is pre-constructed. In the knots array, the knots node with the subscript of the degree required for the closed path curve is used as the starting knots node. Starting from the starting knots node, the value of each knots 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 based on the determination result:
[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 degree 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 embodiment, 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 in the NURBS curve for weighting control points and defining 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) Construction of knots array: According to the generation rules of NURBS curves, the knots array must meet certain conditions to ensure the correctness and continuity of the curve. The size of the knots 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 knots array: The subscript of the knots array starts from 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 in the knots array: Starting from the position of the knots array with the index degree, 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 at both ends of the knots array: For the first degree nodes of the knots array, generate them according to the last parameter value generated in step S2 and the interval between these parameter values. This can be determined by equal intervals or according to 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 in 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 knots node in the knots array, the order required to close the 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] In the formula, 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 function of the NURBS curve is defined by the knot vector and the curve order, and the generation of the basis function follows the Cox-de Boor recursive formula or the definition of the B-spline basis function. Each basis function has at most degree non-zero values in the entire definition domain of the parameter, which means that under any parameter value, only the basis functions with the same number of degrees will contribute to the curve points at the same time. Substitute the parameter values corresponding to each interpolation point into the COX-DE BOOR recursive formula in turn, calculate the value of each basis function under the parameter, and you can get n vectors, each vector represents the basis function value under a specific parameter, that is, get the coefficient 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 cof1=(a1, b1, c1, ...) of the first control point. The coefficient is a vector with a dimension of n. According to the characteristics of the basis function, each coordinate coefficient of this vector has at most degree non-zero values. The parameter values corresponding to the remaining interpolation points t1, t2, ..., t n-1 Substituting into the above COX-DE BOOR recursive formula, we can get 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 the 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 right multiplication vector X=((p x1 ,p y1 ),(p x2 ,p y2 ),...,(p xn ,p yn )) T , the interpolation point vector b is formed by the interpolation points in S1 = ((x1, y1), (x2, y2)...... (x n ,y n)) T , a linear equation system AX=b is constructed by multiplying the matrix A on the left, the vector X on the right, and the interpolation point vector b. After the linear equation system is transformed into an upper triangle or ladder type, the coordinates of all control points are obtained. In the formula, 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 Respectively represent the horizontal coordinates of the 1st, 2nd, ... nth control points in the two-dimensional plane coordinates; p y1 ,p y2 ,.....,p yn They respectively represent the vertical coordinates of the 1st, 2nd,...nth control points in the two-dimensional plane.
[0102] It should be noted that, in this embodiment, the vectors of the coefficients representing the control points are combined into a left multiplication 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 order into a right multiplication vector, which 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 equation system is established through the linear combination of basis functions and control points. The linear equation system links the control points with 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 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 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. A closed path curve that meets the requirements is composed of all the generated actual points. 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 by the calculated control point coordinates using the following NUBRS generation formula. 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 between two specific nodes in the knots array, that is, between the 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 obtain 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 contribution of the control points to the shape of the closed path curve is equivalent. Different weight settings can be used to adjust the curvature of the closed path curve near the control point.
[0110] The 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 closed path curve without sharp corners or discontinuities, and provides precise control over the shape of the curve. By adjusting the control points and weights, the shape of the curve can be precisely 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 two-dimensional closed curve interpolation generation method based on NURBS. The method uses a set of given points on a two-dimensional plane and corresponding geometric constraints to quickly calculate the initial control points of the NURBS curve. The method can effectively generate a two-dimensional closed NURBS curve that meets specific geometric requirements. In addition, the NURBS closed path curve generation method of the present invention can be widely used in computer-aided design (CAD), engineering analysis, manufacturing, animation production and other fields, and has good practicality and broad application prospects. The NURBS closed path curve generated by the method has a high degree of geometric continuity and accuracy, and can meet the requirements of complex engineering design and high-precision manufacturing.
[0112] The above-described embodiment is only a preferred solution of the present invention, but it is not intended to limit the present invention. A person skilled in the relevant technical field may make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, any technical solution obtained by equivalent replacement or equivalent transformation falls within the protection scope 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, 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 are obtained, and at the same time, the number of interpolation points n is 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, and form a parameter value sequence with 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 knots 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 multiplication matrix, the control points of the closed path curve are preset, 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 multiplication vector, the interpolation points in S1 form an interpolation point vector, and a linear equation system is constructed by the left multiplication matrix, the right multiplication vector and the interpolation point vector. After converting the linear equation system into an upper triangle or ladder type, 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 parameter range is composed of the value of the starting knots node and the value of the ending knots node, so that the NUBRS parameter changes continuously within the parameter 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. A closed path curve that meets the requirements is composed of all the generated actual points. 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. A method for generating a two-dimensional interpolation closed curve based on NUBRS as claimed in claim 1, characterized in that: In step S2, the parameter value corresponding to the interpolation point is generated by cumulative chord length parameterization, specifically: S21. According to the preset interpolation point selection order, the first interpolation point is used as the parameterization starting point, and the parameter value of the first interpolation point is preset, and the parameter value of the first interpolation point is used as the first element of the parameter value sequence; S22. Starting from the first interpolation point, the Euclidean distance between two adjacent interpolation points is calculated in sequence, and the calculation result of the Euclidean distance is used as the approximate arc length of the curve segment formed by the two adjacent interpolation points; S23. For each interpolation point except the first interpolation point, all approximate arc lengths from each interpolation point to the first interpolation point are accumulated as the cumulative arc length, and the cumulative arc length corresponding to each interpolation point is added to the parameter value of the first interpolation point to obtain the parameter value corresponding to each interpolation point; S24. The generated parameter values are sequentially saved in the parameter value sequence according to the preset interpolation point selection order, the approximate arc length between the last interpolation point and the first interpolation point is added to the parameter value of the last interpolation point as 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, and 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. A method for generating a two-dimensional interpolation closed curve based on NUBRS as claimed in claim 1, characterized in that: In step S3, the specific process of generating the knots array according to the preset array generation method is as follows: pre-construct a knots array of size 2×degree+1+n, start from the starting knots node, and obtain the value of each knots 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; 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. A method for generating a two-dimensional interpolation closed curve based on NUBRS as claimed in claim 1, characterized in that: 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, characterized in that: In step S6, the weight of each control point is set to 1 by default.
6. A method for generating a two-dimensional interpolation closed curve based on NUBRS as claimed in claim 4, characterized in that: In step S6, a practical 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
Blisk grinding and polishing non-interference area generation method
CN115841001A
Method and apparatus of inputting and outputting color pictures and continually changing tone pictures
KR1019980046610A
