Imitation of a Pre-Designed Irregular 3D Yarn in Given Fabric Structures

The 3D CAD software has obvious advantages in appearance imitating and geometric structure modeling for fabrics. In contemporary 3D CAD fabric systems, only uniform yarns are involved in studies on fabric geometric structures, due to technological limitations, whereas objectives such as irregular/uneven 3D yarns have not been considered much. As the fabric structure or the central curve of the yarn changes, it is difficult to reflect the changed positions of the effect spots of the pre-designed uneven 3D yarns accordingly. In this paper, a key-point-mapping algorithm between the source yarn and the target curve is proposed to reflect the position change in effect spots when the fabric structure changes. By using the shape-preserving quasi-uniform cubic B-spline curve, a simple 3D irregular source yarn is designed using key points and setting their corresponding base cross-sections. The mapping is based on the principle that the lengths of the curve between the key points and the contours of the corresponding base cross-sections of the source yarn remain unchanged. Finally, the control grid of the new 3D yarn in the fabric structure is automatically generated. According to the examples and error analysis, the mapping technique can be applied to arbitrary given fabric structures, and the effect spots of the irregular 3D yarn are reasonably distributed as expected.


Introduction
The geometric structure of fabric is the extending and bending form of yarns in the three-dimensional space, which has a great influence on the appearance, physical properties and processing difficulty of fabric. Usually, the geometrical structure of fabric can be described in terms of two aspects: the cross-section of yarns and the central curve of yarns. The geometric structure affects almost all the properties of the fabric-appearance, strength, flexibility, drapability, porosity which is related to thermal insulation property, air ventilation, vapor permeability and electromagnetic performance. An accurate geometry model is used to imitate the appearance and pattern of the fabric, estimate the properties of the fabric, shorten the design and production cycle significantly and provide the basic data for apparel and industrial fabric design.
A computer-aided design (CAD) system for fabrics is widely used by designers to predict the appearance and geometrical structure of the fabric before weaving or knitting. After inputting the specifications of fabrics, the imitated image appears on the screen of the computer, which helps the designer to evaluate the design. Then, 2D graphical technology are normally used in the CAD systems, providing a quick and easy way to fulfill the target of imitation. Various types of yarns, uniform yarn or irregular yarns, are applied in design. When changing the fabric specification, CAD systems demonstrate the distribution of the effect spots of uneven fancy yarns on the fabric surface. However, the realism of imitation with 2D technology needs to improve dramatically as the edges of the yarns are blurred in the imitated image and the shading of the fabric is poor. There is another serious drawback that the 3D geometrical structure of the fabric is unavailable, which limits the application In Li's [9] study, these three control parameters were arranged freely along the cen tral line of the uneven 3D yarn, and the yarns were only used to convert into 2D images to determine the evenness of yarns or Moire effects of the fabric. All the yarns were ar ranged in straight form, which could not reflect their real bent status in a fabric structure

Representation of 3D Irregular Yarns
In this paper, 3D slub yarns are modeled by a shape-preserving quasi-uniform B spline surface with OpenGL technology [10] as in Zheng [7]. Figure 2 illustrates the form ing principle of the 3D yarn surface. The central curve of the yarn is represented by a shape-preserving quasi-uniform cubic B-spline curve (SPQUCBSC), which is determined by a series of key points as shown in Figure 2a. Each base cross-section corresponding to the key point of the yarn is characterized by a quasi-uniform quadratic B-spline curve which is also defined by a series of control points in Figure 2c. The cross-section could be of an ellipse, or other shapes such as a racetrack or lens. The base cross-section C1 paral leling to YOZ plane in Figure 2a is used to calculate its shape conveniently. Then, all the base cross-sections are rotated to be perpendicular to the central curve to form cross-sec tions such as C2. The control points of each cross-section are rotated accordingly, creating the final B-spline control grid that determines the yarn shape as shown in Figure 2b. In Li's [9] study, these three control parameters were arranged freely along the central line of the uneven 3D yarn, and the yarns were only used to convert into 2D images to determine the evenness of yarns or Moire effects of the fabric. All the yarns were arranged in straight form, which could not reflect their real bent status in a fabric structure.

Representation of 3D Irregular Yarns
In this paper, 3D slub yarns are modeled by a shape-preserving quasi-uniform B-spline surface with OpenGL technology [10] as in Zheng [7]. Figure 2 illustrates the forming principle of the 3D yarn surface. The central curve of the yarn is represented by a shapepreserving quasi-uniform cubic B-spline curve (SPQUCBSC), which is determined by a series of key points as shown in Figure 2a. Each base cross-section corresponding to the key point of the yarn is characterized by a quasi-uniform quadratic B-spline curve, which is also defined by a series of control points in Figure 2c. The cross-section could be of an ellipse, or other shapes such as a racetrack or lens. The base cross-section C 1 paralleling to YOZ plane in Figure 2a is used to calculate its shape conveniently. Then, all the base cross-sections are rotated to be perpendicular to the central curve to form cross-sections such as C 2 . The control points of each cross-section are rotated accordingly, creating the final B-spline control grid that determines the yarn shape as shown in Figure 2b.
A B-spline curve is determined by a series of control points, but an ordinary uniform B-spline curve does not go through the control points. From a designer's perspective, the curve is expected to go through all the key points or interpolating points to ensure its shape. In order to meet the requirement, the inverse calculation is generally adopted, which is easily disturbed by the fluctuation of boundary conditions, however. To solve the problem, a robust algorithm was proposed in Zheng [7] that inserting additional control points would ensure the curve goes through the key points. Figure 3a shows an uneven yarn that goes through the given key points. The red dots are the key points controlling the central curve of the yarn as shown in Figure 3b. Two blue dots are automatically generated and inserted before and behind each red point (two end key points are excluded), as shown in Figure 3b, respectively, and each red key point locates at the midpoint of the segment line connecting the adjacent blue dots. Figure 3c shows the cross-sections of the yarn corresponding to all key points, and the sections are perpendicular to the center curve. Figure 3d shows the yarn control grid formed by connecting the control points of all cross-sections. To produce a uniform yarn, all the base cross-sections should be kept A B-spline curve is determined by a series of control points, but an ordinary uniform B-spline curve does not go through the control points. From a designer's perspective, the curve is expected to go through all the key points or interpolating points to ensure its shape. In order to meet the requirement, the inverse calculation is generally adopted, which is easily disturbed by the fluctuation of boundary conditions, however. To solve the problem, a robust algorithm was proposed in Zheng [7] that inserting additional control points would ensure the curve goes through the key points. Figure 3a shows an uneven yarn that goes through the given key points. The red dots are the key points controlling the central curve of the yarn as shown in Figure 3b. Two blue dots are automatically generated and inserted before and behind each red point (two end key points are excluded), as shown in Figure 3b, respectively, and each red key point locates at the midpoint of the segment line connecting the adjacent blue dots. Figure 3c shows the crosssections of the yarn corresponding to all key points, and the sections are perpendicular to the center curve. Figure 3d shows the yarn control grid formed by connecting the control points of all cross-sections. To produce a uniform yarn, all the base cross-sections should be kept unchanged. If the base cross-sections are different in shape or size, an uneven 3D yarn with a slub effect will be modeled. When there are some larger cross-sections in a short distance, and then a slub knot will be designed. Therefore, each slub knot presents two aspects: the center of the cross-section and the shape of the cross-section. If a long slub knot is expected, and then there will be a long distance between the two key points where the two corresponding cross-sections are both larger than the normal one in size.  Usually, it is sufficient to design a straight slub yarn in a 2D CAD system. However, for universal applications, a curved irregular 3D yarn is created in this paper. The data of the control points of the cross-sections and the central line of the uneven 3D yarn as shown in Figure 3 or Figure 4a are listed in the Appendix A.1. The file format was illustrated in Zheng [11]. According to line 3 of the data, a 29 tex irregular yarn with a radius of approximately 0.069 mm is created and its shape is determined by 13 elliptical cross-sections. The following lines indicate the information of each cross-section, including the XYZ coordinates of the centers, types of the cross-sections and the related parameters. From the data, two cross-sections (Index No 5, and No 9, indexed from No 0) are enlarged by 1.7-and 1.4-fold, respectively. Therefore, the effect spots are formed at cross-section No 5 and No 9. It should be noted that there is only one key point controlling the location of the slub effect spot for each cross-section, so the length of the slub is not considered in the following description. Therefore, the slub length of the effect spot may change in the following examples although its relative position is fixed. Usually, it is sufficient to design a straight slub yarn in a 2D CAD system. However, for universal applications, a curved irregular 3D yarn is created in this paper. The data of the control points of the cross-sections and the central line of the uneven 3D yarn as shown in Figure 3 or Figure 4a are listed in the Appendix A.1. The file format was illustrated in Zheng [11]. According to line 3 of the data, a 29 tex irregular yarn with a radius of approximately 0.069 mm is created and its shape is determined by 13 elliptical cross-sections. The following lines indicate the information of each cross-section, including the XYZ coordinates of the centers, types of the cross-sections and the related parameters. From the data, two cross-sections (Index No 5, and No 9, indexed from No 0) are enlarged by 1.7-and 1.4-fold, respectively. Therefore, the effect spots are formed at cross-section No 5 and No 9. It should be noted that there is only one key point controlling the location of the slub effect spot for each cross-section, so the length of the slub is not considered in the following description. Therefore, the slub length of the effect spot may change in the following examples although its relative position is fixed.

Description of the Geometrical Structure of Fabric
The geometrical structure of fabric is defined as the spatial status of the constitute threads. If the central curve of each constituent thread is correctly described, and then the 3D fabric structure is modelled. In this paper, the geometric structure of fabric is given by either calculating or measuring results. The central curve of a single thread in fabric is described as target curve which is controlled by a series of key points with X coordinates, Y coordinates and Z coordinates. A good example is shown in the Appendix A.2, where 10 central points of cross-sections are set to define the central curve of the single yarn in a given geometric structure repeat unit. As regards to the contour of the cross-sections, there is an assumption that no elongation and flatness occur when the yarn changes its path as this paper purely deals with a geometrical model rather than a physical model of the fabric structure. Therefore, the cross-sections of the source yarn will be copied directly to the yarns in fabric so that the effect spots of the source yarn will be kept.

Mathematical Expression of the Problem
To reflect an irregular/uneven 3D yarn in the fabric structure, it is necessary to investigate how the effect spots change their spatial positions when the central curve of the yarn changes freely. Figure 4a shows a 3D slub yarn with two knot effects in a repeat unit. If the central curve of the yarn changes from Figure 4b to Figure 4c, the change in the positions of the knots is shown in Figure 4d. In this converting procedure, the control points for the central curve of the new yarn are shown in Figure 4e.  From a mathematical point of view, the process can be described as the following sentences. Surface Y (the actual shape of the pre-designed source yarn) and surface F (the actual configuration of yarn in the fabric structure) are both modelled by a cubic B-spline surface. Both the central curves of the two surfaces are of SPQUCBSCs, and the base crosssections are modelled by a quasi-uniform quadric B-spline curve. The key points sequence for central curve P of surface Y are given by the design process, and then the control points for the corresponding base cross-sections can be calculated accordingly. The sequence of key control points for the central curve D of surface F is also given by calculating or measuring the fabric structure.
To model a 3D yarn based on target curve D with OpenGL, the cross-sections should be calculated and assigned along curve D at the effect spots determined by key points at central curve P and the key points to determine the base cross-sections of the curve. Therefore, the key to the solution is to calculate the coordinates of the control points for the corresponding cross-sections on surface F according to surface Y of the source yarn. From a mathematical point of view, the process can be described as the following sentences. Surface Y (the actual shape of the pre-designed source yarn) and surface F (the actual configuration of yarn in the fabric structure) are both modelled by a cubic B-spline surface. Both the central curves of the two surfaces are of SPQUCBSCs, and the base crosssections are modelled by a quasi-uniform quadric B-spline curve. The key points sequence for central curve P of surface Y are given by the design process, and then the control points for the corresponding base cross-sections can be calculated accordingly. The sequence of key control points for the central curve D of surface F is also given by calculating or measuring the fabric structure.
To model a 3D yarn based on target curve D with OpenGL, the cross-sections should be calculated and assigned along curve D at the effect spots determined by key points at central curve P and the key points to determine the base cross-sections of the curve. Therefore, the key to the solution is to calculate the coordinates of the control points for the corresponding cross-sections on surface F according to surface Y of the source yarn.
Generally, an arbitrary point D s on the central curve D of surface F is set as the mapping start, and its counterpart point P s is also set arbitrarily on central curve P of surface Y. It is necessary to find the spatial coordinates of a random point D k (to be located) with a given distance of L behind the point D s along curve D and the spatial coordinates of the control points of the corresponding cross-sections on curve D.
To sum up, the idea to solve the change in the yarn central curve is to find the mapping relationship between the corresponding points and the cross-section from any given point on central curve P of surface Y to the central curve D of surface F when a pair of corresponding mapping starting points P s on curve P and D s on curve D are set. Key point mapping is used to solve the problem proposed in this paper. The method of mapping is to insert the key points from central curve P and the corresponding base cross-sections for surface Y to target curve D within a certain range of mapping length, and then combine them together to form a control grid of the new yarn. In this new control grid, the centers of the cross-sections are all on the target curve. Before mapping, two conditions have to be designated: (1) the positions on curve D for inserting the key points of curve P and (2) the corresponding base cross-sections at the original key points of curve D, which is why this process is named key point mapping. According to the principle that the length of the curve between the adjacent key points along source yarn Y remains unchanged, all the key points of curve P are inserted onto curve D, and generate a new curve, D 1 , which has the same shape of the original target curve, D. In practice, curve D 1 is generated by copying curve D firstly. All the base cross-sections of surface Y are used to assign the cross-sections onto surface F. At each original key point on curve D 1 , the corresponding base cross-section is automatically generated in proportion to the curve distance of the key points with the known sections just added before and after on curve D 1 . If a pair of corresponding points on curve P and D for the mapping are set at different positions, the proportion will change and the contour of the new yarn will also change.

Mapping Steps
The key-point-mapping processes are illustrated in the following diagrams. In Figure 5, we assume that central curve P of the source yarn is controlled by the sequence of key points {P 0 , P 1 , . . . , P 6 }, which are also the centers of the base cross-sections. In Figure 5, target curve D is controlled by the sequence of key points {D 0 , D 1 , . . . , D 4 }, which actually describes the geometric path of the yarn in the fabric structure. The change in curve D means the change in the geometry of the fabric. According to the algorithm of modelling the SPQUCBSC, curve lengths between every two neighboring key points along curve P are {L 0 , L 1 , . . . , L 5 } as shown in Figure 5a. For curve D, the curve lengths between every two neighboring key points are {K 0 , K 1 , . . . , K 3 } as shown in Figure 5b. In order to ensure that the new yarn has a path following that of target curve D and maintains the contour of the cross-sections as in surface Y, the key points of curve P and curve D are combined to form a new central curve D 1 as the central path of the new yarn. The simplest mapping method is that P 0 on the point curve P corresponds to point D 0 on curve D. The key mapping steps are described as follows: neighboring key points are {K0, K1, …, K3} as shown in Figure 5b. In order to ensure that the new yarn has a path following that of target curve D and maintains the contour of the cross-sections as in surface Y, the key points of curve P and curve D are combined to form a new central curve D 1 as the central path of the new yarn. The simplest mapping method is that P0 on the point curve P corresponds to point D0 on curve D. The key mapping steps are described as follows: (1) If central curve P is straightened, the distance between the key points will be {L0, L1, …, L5}. Take the starting point as the coordinate origin, and obtain X coordinates of each corresponding key point along the X axis, as shown in Figure 6a.
(2) Similarly, straighten the central curve D and the lengths between each 2 adjacent key points along central curve D are {K0, K1, …, K3}. Take the starting point as the coordinate origin, and obtain X coordinates of each corresponding key point along the X axis, as shown in Figure 6b.
(3) According to the curve length between 2 adjacent key points along the source yarn P, the key point of the source yarn Pi (i = 0, 1, …, 5, and i is an integer number in this paper) corresponds to point Pi 1 on the new curve D 1 . Meanwhile, the contour of the corresponding base cross-section at Pi on curve D is obtained and assigned to the base cross-section at Pi 1 on curve D 1 .
(4) Calculate the distance Lm and Ln between the key point De (e can be any integer less than the number of the key points, 0 < e < 4 for this example) on curve D 1 and the newly inserted nearest key points PM 1 and PM+1 1 on each side. Calculate all control points of the base cross-section corresponding to De according to the distance proportion. (1) If central curve P is straightened, the distance between the key points will be {L 0 , L 1 , . . . , L 5 }. Take the starting point as the coordinate origin, and obtain X coordinates of each corresponding key point along the X axis, as shown in Figure 6a.
(2) Similarly, straighten the central curve D and the lengths between each 2 adjacent key points along central curve D are {K 0 , K 1 , . . . , K 3 }. Take the starting point as the coordinate origin, and obtain X coordinates of each corresponding key point along the X axis, as shown in Figure 6b.
(3) According to the curve length between 2 adjacent key points along the source yarn P, the key point of the source yarn P i (i = 0, 1, . . . , 5, and i is an integer number in this paper) corresponds to point P i 1 on the new curve D 1 . Meanwhile, the contour of the corresponding base cross-section at P i on curve D is obtained and assigned to the base cross-section at P i 1 on curve D 1 . (4) Calculate the distance L m and L n between the key point D e (e can be any integer less than the number of the key points, 0 < e < 4 for this example) on curve D 1 and the newly inserted nearest key points P M 1 and P M+1 1 on each side. Calculate all control points of the base cross-section corresponding to D e according to the distance proportion.
(5) According to X coordinates by straightening the curve (distance L i from the key point to the starting point on the source yarn P, or K i from the key point on target curve D to the mapping starting point), all the key points on curve P and curve D are mixed orderly in sequence to form the new central curve D 1 . Meanwhile, the corresponding base cross-sections are also arranged according to the order of these key points as shown in Figure 6c. (6) Rearrange the sequence of key points similar to curve D. According to the distance of key point P i after an arbitrary key point D k , the order of sections of SPQUCBSC and parameter t are obtained for P i 2 , which is the corresponding point on curve D to key point P i 1 . Then, the XYZ coordinates of key point P i 2 are calculated, and the XYZ coordinates of the control points for the corresponding base cross-sections are revised again by proportion. Based on the cross-section order determined in Step (5), a B-spline surface control mesh centered on curve D 1 is formed to construct the uneven 3D slub yarn. Figure 7 is the schematic diagram showing the positions and sequence of key points on the newly generated curve. Pi 1 . Then, the XYZ coordinates of key point Pi 2 are calculated, and the XYZ coordinates of the control points for the corresponding base cross-sections are revised again by proportion. Based on the cross-section order determined in Step (5), a B-spline surface control mesh centered on curve D 1 is formed to construct the uneven 3D slub yarn. Figure 7 is the schematic diagram showing the positions and sequence of key points on the newly generated curve.  Therefore, the algorithm for free conversion of the central curve of an irregular 3D yarn is as follows. (1) Calculate the distances between the key points along the central curve, which is the basis for the next three steps. (2) Find the counterpart of the key points Pi 1 . Then, the XYZ coordinates of key point Pi 2 are calculated, and the XYZ coordinates of the control points for the corresponding base cross-sections are revised again by proportion. Based on the cross-section order determined in Step (5), a B-spline surface control mesh centered on curve D 1 is formed to construct the uneven 3D slub yarn. Figure 7 is the schematic diagram showing the positions and sequence of key points on the newly generated curve.  Therefore, the algorithm for free conversion of the central curve of an irregular 3D yarn is as follows. (1) Calculate the distances between the key points along the central curve, which is the basis for the next three steps. (2) Find the counterpart of the key points Therefore, the algorithm for free conversion of the central curve of an irregular 3D yarn is as follows. (1) Calculate the distances between the key points along the central curve, which is the basis for the next three steps. (2) Find the counterpart of the key points of the source yarn on the target curve and set the corresponding cross-sections. (3) Set the base cross-sections at the original key points of the target curve according to the proportional interpolation method. (4) Combine and sort all the base cross-sections reflecting the spatial state of the uneven yarn in the order of the distance to the mapping start.

Mode of Mapping
(1) Mapping from Origins Figure 7 shows the simplest mapping-both the source yarn and the target curve start from their first key points. P s , the starting point to be mapped on the source yarn, just happened to be P 0 , the first key point of curve P, while D s , the starting point corresponding to P s , is also the first key point, D 0 , of target curve D. weft yarn should be randomly changed purposely. When considering the fabric width, the starting point of the source yarn and the target curve must be different at two adjacent weft yarns in continuous weft picking. Therefore, the starting point of the mapping of the source yarn, P s , is generally not the first key point of the source yarn, or P 0 ; and the starting point of the target mapping curve, D s , is not its first key point, D 0 , either, as shown in Figure 8a,b, respectively. Let us suppose that the distance from P s to P 0 is L s , and the distance from D s to D 0 is K s . In Figure 8c, although L s < L 0 and K s < K 0 , actually L s and K s are arbitrary values without any restriction. In calculating P i 2 , the key point on the mapped curve, the pair of the starting point P s and D s are both located at the distance L s -K s from D 0 on the mapped curve, as shown in Figures 8c and 9, respectively. Figure 7 shows the simplest mapping-both the source yarn and the target curve start from their first key points. Ps, the starting point to be mapped on the source yarn, just happened to be P0, the first key point of curve P, while Ds, the starting point corresponding to Ps, is also the first key point, D0, of target curve D.
(2) Mapping from Random Points In actual fabric design and manufacturing, in order to avoid Moire effects in a large area in warp or weft directions and forming defects, the mapping starting point of warp or weft yarn should be randomly changed purposely. When considering the fabric width, the starting point of the source yarn and the target curve must be different at two adjacent weft yarns in continuous weft picking. Therefore, the starting point of the mapping of the source yarn, Ps, is generally not the first key point of the source yarn, or P0; and the starting point of the target mapping curve, Ds, is not its first key point, D0, either, as shown in Figure 8a,b, respectively. Let us suppose that the distance from Ps to P0 is Ls, and the distance from Ds to D0 is Ks. In Figure 8c, although Ls < L0 and Ks < K0, actually Ls and Ks are arbitrary values without any restriction. In calculating Pi 2 , the key point on the mapped curve, the pair of the starting point Ps and Ds are both located at the distance Ls-Ks from D0 on the mapped curve, as shown in Figures 8c and 9, respectively.
P 0 1 P 6 1 P 3 1 P 2 1 P 1 1 P 3 1 P 2 1 P 1 1 P 4 1 P 5 1 P t 1 P 4 1 Next Repeat   9 show the mapping of the target curve for a single cycle. If the length of the mapped curve is not the length of a target curve repeat, but a random length, it makes the mapping more flexible and more widely used in practice as shown in Figure  10, where the curve length of the mapping is more than one cycle.    Figures 7 and 9 show the mapping of the target curve for a single cycle. If the length of the mapped curve is not the length of a target curve repeat, but a random length, it makes the mapping more flexible and more widely used in practice as shown in Figure  10, where the curve length of the mapping is more than one cycle. By designing the cumulative mapping length (the distance from the mapping starting position Ds), the length of this mapping process and other parameters, multiple loop mapping can be achieved. If the cumulative length is very long, or the length from the starting point Ds to D0 of the target curve is very large, there must be an appropriate way to locate Ds. Therefore, it is necessary to find a way to represent the position of any point on the curve.

Sections of SPQUCBSC
A cubic B-spline curve is defined by a series of control points, and every four consecutive control points determine the expression of a curve section. Therefore, a cubic Bspline curve comprises cubic curve segments of different expressions. If the designed curve is expected to interpolate a serial of the key points P0, P1, ..., Pn, the control points of SPQUCBSC are S0, S1, ..., S3×n, the number of the control points is 3 × n + 1, the curve segments in SPQUCBSC are L0, L1, ..., L3×n−3, and the number of curve segments is 3 × n − 2. It should be mentioned that point Pi is coincidental with point Si×3 (0 ≤ i ≤ n, and i is an integer number). Figure 11 shows the curve interpolating five red key points, i.e., P0, P1, …,P4. To form such a shape-preserving curve, a sequence of 13 (5 × 3 − 2 = 13) control points {S0, S1, …, S12} is required. The curve comprises 10 (13 − 3 = 10) curve segments, expressed as {L0, L1, …, L9}. Each curve segment Li (i = 0, 1, 2, …, 9) is a cubic polynomial with different By designing the cumulative mapping length (the distance from the mapping starting position D s ), the length of this mapping process and other parameters, multiple loop mapping can be achieved. If the cumulative length is very long, or the length from the starting point D s to D 0 of the target curve is very large, there must be an appropriate way to locate D s . Therefore, it is necessary to find a way to represent the position of any point on the curve.

Sections of SPQUCBSC
A cubic B-spline curve is defined by a series of control points, and every four consecutive control points determine the expression of a curve section. Therefore, a cubic B-spline curve comprises cubic curve segments of different expressions. If the designed curve is expected to interpolate a serial of the key points P 0 , P 1 , . . . , P n , the control points of SPQUCBSC are S 0 , S 1 , . . . , S 3 × n , the number of the control points is 3 × n + 1, the curve segments in SPQUCBSC are L 0 , L 1 , . . . , L 3×n−3 , and the number of curve segments is 3 × n − 2. It should be mentioned that point P i is coincidental with point S i×3 (0 ≤ i ≤ n, and i is an integer number). Figure 11 shows the curve interpolating five red key points, i.e., P 0 , P 1 , . . . , P 4 . To form such a shape-preserving curve, a sequence of 13 (5 × 3 − 2 = 13) control points {S 0 , S 1 , . . . , S 12 } is required. The curve comprises 10 (13 − 3 = 10) curve segments, expressed as {L 0 , L 1 , . . . , L 9 }. Each curve segment L i (i = 0, 1, 2, . . . , 9) is a cubic polynomial with different multinomial coefficients. These 10 curve segments form a complete quasi-uniform cubic B-spline curve.  Between the first two key points and last two key points, there are only two curve segments of the cubic curve, respectively. In contrast, there are three curve segments of the cubic curve between the middle key points. Therefore, for these middle key points, key point Pi is the starting point of the curve segment indexed as L3*i−1 (0 < i < n). In the example shown in Figure 11, P1 is the starting point of the curve segment indexed as L2 (2 = 3 × 1 − 1). P2 is the starting point of the curve segment indexed as L5 (5 = 3 × 2 − 1), while P3 is the starting point of the curve segment indexed as L8 (8 = 3 × 3 − 1). Figure 11. Key points, control points and curve segments of a shape-preserving quasi-uniform B-spline curve.
Between the first two key points and last two key points, there are only two curve segments of the cubic curve, respectively. In contrast, there are three curve segments of the cubic curve between the middle key points. Therefore, for these middle key points, key point P i is the starting point of the curve segment indexed as L 3*i−1 (0 < i < n). In the example shown in Figure 11, P 1 is the starting point of the curve segment indexed as L 2 (2 = 3 × 1 − 1). P 2 is the starting point of the curve segment indexed as L 5 (5 = 3 × 2 − 1), while P 3 is the starting point of the curve segment indexed as L 8 (8 = 3 × 3 − 1).

Calculating the Distance between the Neighbouring Key Points
Defined by a series of control points {S 0 , S 1 , S 2 , . . . , S n }, the point S i (t) on the ith curve section of the B-spline curve defined by {S i , S i+1 , S i+2 , S i+3 } is given by Formula (1) in Pigel [12]: The transformation matrix M 3 is determined by i and n according to Zheng [7]. t is the parameter to control the position of the point on the curve. The formula can also be written as the following parametric Equation (2).
Here, x, y and z are the coordinates of the point on the curve at t. a i , b i , c i and d i (I = 1, 2, 3) are determined by matrix M 3 .
In order to calculate the length of this curve segment L i , the arc differentiate length ds is given by Equation (3): Then, the length of the curve segment s is calculated by Equation (4): Let function u(t) = m(t) Obviously, an exact integral expression to calculate the length of the curve cannot be obtained. In this case, Composite Simpson's Rule [13] is used to approximate the calculation. According to the uniform distribution of t value (0 ≤ t ≤ 1), this curve section is divided into w (must be an even integer number) subintervals to obtain w/2 sub-segments of the curve. The length of these sub-segments of the curve, G j (j = 1, 2, . . . , w/2) is calculated as: where u i (I = 0, 1, . . . , n) = u i n . According to Equations (8) and (9), the length of the curve segment L i defined by control points S i , S i+1 , S i+2 , and S i+3 is approximately calculated as the sum of the sub-segments of the curve as shown in Equation (10).
The larger the even number w, the more accurate the calculation.

Definition of Anterior and Posterior on a Curve
On the curve, there are two points A and B, respectively, and the distances between the two points to the starting point S s of the curve are L A and L B , respectively. If L A < L B , point A is said to be in front of point B at L B -L A and point B is behind point A at L B -L A . So, point A is the anterior and point B is the posterior.

Representation of a Given Point on a SPQUCBSC
There are two methods to locate a given point on a SPQUCBSC.
(1) Index Number of the Curve Segment + Parameter t According to definition (1) or (2) of a B-spline curve, the XYZ coordinates of any given point on the curve are accurately determined through four control points and parameter value t. Once four control points are known, the index number of the curve segment defined by them is determined. This representation is equivalent to the form of "the index number of the nearest shape-preserving anterior control point A + the distance behind point A along curve". The method is mathematically easy to understand, but not intuitive in locating an arbitrary point on the curve.

(2) Index Number of the Anterior Key Point A + Distance to Point A along the Curve
The second way to define a given point on a SPQUCBSC is to use the mode of "index number of the anterior key point A + distance behind point A along the curve", which is intuitive for the user to understand, but difficult to map. Therefore, it must be converted into the mode of "the index number of the nearest shape-preserving anterior control point B + the distance behind point B along curve", and then converted into the mode of "the index number of the curve segment + parameter t".
Based on the way of locating a given point, the point A shown in Figure 11 on curve L 6 can be defined or located in either of the following ways: 1 at the distance of L after key point P 1 , requiring L 2 + L 3 + L 4 + L 5 < L < L 2 + L 3 + L 4 + L 5 + L 6 ; 2 at the distance of L A after key point P 2 , demanding 0 < L A < L 6 ; 3 on the curve segment indexed No 6 (or curve L 6 ) defined by control points S 6 (P 2 ), S 7 , S 8 and S 9 , at parameter t = t A , where t A is to be calculated later.

Locating of the Corresponding Point on the Given SPQUCBSC
The key to this algorithm is to find the XYZ coordinates of a given point on a curve according to the index number of the anterior key point and the distance after the key point. It is actually to calculate the index number of the curve segment and parameter t of the point on SPQUCBSC. This algorithm can not only locate the starting point of the mapping, but also search the mapped point (corresponding point) on curve D from any given point on curve P.
The following description takes the searching of a given point on central curve P of the source yarn as an example to describe the steps of the algorithm.
(1) Calculation of the Repeat Unit Length of the Curve The repeat unit length of the curve is the length of the curve that passes through all the key points, and is the sum of the lengths of the curve segments defined by the sequence of shape-preserving control points. The repeat unit length R s of curve S is calculated by Equation (11), respectively. Supposing the number of the key points to interpolate SPQUCBSC S is n + 1, and then the number of the curve segments is 3n − 2 (or h = 3n − 3).
(2) Calculation of the Number of Repeats N s When the mapping length behind a given starting point is greater than the repeat unit length of a curve, the number of repeats (N s ) of mapping should be calculated. The calculation method is equal to the quotient of the sum of the distance D s of the point from mapping starting point and the mapping length L divided by the repeat unit length R s of the curve, and the integer part of the quotient is set as N s . The formula is shown in Equation (12). Be noted that it's not rounded up or rounded down.
Therefore, to the point far away from the mapping start, the coordinate differences resulting from the repeats (N s ) should be added, which will be explained in step (5).

(3) Calculation of the Index Number of the Curve Segment of SPQUCBSC
According to the accumulated value of the length L i of each curve section, the index number (N x ) of the shape-preserving curve section where the point is located is determined, which is actually the index number of the nearest anterior key point in front of the point to search. According to Equation (13), the residue mapping length L r that exceeds a number of complete repeats is calculated.
Then, solve the inequality A series of i values that satisfy the condition are obtained. Among them, the maximum value of i is selected as the index number N x of the curve segment, or, N x = Max{i}.

(4) Calculation of Parameter t
Composite Simpson's Rule dictates that when calculating curve segments, each curve segment is divided into w (an even integer number) subintervals. According to the method similar to calculating the index number of the curve segment, the index number T (T = 0, 1, . . . , w/2) of the subinterval of the curve segment containing the corresponding point is obtained. Thus, parameter t is determined.
Again, solve the inequality A series of i values that satisfy the condition are obtained and T is the maximum value of i, or T = Max{i}. Finally, parameter t is calculated by Equation (17).
Since w is set as 20 in this paper, t is thereby one of the 11 values from 0, 0.1, 0.2, 0.3, . . . , 1.0.

(5) Calculation of the XYZ Coordinates of the Mapped Point
After N s (number of repeat units), N x (index of the curve segment) and t are all calculated, the coordinates of the mapped point (X 1 , Y 1 , Z 1 ) can be calculated according to Equation (2). Then, the final coordinates (X t , Y t , Z t ) of the mapped point at parameter t are calculated by Equation (18): Here, N st means the number of repeats N s at given point of parameter t, N ss is the number of repeats N s at the mapping starting point. X n is the X coordinate of the last point of original curve S while X 0 is the X coordinate of the first point of the original curve S. The rule is also applied to Y n , Y 0 , Z n and Z 0 .
For searching the coordinates of any point on target curve D, the algorithm is exactly the same.

Calculation of the Control Points of the Base Cross-Section Generated Automatically
The base cross-section (C 1 , C a , C M and C B ) as shown in Figure 12 is actually a curve in a 2D plane parallel to plane YOZ plane, and is determined by 18 control points. All the base cross-sections (such as C 1 ) should automatically rotate to the plane that is perpendicular to the central curve of the yarn, i.e., C 2 , to form the final controlling mesh for the uneven 3D yarn.
Since w is set as 20 in this paper, t is thereby one of the 11 values from 0, 0.1, 0.2, 0.3, …, 1.0. After Ns (number of repeat units), Nx (index of the curve segment) and t are all calculated, the coordinates of the mapped point (X 1 , Y 1 , Z 1 ) can be calculated according to Equation (2). Then, the final coordinates (Xt, Yt, Zt) of the mapped point at parameter t are calculated by Equation (18): Here, Nst means the number of repeats Ns at given point of parameter t, Nss is the number of repeats Ns at the mapping starting point. Xn is the X coordinate of the last point of original curve S while X0 is the X coordinate of the first point of the original curve S. The rule is also applied to Yn, Y0, Zn and Z0.
For searching the coordinates of any point on target curve D, the algorithm is exactly the same.

Calculation of the Control Points of the Base Cross-Section Generated Automatically
The base cross-section (C1, Ca, CM and CB) as shown in Figure 12 is actually a curve in a 2D plane parallel to plane YOZ plane, and is determined by 18 control points. All the base cross-sections (such as C1) should automatically rotate to the plane that is perpendicular to the central curve of the yarn, i.e., C2, to form the final controlling mesh for the uneven 3D yarn.
The coordinates of all the 18 control points shown in Figure 2c for a cross-section are set relatively to its center. The newly generated base cross-section corresponding to any point between the two base cross-sections before and after which are at the known spacing is smoothly interpolated according to proportion of length, the method is demonstrated in Figure 12.  The coordinates of all the 18 control points shown in Figure 2c for a cross-section are set relatively to its center. The newly generated base cross-section corresponding to any point between the two base cross-sections before and after which are at the known spacing is smoothly interpolated according to proportion of length, the method is demonstrated in Figure 12.
Assuming that the base cross-sections C a and C b corresponding, respectively, to point S a and S b at the central curve have been calculated, in other words, the coordinates of a pair of the corresponding control points P a and P b on the base cross-section are known, it is necessary to calculate the coordinates of the corresponding control point P m on the cross-section at the S m point on the central curve.
Here, we can re-write the distances between the point pairs, S a − S m , and S m − S b , which are all set along the curve, as L ma and L bm , respectively. P m can be obtained according to the proportional relationship by Equation (19): Similarly, the coordinates of the other 17 control points on the base cross-section C m can be calculated automatically.

Sort and Combine All the Key Points and the Corresponding Base Cross-Sections
After calculating, all the corresponding points of the key points on the source yarn and the key points on target curve D will be combined and ascendingly sorted to form the mapped curve D 1 according to their distances to the mapping starting point D s . Meanwhile, the base cross-sections corresponding to all these key points are also sorted in the same order. Thus, a control mesh of new yarn is formed and the uneven 3D yarn can be drawn by OpenGL.
The sorting process can be solved by the conventional bubbling algorithm, which will not be described here.

Imitation of an Irregular Yarn in Free Space
The following examples show the mapping effect of different mapping length at different starting mapping points with the same source yarn and target curve. The specifications of the source yarn and the target curve to test are listed in Table 1 Table 2 and the final effects are demonstrated in Figure 13. It should be noted that all the key points are indexed from No 0. The two corresponding mapping starting points of the source yarn and the target curve are both set by the mode "index number of the anterior key point A + distance behind point A along the curve". In example No 1, the simplest mapping from origins is used and the resulting effect is shown in Figure 4d. In example No 2, the mapping starting point of the source yarn is not its first key point but its corresponding point is the first key point of the targe curve, and the mapped effect is shown in Figure 13a. In example No 3, the mapping starting point of the source yarn is the first key point but its corresponding point is not the first key point of the targe curve, and the mapped effect is shown in Figure 13b. In these three examples, the mapping length is a full repeat unit of the target curve, thereby a full knitted loop is shown in Figures 4d and 13a,b, respectively, although the three loops looked quite different. In example No 4, there is displacement of mapping starting points from both the origins of the source yarn and the target curve, and the mapping length is more than a repeat unit, so more than one loop repeat is shown in Figure 13c. It is intuitively reliable that the key-point-mapping algorithm works well since the effect spots distribute on the target curve as expected.  Polymers 2022, 14, x FOR PEER REVIEW 16 of 27 unit, so more than one loop repeat is shown in Figure 13c. It is intuitively reliable that the key-point-mapping algorithm works well since the effect spots distribute on the target curve as expected.    Figure 14c shows another three different effects, respectively, by mapping the yarn to target curve in Figure 14a at different mapping starting points. Figure 15a shows the enlarged view of local image of Figure 14c, while Figure 15b shows the corresponding control points for the mapped yarn. Figure 15c shows the magnified mapped yarn if the target curve in Figure 14b is applied, and the control points are shown in Figure 15d. The data of the key points for target curve in Figure 14a and targe curve in Figure 14b are listed in Appendices A.3 and A.4, respectively. From the data, two curves are both 2D curves since all the X coordinates of the key points are constant. So, a real yarn is bent to imitate the target curve to verify the validity of the mapping. In Figure 16, the green dots on the yarn indicate the effect spots of the irregular yarn. Figure 16a shows the red dots on the real yarn are arranged as the XYZ coordinates in the file of Appendix A.2 while Figure  16b shows the source yarn be stretched straight. The smallest scale on graph paper is 0.1. According to scale, the length of the source is 2.7, which is approximate to the curve length calculated by the algorithm based on Composite Simpson's Rule. The mark "×" in Figure  16c indicates the key points of the target curves defined in the Appendix A.3; meanwhile, three effect yarns with different mapping starts are bent and passing through the marks smoothly. Figure 16c demonstrates that the distribution of the green effect spots is quite similar to that in the simulated image of Figure 14c.  Figure 14c shows another three different effects, respectively, by mapping the yarn to target curve in Figure 14a at different mapping starting points. Figure 15a shows the enlarged view of local image of Figure 14c, while Figure 15b shows the corresponding control points for the mapped yarn. Figure 15c shows the magnified mapped yarn if the target curve in Figure 14b is applied, and the control points are shown in Figure 15d. The data of the key points for target curve in Figure 14a and targe curve in Figure 14b are listed in Appendices A.3 and A.4, respectively. From the data, two curves are both 2D curves since all the X coordinates of the key points are constant. So, a real yarn is bent to imitate the target curve to verify the validity of the mapping. In Figure 16, the green dots on the yarn indicate the effect spots of the irregular yarn. Figure 16a shows the red dots on the real yarn are arranged as the XYZ coordinates in the file of Appendix A.2 while Figure 16b shows the source yarn be stretched straight. The smallest scale on graph paper is 0.1. According to scale, the length of the source is 2.7, which is approximate to the curve length calculated by the algorithm based on Composite Simpson's Rule. The mark "×" in Figure 16c indicates the key points of the target curves defined in the Appendix A.3; meanwhile, three effect yarns with different mapping starts are bent and passing through the marks smoothly. Figure 16c demonstrates that the distribution of the green effect spots is quite similar to that in the simulated image of Figure 14c.

Applying Irregular 3D Yarns in Fabric Structures
Once the central curve of an irregular 3D yarn has been freely transformed, it can be applied to various industrial applications, such as electronic blackboard, 3D fabric structure modeling and appearance simulation for woven, knitted and braided fabrics. The source yarn in the Appendix A.1 is used in the following examples again.

Applying Irregular 3D Yarns in Fabric Structures
Once the central curve of an irregular 3D yarn has been freely transformed, it can be applied to various industrial applications, such as electronic blackboard, 3D fabric structure modeling and appearance simulation for woven, knitted and braided fabrics. The source yarn in the Appendix A.1 is used in the following examples again.

Electronic Blackboard
In simulating the electronic blackboard of uneven 3D yarn as shown in Figure 17, all the target curves are actually a series of parallel straight lines, and each line can be designed by only four key points. In mapping, the target curves (actually, straight lines) are processed from their first key points. However, the invisible yarn segments on the back of the blackboard should be considered, which can be achieved by setting different cumulative mapping lengths for each mapping. In simulating the electronic blackboard of uneven 3D yarn as shown in Figure 17, all the target curves are actually a series of parallel straight lines, and each line can be designed by only four key points. In mapping, the target curves (actually, straight lines) are processed from their first key points. However, the invisible yarn segments on the back of the blackboard should be considered, which can be achieved by setting different cumulative mapping lengths for each mapping.

Imitation of Woven Geometric Structures
In order to simulate the geometric structure of woven fabrics, it is necessary to randomly distribute the mapping start of the central curve of the warp yarn in order to avoid Moire effects in large area. The mapping of weft yarns is similar to that of electronic blackboards in setting the accumulative mapped length, but different weft yarn has a different mapping setting depending on the direction of picking. If it is applied for a shuttleless loom, the weft yarn is picked from the same side. The mapping starting points of all weft yarns are set the same, and the cumulative length of each yarn should be increased by one fabric width based on the previous weft mapping. For a shuttle loom, if the weft yarn is picked from both sides, and then it may be necessary to reverse the direction of the key points of the target curve representing the original fabric structure. Figure 18 shows the geometrical structure of plain woven fabric by picking the 3D effect yarn from same side of the loom. In this example, the XYZ coordinates of each interlacing point are roughly calculated. Supposing it is a balanced plain structure, all the interlacing points are considered to be evenly distributed, and the distance between the warp thread and the weft thread is set as one diameter of yarn. The sequence of the interlacing points forms the target curve. In order to better control the path of the yarns in structure, a middle point is inserted between two neighboring interlacing points. The data file of woven structure or the central curves of all the yarns for Figure 18 is shown in the Appendix A.5. In each target curve repeat unit, there are nine key points for four interlacing points. In the file, the second data '12' of the line 2 means that there are 12 target curves in the structure. According to the coordinates of the center of each cross-section, six ends and six picks in the geometric structure of a woven fabric are set in the file. Actually, one and half repeat of the target curve is mapped in the example as shown in Figure 18.

Imitation of Woven Geometric Structures
In order to simulate the geometric structure of woven fabrics, it is necessary to randomly distribute the mapping start of the central curve of the warp yarn in order to avoid Moire effects in large area. The mapping of weft yarns is similar to that of electronic blackboards in setting the accumulative mapped length, but different weft yarn has a different mapping setting depending on the direction of picking. If it is applied for a shuttleless loom, the weft yarn is picked from the same side. The mapping starting points of all weft yarns are set the same, and the cumulative length of each yarn should be increased by one fabric width based on the previous weft mapping. For a shuttle loom, if the weft yarn is picked from both sides, and then it may be necessary to reverse the direction of the key points of the target curve representing the original fabric structure. Figure 18 shows the geometrical structure of plain woven fabric by picking the 3D effect yarn from same side of the loom. In this example, the XYZ coordinates of each interlacing point are roughly calculated. Supposing it is a balanced plain structure, all the interlacing points are considered to be evenly distributed, and the distance between the warp thread and the weft thread is set as one diameter of yarn. The sequence of the interlacing points forms the target curve. In order to better control the path of the yarns in structure, a middle point is inserted between two neighboring interlacing points. The data file of woven structure or the central curves of all the yarns for Figure 18 is shown in the Appendix A.5. In each target curve repeat unit, there are nine key points for four interlacing points. In the file, the second data '12' of the line 2 means that there are 12 target curves in the structure. According to the coordinates of the center of each cross-section, six ends and six picks in the geometric structure of a woven fabric are set in the file. Actually, one and half repeat of the target curve is mapped in the example as shown in Figure 18

Imitation of Weft-Knitted Geometric Structure
The geometric structure of the fabric is changed as shown in the Appendix A.6, which is roughly obtained for a plain knitted stitch. According to the data, there are 4 yarns in the knitted structure, each loop unit is controlled by 10 key points. The central curve of the yarn at the 1st wale is just the same as the target curve in the Appendix A.2, and the key points controlling the remaining three yarn in the next three wales are just obtained by translating the previous yarn upward for a fixed distance, respectively. More than one repeat of the target curve is mapped in the example, which means a large area of the fabric can be imitated. The mapping starting point on the target curve of the weft-knitted fabrics is similar to mapping the weft yarns in a shuttleless-woven fabric. Figure 19 shows an imitated geometrical structure of the weft knitted fabric with the 3D uneven yarns. From the imitated image, the distribution of each effect spots is clearly demonstrated.
From the above examples, it can be seen that the effect knots in 3D slub yarns are distributed as expected at the reasonable positions of different fabric structures by using the key-point-mapping technique. Figure 19. Weft-knitted structure with 3D slub yarns.

Imitation of Weft-Knitted Geometric Structure
The geometric structure of the fabric is changed as shown in the Appendix A.6, which is roughly obtained for a plain knitted stitch. According to the data, there are 4 yarns in the knitted structure, each loop unit is controlled by 10 key points. The central curve of the yarn at the 1st wale is just the same as the target curve in the Appendix A.2, and the key points controlling the remaining three yarn in the next three wales are just obtained by translating the previous yarn upward for a fixed distance, respectively. More than one repeat of the target curve is mapped in the example, which means a large area of the fabric can be imitated. The mapping starting point on the target curve of the weft-knitted fabrics is similar to mapping the weft yarns in a shuttleless-woven fabric. Figure 19 shows an imitated geometrical structure of the weft knitted fabric with the 3D uneven yarns. From the imitated image, the distribution of each effect spots is clearly demonstrated.

Imitation of Weft-Knitted Geometric Structure
The geometric structure of the fabric is changed as shown in the Appendix A.6, which is roughly obtained for a plain knitted stitch. According to the data, there are 4 yarns in the knitted structure, each loop unit is controlled by 10 key points. The central curve of the yarn at the 1st wale is just the same as the target curve in the Appendix A.2, and the key points controlling the remaining three yarn in the next three wales are just obtained by translating the previous yarn upward for a fixed distance, respectively. More than one repeat of the target curve is mapped in the example, which means a large area of the fabric can be imitated. The mapping starting point on the target curve of the weft-knitted fabrics is similar to mapping the weft yarns in a shuttleless-woven fabric. Figure 19 shows an imitated geometrical structure of the weft knitted fabric with the 3D uneven yarns. From the imitated image, the distribution of each effect spots is clearly demonstrated.
From the above examples, it can be seen that the effect knots in 3D slub yarns are distributed as expected at the reasonable positions of different fabric structures by using the key-point-mapping technique. Figure 19. Weft-knitted structure with 3D slub yarns. Figure 19. Weft-knitted structure with 3D slub yarns.
From the above examples, it can be seen that the effect knots in 3D slub yarns are distributed as expected at the reasonable positions of different fabric structures by using the key-point-mapping technique.

Discussion
When the shape of the target curve and the final mapped curve are carefully observed, some slight differences in shape will be noticed although curve D and curve D 1 are very similar. In the following part, rationalization to such phenomena will be addressed.

Source of Error
The sources of difference are originated from three parts: (1) According to the principle of mapping, the number of key points of target curve D is different from that of the final merged curve D 1 . As the key points of the source yarn are inserted, the number of control points on the central curve of the final yarn changes, and so does the expression of each curve segment. Therefore, the two curves are definitely different, and the error occurs.
(2) When calculating the coordinates of a given point on SPQUCBSC, the length of each curve segment needs to be calculated accurately. However, the length is calculated approximately by summation, which is not a deterministic value, and its accuracy depends on the number of the intervals w of each curve segment. The larger w is, the higher the accuracy and the smaller the error.
(3) When calculating the final spatial coordinates of points on the curve, parameter t needs to be determined. However, the value of t is a lookup, there is not a continuous change but a jump when t changes. The jump value is determined by the number of intervals w and skips by at least 2/w each time, resulting in deviation in the calculation of the coordinates of the given point. Obviously, the larger w is, the smaller the error.

Margin of Error
To improve the calculating speed on curve length and save memory, the interval number w should remain within a certain range. In the examples in this paper, w = 20. Taking the source yarn in Figure 4a as an example (same position of all the key points except that two knots of the same thickness), three different target curves are mapped with four different lengths, respectively. Table 3 shows the accumulative length calculation error values under 12 different mapping conditions. Due to the huge amount of the data, the lengths between each effect spot have not been listed. It can be seen from Table 3 that only one of the curve length errors is 1.7%, while the others are less than 1%. This amount of difference in curve length is negligible in human vision. It means that the effect spots of the irregular 3D yarn can be placed at the proper position of the 3D yarn and the key-point-mapping algorithm can be used to imitate a pre-designed irregular 3D yarns in any given geometric structure of fabric.

Application Prospect and Future Research
Theoretically, the mapping technique can also be extended to braided fabric as long as the structure is given. It can also be predicted that this mapping technique can be extended to the application of other fancy yarns such as flake yarn. For the folded fancy yarn, the central curve of the constitute single yarns are different from the central curve of the folded yarn, the mapping process will be more complex and requires further study. For uneven fancy yarns such as snarl yarn or loop yarn, the effect spots are not just the slub effect, new way of modelling effected 3D yarn is needed as well.
Another problem may be encountered when the key-point-mapping technique is applied. Due to the irregular cross-sections along the yarn central curve, two different yarns may collide at the thicker spots, which leads to an unreasonable 3D model of the geometric structure. The collision of the yarns should be detected and rectified in the future research.