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

**Tianyong Zheng \* , Wenli Yue and Xiaojiao Wang**

School of Textile Science and Engineering, Tiangong University, Tianjin 300387, China

**\*** Correspondence: zty\_zzti@126.com or zty\_tjpu@tiangong.edu.cn

**Abstract:** 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.

**Keywords:** fabric CAD; irregular 3D yarn; B-spline curve; fabric structure; key point mapping

Imitation of a Pre-Designed Irregular 3D Yarn in Given Fabric Structures. *Polymers* **2022**, *14*, 3992. https:// doi.org/10.3390/polym14193992

**Citation:** Zheng, T.; Yue, W.; Wang, X.

Academic Editors: Yang Zhou and Zhaoling Li

Received: 29 August 2022 Accepted: 18 September 2022 Published: 23 September 2022

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

**Copyright:** © 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

### **1. 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

of the CAD system of 2D technology because the geometry of the fabric is necessary to predict its physical properties with the help of various finite software.

Therefore, 3D technology for modeling uniform yarns were developed to better construct the geometrical structure of fabrics in Liao [1], Lin [2], Lomov [3] and Sherburn [4]. The uniform 3D yarns are modeled either by facets, a Bezier surface or a B-spline surface, which are all determined by a control grid. However, a uniform/even yarn is only an ideal state, and most of the yarns are uneven in production and some yarns are purposely designed irregularly to form special effects on the fabric. For example, most fancy yarns designed irregularly.

To model irregular/uneven yarns, Jiang [5] and Gong [6] modeled the 3D yarn by setting the cross-section of the yarn as various super ellipses and ellipses, respectively. Software such as TexGen provide ways for modeling 3D yarn of various fixed cross-sections in the fabric structure, but fail to report the shapes of arbitrary cross-sections in a given fabric structure.

In Zheng [7], irregular 3D yarns are modeled by NURBS (Non-Uniform Rational B-Spline Curve). The shape-preserving quasi-uniform cubic B-spline curve is applied to fit the contour of the yarn path accurately, smoothly and stably. Two more adjacent points are inserted before and after an interpolating point, respectively, according to the direction of the all interpolating points, which ensures that the curve goes through all the interpolating points. Meanwhile, the quasi-uniform quadratic B-spline curve is applied to approximately to design the cross-section of a single yarn in the shape of the circle, ellipse, racetrack, lens, bowl, or round rectangle along the yarn path simultaneously. The shape of the cross-section is controlled by a 16-polygon formed by 18 control points. By manually assigning the specified base cross-sections at given positions, irregular 3D yarn effects appear in the structure of the woven fabric.

Actually, it is unreasonable to manually assign the contours of the cross-sections at given positions in a geometrical structure. If the contour of the pre-designed irregular yarn or the geometry of the fabric change, irregular 3D yarns bend in different forms and the positions of the effect spots change accordingly. The change in the distribution of the effect spots on the fabric surface has not been investigated. Indeed, such technological incompetence limits further in-depth application of the yarns, e.g., improved pattern design on apparels by Xue [8], where he developed a colored fancy yarn spun by three-channel digital ring spinning recently. The colored folded yarn comprises three irregular color yarn, which definitely enhances the esthetic effects of the apparels. Even in the CAD of 2D technology, where the effect spots can be viewed in the imitated image, the issue of the distribution of effect spots in the fabric structure is neglected or concealed by copying the part of the effected spots in the yarn image to the imitated fabric image directly.

The objective of this paper is to suggest/analyze a possible way of simulating the effect spot position distribution on irregular 3D yarn in any fabric structure. In other words, when the central curve of an uneven 3D yarn changes or the yarn itself moves arbitrarily, how will the effect spots in the pre-designed yarn change their positions accordingly given that no elongation and flatness occur?

### **2. Methodology**

### *2.1. Choosing the Irregular Yarn*

Due to the anisotropy of the irregular yarn, precise methods corresponding to different fancy yarn types are required. Slub yarn is the simplest type of irregular fancy yarn, in which slub knots are deliberately created to produce the desired effect. Therefore, an irregular yarn with a slub effect is a proper way to demonstrate how the effect spots distribute with the change in the fabric structure.

In most CAD systems for designing slub yarns, three parameters, namely, slub length, slub thickness and slub pitch, are used to control the contour of slub knots along the yarn (Figure 1); therefore, images of complicated slub yarns can be generated and put into a 2D

*Polymers* **2022**, *14*, x FOR PEER REVIEW 3 of 27

fabric pattern. In order to avoid Moire effects, as a rule, slub yarns have a non-constant slub pitch between the slub spots. into a 2D fabric pattern. In order to avoid Moire effects, as a rule, slub yarns have a nonconstant slub pitch between the slub spots.

In most CAD systems for designing slub yarns, three parameters, namely, slub length, slub thickness and slub pitch, are used to control the contour of slub knots along the yarn (Figure 1); therefore, images of complicated slub yarns can be generated and put

**Figure 1.** Three parameters to control the contour of slub knots. **Figure 1.** Three parameters to control the contour of slub knots.

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. 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.

### *2.2. Representation of 3D Irregular Yarns*

*2.2. Representation of 3D Irregular Yarns*  In this paper, 3D slub yarns are modeled by a shape-preserving quasi-uniform Bspline 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 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 *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-sec-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*<sup>1</sup> 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.

tions 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

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. *Polymers* **2022**, *14*, x FOR PEER REVIEW 4 of 27

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 **Figure 3.** Design process of a 3D irregular yarn. (**a**) A solid 3D irregular yarn. (**b**) The control points of the cubic quasi-uniform B spline curve (red points: key points and control points, blue points: control points). (**c**) Cross-sections of the yarn. (**d**) Control grid of the B-spline surface for the 3D yarn. **Figure 3.** Design process of a 3D irregular yarn. (**a**) A solid 3D irregular yarn. (**b**) The control points of the cubic quasi-uniform B spline curve (red points: key points and control points, blue points: control points). (**c**) Cross-sections of the yarn. (**d**) Control grid of the B-spline surface for the 3D yarn.

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 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

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 follow-

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

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

yarns in fabric so that the effect spots of the source yarn will be kept.

examples although its relative position is fixed.

*2.4. Mathematical Expression of the Problem* 

*2.3. Description of the Geometrical Structure of Fabric* 

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.

### *2.3. 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.

### *2.4. 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. *Polymers* **2022**, *14*, x FOR PEER REVIEW 6 of 27 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.

**Figure 4.** The procedure of changing the central line of a 3D slub yarn. **Figure 4.** The procedure of changing the central line of a 3D slub 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 meas-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.

uring the fabric structure. To model a 3D yarn based on target curve *D* with OpenGL, the cross-sections should 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

corresponding cross-sections on surface *F* according to surface *Y* of the source yarn.

corresponding mapping starting points *Ps* on curve *P* and *Ds* on curve *D* are set.

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. There-

Generally, an arbitrary point *Ds* on the central curve *D* of surface *F* is set as the mapping start, and its counterpart point *Ps* is also set arbitrarily on central curve *P* of surface *Y*. It is necessary to find the spatial coordinates of a random point *Dk* (to be located) with a given distance of *L* behind the point *Ds* along curve *D* and the spatial coordinates of the

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

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,

control points of the corresponding cross-sections on curve *D*.

*2.5. Principle and Steps of Mapping* 

2.5.1. Principle of Mapping

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<sup>s</sup>* on the central curve *D* of surface *F* is set as the mapping start, and its counterpart point *P<sup>s</sup>* is also set arbitrarily on central curve *P* of surface *Y*. It is necessary to find the spatial coordinates of a random point *D<sup>k</sup>* (to be located) with a given distance of *L* behind the point *D<sup>s</sup>* 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<sup>s</sup>* on curve *P* and *D<sup>s</sup>* on curve *D* are set.

### *2.5. Principle and Steps of Mapping*

### 2.5.1. Principle of Mapping

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*<sup>1</sup> , which has the same shape of the original target curve, *D*. In practice, curve *D*<sup>1</sup> 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*<sup>1</sup> , 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*<sup>1</sup> . 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.

### 2.5.2. 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*<sup>1</sup> as the central path of the new yarn. The simplest mapping method is that *P*<sup>0</sup> on the point curve *P* corresponds to point *D*<sup>0</sup> on curve *D*. The key mapping steps are described as follows:

**Figure 5.** (**a**) Key points on the central curve *P* of source yarn. (**b**). Key points on the target curve **Figure 5.** (**a**) Key points on the central curve *P* of source yarn. (**b**). Key points on the target curve *D*.

*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

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

proportion will change and the contour of the new yarn will also change.

2.5.2. Mapping Steps

are described as follows:

*D.*

(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 (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.

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 coordi-(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.

nate 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 correspond-(3) According to the curve length between 2 adjacent key points along the source yarn *P*, the key point of the source yarn *P<sup>i</sup>* (*i* = 0, 1, . . . , 5, and *i* is an integer number in this paper) corresponds to point *P<sup>i</sup> <sup>1</sup>* on the new curve *D*<sup>1</sup> . Meanwhile, the contour of the corresponding base cross-section at *P<sup>i</sup>* on curve *D* is obtained and assigned to the base cross-section at *P<sup>i</sup>* <sup>1</sup> on curve *D*<sup>1</sup> .

ing 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 (4) Calculate the distance *L<sup>m</sup>* and *L<sup>n</sup>* between the key point *D<sup>e</sup>* (*e* can be any integer less than the number of the key points, 0 < *e* < 4 for this example) on curve *D*<sup>1</sup> and the newly inserted nearest key points *P<sup>M</sup>* <sup>1</sup> and *PM*+1 <sup>1</sup> on each side. Calculate all control points of the base cross-section corresponding to *D<sup>e</sup>* according to the distance proportion.

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*+11 on each side. Calculate all control points of the base cross-section corresponding to *De* according to the distance proportion. (5) According to *X* coordinates by straightening the curve (distance *L<sup>i</sup>* from the key point to the starting point on the source yarn *P*, or *K<sup>i</sup>* 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*<sup>1</sup> . 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<sup>i</sup>* after an arbitrary key point *D<sup>k</sup>* , the order of sections of SPQUCBSC and parameter *t* are obtained for *P<sup>i</sup>* 2 , which is the corresponding point on curve *D* to key point *Pi* 1 . Then, the *XYZ* coordinates of key point *P<sup>i</sup>* <sup>2</sup> 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*<sup>1</sup> 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.

6c.

6c.

*Pi*

*Pi*

erated curve.

erated curve.

parameter *t* are obtained for *Pi*

parameter *t* are obtained for *Pi*

1. Then, the *XYZ* coordinates of key point *Pi*

1. Then, the *XYZ* coordinates of key point *Pi*

*Polymers* **2022**, *14*, x FOR PEER REVIEW 8 of 27

(5) According to *X* coordinates by straightening the curve (distance *Li* from the key point to the starting point on the source yarn *P*, or *Ki* 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 crosssections are also arranged according to the order of these key points as shown in Figure

(5) According to *X* coordinates by straightening the curve (distance *Li* from the key point to the starting point on the source yarn *P*, or *Ki* 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 crosssections are also arranged according to the order of these key points as shown in Figure

(6) Rearrange the sequence of key points similar to curve *D*. According to the distance of key point *Pi* after an arbitrary key point *Dk*, the order of sections of SPQUCBSC and

(6) Rearrange the sequence of key points similar to curve *D*. According to the distance of key point *Pi* after an arbitrary key point *Dk*, the order of sections of SPQUCBSC and

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*<sup>1</sup> 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 gen-

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*<sup>1</sup> 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 gen-

2, which is the corresponding point on curve *D* to key point

2, which is the corresponding point on curve *D* to key point

2 are calculated, and the *XYZ* coordinates of

2 are calculated, and the *XYZ* coordinates of

**Figure 6.** The calculation of key point spacing along the central curve and the combination of the sorting of key points. (**a**) Calculate the distance to the mapping start P0 for each key control point on the source yarn. (**b**) Calculate the distance to the mapping start D0 for each key point on the target curve. (**c**) Combine and rearrange all the key points of both source yarn and target curve in order on the new central curve according to the distances to the random mapping start *P*0 or *D*0. **Figure 6.** The calculation of key point spacing along the central curve and the combination of the sorting of key points. (**a**) Calculate the distance to the mapping start P<sup>0</sup> for each key control point on the source yarn. (**b**) Calculate the distance to the mapping start D<sup>0</sup> for each key point on the target curve. (**c**) Combine and rearrange all the key points of both source yarn and target curve in order on the new central curve according to the distances to the random mapping start *P*<sup>0</sup> or *D*<sup>0</sup> . **Figure 6.** The calculation of key point spacing along the central curve and the combination of the sorting of key points. (**a**) Calculate the distance to the mapping start P0 for each key control point on the source yarn. (**b**) Calculate the distance to the mapping start D0 for each key point on the target curve. (**c**) Combine and rearrange all the key points of both source yarn and target curve in order on the new central curve according to the distances to the random mapping start *P*0 or *D*0.

**Figure 7.** Arrangement of all key points in curve *D*1 according to distance. **Figure 7.** Arrangement of all key points in curve *D*1 according to distance. **Figure 7.** Arrangement of all key points in curve *D*<sup>1</sup> according to distance.

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 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.

### 2.5.3. 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<sup>s</sup>* , 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<sup>s</sup>* , the starting point corresponding to *P<sup>s</sup>* , is also the first key point, *D*0, 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, *P<sup>s</sup>* , is generally not the first key point of the source yarn, or *P*0; and the starting point of the target mapping curve, *D<sup>s</sup>* , is not its first key point, *D*0, either, as shown in Figure 8a,b, respectively. Let us suppose that the distance from *P<sup>s</sup>* to *P*<sup>0</sup> is *L<sup>s</sup>* , and the distance from *D<sup>s</sup>* to *D*<sup>0</sup> is *K<sup>s</sup>* . In Figure 8c, although *L<sup>s</sup>* < *L*<sup>0</sup> and *K<sup>s</sup>* < *K*0, actually *L<sup>s</sup>* and *K<sup>s</sup>* are arbitrary values without any restriction. In calculating *P<sup>i</sup>* 2 , the key point on the mapped curve, the pair of the starting point *P<sup>s</sup>* and *D<sup>s</sup>* are both located at the distance *Ls*–*K<sup>s</sup>* from *D*<sup>0</sup> on the mapped curve, as shown in Figures 8c and 9, respectively. 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 *P*0; and the starting point of the target mapping curve, *Ds*, is not its first key point, *D*0, either, as shown in Figure 8a,b, respectively. Let us suppose that the distance from *Ps* to *P*0 is *Ls*, and the distance from *Ds* to *D*0 is *Ks*. In Figure 8c, although *Ls* < *L*0 and *Ks* < *K*0, 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 *D*0 on the mapped curve, as shown in Figures 8c and 9, respectively.

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

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 *P*0, the first key point of curve *P*, while *Ds*, the starting point corresponding

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

spatial state of the uneven yarn in the order of the distance to the mapping start.

*Polymers* **2022**, *14*, x FOR PEER REVIEW 9 of 27

to *Ps*, is also the first key point, *D*0, of target curve *D*.

2.5.3. Mode of Mapping (1) Mapping from Origins

(2) Mapping from Random Points

**Figure 8.** The mapping procedure for the different starting points. (**a**) Calculate the distance to the random mapping start *Ps* for each key control point on the source yarn. (**b**) Calculate the distance to the random mapping start *Ds* for each key point on the target curve. (**c**) Combine and rearrange all the key points of both source yarn and target curve in order on the new central curve according to the distances to the random mapping start *Ps* or *Ds*. **Figure 8.** The mapping procedure for the different starting points. (**a**) Calculate the distance to the random mapping start *Ps* for each key control point on the source yarn. (**b**) Calculate the distance to the random mapping start *D<sup>s</sup>* for each key point on the target curve. (**c**) Combine and rearrange all the key points of both source yarn and target curve in order on the new central curve according to the distances to the random mapping start *Ps* or *Ds*. *Polymers* **2022**, *14*, x FOR PEER REVIEW 10 of 27

**Figure 9.** The mapping result for the different starting points. **Figure 9.** The mapping result for the different starting points.

(3) Mapping over an Arbitrary Length (3) Mapping over an Arbitrary Length

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. 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 *D*<sup>0</sup> 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

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 *P*0, *P*1, ..., *Pn*, 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 *Pi* is coincidental with point *Si*×3 (0 ≤ *i ≤ n*, and *i* is an integer

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 *Li* (*i =* 0, 1, 2, …, 9) is a cubic polynomial with different

**Figure 10.** The mapping result for the multiple repeats of the curve.

curve.

**3. Algorithm** 

number)*.*

*3.1. Sections of SPQUCBSC* 

10, where the curve length of the mapping is more than one cycle.

**Figure 9.** The mapping result for the different starting points.

(3) Mapping over an Arbitrary Length

**Figure 10.** The mapping result for the multiple repeats of the curve. **Figure 10.** The mapping result for the multiple repeats of the curve.

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 *D*<sup>0</sup> 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. 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 *D<sup>s</sup>* to *D*<sup>0</sup> of the target curve is very large, there must be an appropriate way to locate *D<sup>s</sup>* . Therefore, it is necessary to find a way to represent the position of any point on the curve.

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

### **3. Algorithm**

[12]:

() = ଵ

<sup>ଶ</sup> + ଶ

<sup>ଶ</sup> + ଷ

<sup>ଶ</sup> + 4ଵ

ଶଶ + 4ଶ

#### **3. Algorithm**  *3.1. Sections of SPQUCBSC*

*3.1. 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 *P*0, *P*1, ..., *Pn*, 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 *Pi* is coincidental with point *Si*×3 (0 ≤ *i ≤ n*, and *i* is an integer 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, . . . , *Pn*, 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<sup>i</sup>* is coincidental with point *Si*×<sup>3</sup> (0 ≤ *i* ≤ *n*, and *i* is an integer number).

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 *Li* (*i =* 0, 1, 2, …, 9) is a cubic polynomial with different 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<sup>i</sup>* (*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. *Polymers* **2022**, *14*, x FOR PEER REVIEW 11 of 27 multinomial coefficients. These 10 curve segments form a complete quasi-uniform cubic B-spline curve.

**Figure 11.** Key points, control points and curve segments of a shape-preserving quasi-uniform Bspline curve. **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 *Pi* is the starting point of the curve segment indexed as *L*3\**i*−1 (0 *< i < n*). In the 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<sup>i</sup>* is the starting point of the curve segment indexed as *L*3\**i*−<sup>1</sup> (0 *< i < n*). In the

example shown in Figure 11, *P*1 is the starting point of the curve segment indexed as *L*<sup>2</sup> (2 = 3 × 1 − 1). *P*2 is the starting point of the curve segment indexed as *L*<sup>5</sup> (5 = 3 × 2 − 1), while

Defined by a series of control points {*S*0, *S*1, *S*2, *…*, *Sn*}, the point *Si*(*t*) on the *i*th curve section of the B-spline curve defined by {*Si*, *Si*+1, *Si*+2, *Si*+3} is given by Formula (1) in Pigel

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

=() = ଶ + ଶ+ଶ<sup>ଶ</sup> + ଶଷ (0≤≤1)

Here, *x*, *y* and *z* are the coordinates of the point on the curve at *t*. *ai*, *bi*, *ci* and *di* (*I* = 1,

In order to calculate the length of this curve segment *Li*, the arc differentiate length

൪ 0≤≤1 = 0,1, … , − 3 (1)

ଵ()

ଶସ + 4ଵଵ + 4ଶଶ + 4ଷଷ + 6ଵଵ<sup>ଶ</sup>

(4)

(2)

() = ሾ1ଶ ଷሿଷ ൦

written as the following parametric Equation (2).

ቐ

2, 3) are determined by matrix *M*3.

Let function () = ඥ()

ଶଶ + 9ଵ

*ds* is given by Equation (3):

ଶଶ + 4ଷ

*3.2. Calculating the Distance between the Neighbouring Key Points* 

 ାଵ ାଶ ାଷ

= () = ଵ + ଵ+ଵ<sup>ଶ</sup> + ଵଷ

=ℎ() = ଷ + ଷ+ଷ<sup>ଶ</sup> + ଷଷ

= ඥ()ଶ + ()ଶ + ()ଶ = ඥᇱଶ()()ଶ + ᇱଶ()()ଶ + ℎᇱଶ()()ଶ = ඥᇱଶ() + ᇱଶ() + ℎᇱଶ() (3)

ଶସ + 9ଷ

ଶସ + 9ଶ

Then, the length of the curve segment *s* is calculated by Equation (4):

+ 6ଶଶ<sup>ଶ</sup> + 6ଷଷ<sup>ଶ</sup> + 12ଵଵ<sup>ଷ</sup> + 12ଶଶ<sup>ଷ</sup> + 12ଷଷ<sup>ଷ</sup> (5)

= ඥᇱଶ() + ᇱଶ() + ℎᇱଶ() = <sup>ଵ</sup>

example shown in Figure 11, *P*<sup>1</sup> is the starting point of the curve segment indexed as *L*<sup>2</sup> (2 = 3 × 1 − 1). *P*<sup>2</sup> is the starting point of the curve segment indexed as *L*<sup>5</sup> (5 = 3 × 2 − 1), while *P*<sup>3</sup> is the starting point of the curve segment indexed as *L*<sup>8</sup> (8 = 3 × 3 − 1).

### *3.2. Calculating the Distance between the Neighbouring Key Points*

Defined by a series of control points {*S*0, *S*1, *S*2, . . . , *Sn*}, the point *S<sup>i</sup>* (*t*) on the *i*th curve section of the B-spline curve defined by {*S<sup>i</sup>* , *Si*+1, *Si*+2, *Si*+3} is given by Formula (1) in Pigel [12]:

$$S\_{\bar{i}}(t) = \begin{bmatrix} 1 & t & t^2 & t^3 \end{bmatrix} M\_3 \begin{bmatrix} S\_{\bar{i}} \\ S\_{\bar{i}+1} \\ S\_{\bar{i}+2} \\ S\_{\bar{i}+3} \end{bmatrix} \qquad 0 \le t \le 1 \quad \bar{i} = 0, 1, \dots, n-3 \tag{1}$$

The transformation matrix *M*<sup>3</sup> 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).

$$\begin{cases} x = f(t) = a\_1 + b\_1 t + c\_1 t^2 + d\_1 t^3 \\ y = g(t) = a\_2 + b\_2 t + c\_2 t^2 + d\_2 t^3 \\ z = h(t) = a\_3 + b\_3 t + c\_3 t^2 + d\_3 t^3 \end{cases} \quad (0 \le t \le 1) \tag{2}$$

Here, *x*, *y* and *z* are the coordinates of the point on the curve at *t*. *a<sup>i</sup>* , *b<sup>i</sup>* , *c<sup>i</sup>* and *d<sup>i</sup>* (*I* = 1, 2, 3) are determined by matrix *M*3.

In order to calculate the length of this curve segment *L<sup>i</sup>* , the arc differentiate length *ds* is given by Equation (3):

$$ds = \sqrt{(dx)^2 + (dy)^2 + (dz)^2} = \sqrt{f^2(t)(dt)^2 + g^2(t)(dt)^2 + h^2(t)(dt)^2} = \sqrt{f^2(t) + g^2(t) + h r^2(t)}dt\tag{3}$$

Then, the length of the curve segment *s* is calculated by Equation (4):

$$s = \int\_0^1 \sqrt{f^2(t) + g t^2(t) + h t^2(t)} dt = \int\_0^1 u(t) dt\tag{4}$$

Let function *u*(*t*) = p *m*(*t*)

$$\begin{aligned} m(t) &= b\_1^2 + b\_2^2 + b\_3^2 + 4c\_1^2 t^2 + 4c\_2^2 t^2 + 4c\_3^2 t^2 + 9d\_1^2 t^4 + 9d\_2^2 t^4 + 4b\_1 c\_1 t + 4b\_2 c\_2 t + 4b\_3 c\_3 t + 6b\_1 d\_1 t^2 \\ &+ 6b\_2 d\_2 t^2 + 6b\_3 d\_3 t^2 + 12c\_1 d\_1 t^3 + 12c\_2 d\_2 t^3 + 12c\_3 d\_3 t^3 \\ &= b\_1^2 + b\_2^2 + b\_3^2 + (4b\_1 c\_1 + 4b\_2 c\_2 + 4b\_3 c\_3)t + (4c\_1^2 + 4c\_2^2 + 4c\_3^2 + 6b\_1 d\_1 + 6b\_2 d\_2 + 6b\_3 d\_3)t^2 \\ &+ (12c\_1 d\_1 + 12c\_2 d\_2 + 12c\_3 d\_3)t^3 + (9d\_1^2 + 9d\_2^2 + 9d\_3^2)t^4 \end{aligned} \tag{5}$$

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<sup>j</sup>* (*j* = 1, 2, . . . , *w*/2) is calculated as:

$$G\_1 = \frac{1}{3n}(\mu\_0 + 4\mu\_1 + \mu\_2) \tag{6}$$

$$G\_2 = \frac{1}{3n}(\mu\_2 + 4\mu\_3 + \mu\_4) \tag{7}$$

$$G\_{j} = \frac{1}{3n} (u\_{j-2} + 4u\_{j-1} + u\_{j}) \tag{8}$$

$$G\_{\frac{n}{2}} = \frac{1}{3n}(u\_{n-2} + 4u\_{n-1} + u\_n) \tag{9}$$

where *u<sup>i</sup>* (*I* = 0, 1, . . . , *n*) = *u i n* . According to Equations (8) and (9), the length of the curve segment *L<sup>i</sup>* defined by control points *S<sup>i</sup>* , *Si*+1, *Si*+2, and *Si*+3 is approximately calculated as the sum of the sub-segments of the curve as shown in Equation (10).

$$L\_l = \int\_0^1 u(\mathbf{x})d\mathbf{x} \approx \frac{1}{3n} [(u\_0 + u\_n) + 2(u\_2 + u\_4 + \dots + u\_{n+2}) + 4(u\_1 + u\_3 + \dots \dots u\_{n-1})] \tag{10}$$

The larger the even number *w*, the more accurate the calculation.

### *3.3. The Representation of an Arbitrary Point on a SPQUCBSC*

### 3.3.1. 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<sup>s</sup>* of the curve are *L<sup>A</sup>* and *LB*, respectively. If *L<sup>A</sup>* < *LB*, point *A* is said to be in front of point *B* at *LB*–*L<sup>A</sup>* and point *B* is behind point *A* at *LB–LA*. So, point *A* is the anterior and point *B* is the posterior.

### 3.3.2. 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*<sup>6</sup> can be defined or located in either of the following ways: <sup>1</sup> at the distance of *L* after key point *P*1, requiring *L*<sup>2</sup> + *L*<sup>3</sup> + *L*<sup>4</sup> + *L*<sup>5</sup> < *L* < *L*<sup>2</sup> + *L*<sup>3</sup> + *L*<sup>4</sup> + *L*<sup>5</sup> + *L*6; <sup>2</sup> at the distance of *L<sup>A</sup>* after key point *P*2, demanding 0 < *L<sup>A</sup>* < *L*6; <sup>3</sup> on the curve segment indexed No 6 (or curve *L*6) defined by control points *S*6(*P*2), *S*7, *S*<sup>8</sup> and *S*9, at parameter *t* = *tA*, where *t<sup>A</sup>* is to be calculated later.

### *3.4. 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<sup>s</sup>* 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 3*n* − 2 (*or h =* 3*n* − 3).

$$R\_{\mathcal{S}} = \sum\_{i=0}^{h} L\_i \qquad \qquad (h+1 : number \text{ of the curve segments on curve } \mathcal{S}) \tag{11}$$

### (2) Calculation of the Number of Repeats *N<sup>s</sup>*

When the mapping length behind a given starting point is greater than the repeat unit length of a curve, the number of repeats (*Ns*) of mapping should be calculated. The calculation method is equal to the quotient of the sum of the distance *D<sup>s</sup>* of the point from mapping starting point and the mapping length *L* divided by the repeat unit length *R<sup>s</sup>* of the curve, and the integer part of the quotient is set as *N<sup>s</sup> .* The formula is shown in Equation (12). Be noted that it's not rounded up or rounded down.

$$N\_s = \left(integer\right)\frac{D\_s + L}{R\_s} \tag{12}$$

Therefore, to the point far away from the mapping start, the coordinate differences resulting from the repeats (*Ns*) 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<sup>i</sup>* of each curve section, the index number (*Nx*) 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<sup>r</sup>* that exceeds a number of complete repeats is calculated.

$$L\_r = L + Ds - N\_\text{s} \cdot R\_\text{s} \tag{13}$$

Then, solve the inequality

$$\sum\_{i=0}^{h} L\_i < L\_r \tag{14}$$

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<sup>x</sup>* of the curve segment, or, *N<sup>x</sup>* = 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.

$$\text{Let } Q\_r = L\_r - \sum\_{i=0}^{N\_x} L\_i \tag{15}$$

Again, solve the inequality

$$\sum\_{i=0}^{N\_\chi} G\_i < Q\_r \tag{16}$$

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).

$$T = \text{(float)} \, 2 \times T / w \tag{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. tion (2). Then, the final coordinates (*Xt*, *Yt*, *Zt*) of the mapped point at parameter *t* are calculated by Equation (18):

1, …, *w/*2) of the subinterval of the curve segment containing the corresponding point is

Let = − ∑

∑ < ேೣ

value of *i*, or *T* = Max{*i*}. Finally, parameter *t* is calculated by Equation (17).

A series of *i* values that satisfy the condition are obtained and *T* is the maximum

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,

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 Equa-

ேೣ

ୀ (15)

(18)

ୀ (16)

*T =* (*float*) 2 × *T/w* (17)

#### (5) Calculation of the *XYZ* Coordinates of the Mapped Point ቐ ௧ = <sup>ଵ</sup> + (௦௧ − ௦௦) ∙ ( − ) ௧ = <sup>ଵ</sup> + (௦௧ − ௦௦) ∙ ( − )

(5) Calculation of the *XYZ* Coordinates of the Mapped Point

*Polymers* **2022**, *14*, x FOR PEER REVIEW 14 of 27

obtained. Thus, parameter *t* is determined.

Again, solve the inequality

…, 1.0.

the same.

After *N<sup>s</sup>* (number of repeat units), *N<sup>x</sup>* (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<sup>t</sup>* , *Y<sup>t</sup>* , *Zt*) of the mapped point at parameter *t* are calculated by Equation (18): ௧ = <sup>ଵ</sup> + (௦௧ − ௦௦) ∙ ( − ) 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 *X*0 is the *X* coordinate of the first point of the original curve *S*.

$$\begin{cases} \mathbf{X}\_{l} = \mathbf{X}^{1} + (\mathbf{N}\_{\rm{sl}} - \mathbf{N}\_{\rm{ss}}) \cdot (\mathbf{X}\_{\rm{lt}} - \mathbf{X}\_{\rm{0}})\\\mathbf{Y}\_{l} = \mathbf{Y}^{1} + (\mathbf{N}\_{\rm{sl}} - \mathbf{N}\_{\rm{ss}}) \cdot (\mathbf{Y}\_{\rm{lt}} - \mathbf{Y}\_{\rm{0}})\\\mathbf{Z}\_{l} = \mathbf{Z}^{1} + (\mathbf{N}\_{\rm{sl}} - \mathbf{N}\_{\rm{ss}}) \cdot (\mathbf{Z}\_{\rm{0}} - \mathbf{Z}\_{\rm{0}}) \end{cases} \tag{18}$$

Here, *Nst* means the number of repeats *N<sup>s</sup>* at given point of parameter *t*, *Nss* is the number of repeats *N<sup>s</sup>* at the mapping starting point. *X<sup>n</sup>* is the *X* coordinate of the last point of original curve *S* while *X*<sup>0</sup> is the *X* coordinate of the first point of the original curve *S*. The rule is also applied to *Yn*, *Y*0, *Z<sup>n</sup>* and *Z*0. *3.5. Calculation of the Control Points of the Base Cross-Section Generated Automatically*  The base cross-section (*C*1, *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

For searching the coordinates of any point on target curve *D*, the algorithm is exactly the same. 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

#### *3.5. Calculation of the Control Points of the Base Cross-Section Generated Automatically* uneven 3D yarn. The coordinates of all the 18 control points shown in Figure 2c for a cross-section are

The base cross-section (*C*1, *Ca*, *C<sup>M</sup>* 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 *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. 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.

**Figure 12.** The method for generating a base cross-section by two known ones. **Figure 12.** The method for generating a base cross-section by two known ones.

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<sup>a</sup>* and *C<sup>b</sup>* corresponding, respectively, to point *S<sup>a</sup>* and *S<sup>b</sup>* at the central curve have been calculated, in other words, the coordinates of a pair of the corresponding control points *P<sup>a</sup>* and *P<sup>b</sup>* on the base cross-section are known, it is necessary to calculate the coordinates of the corresponding control point *P<sup>m</sup>* on the cross-section at the *S<sup>m</sup>* point on the central curve.

Here, we can re-write the distances between the point pairs, *S<sup>a</sup>* − *Sm*, and *S<sup>m</sup>* − *S<sup>b</sup>* , which are all set along the curve, as *Lma* and *Lbm*, respectively. *P<sup>m</sup>* can be obtained according to the proportional relationship by Equation (19):

$$\frac{P\_m - P\_a}{L\_{ma}} = \frac{P\_b - P\_m}{L\_{bm}}\tag{19}$$

Similarly, the coordinates of the other 17 control points on the base cross-section *C<sup>m</sup>* can be calculated automatically.

### *3.6. 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*<sup>1</sup> according to their distances to the mapping starting point *D<sup>s</sup>* . 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.

### **4. Results**

### *4.1. 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. The length of the curve repeat is calculated by Composite Simpson's Rule according to the data in Appendices A.1 and A.2.

### **Table 1.** Specifications of the source yarn and target curve.


By changing the mapping starting points of the source yarn, target curve and mapping length, four experiments are tested to demonstrate the mapping results. The mapping parameters are shown in 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


**Figure 13.** The mapping effect with different mapping starting points and mapping length. (**a**) Mapping a full unit length of the source yarn at the origin of the target curve. (**b**) Mapping a full unit length from the origin of the source yarn onto the target curve. (**c**) Mapping a random length of a given position of the source yarn onto the target curve at another specified position. **Figure 13.** The mapping effect with different mapping starting points and mapping length. (**a**) Mapping a full unit length of the source yarn at the origin of the target curve. (**b**) Mapping a full unit length from the origin of the source yarn onto the target curve. (**c**) Mapping a random length of a given position of the source yarn onto the target curve at another specified position.

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

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 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.

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 14.** Different target curves and different mapping starts. (**a**) Target curve a. (**b**) Target curve b. (**c**) Mapping effects onto the target curve a from the source yarn at different mapping starts. **Figure 14.** Different target curves and different mapping starts. (**a**) Target curve a. (**b**) Target curve b. (**c**) Mapping effects onto the target curve a from the source yarn at different mapping starts. **Figure 14.** Different target curves and different mapping starts. (**a**) Target curve a. (**b**) Target curve b. (**c**) Mapping effects onto the target curve a from the source yarn at different mapping starts.

**Figure 15.** Enlarged generated central curves after mapping (local image). (**a**) The enlarged mapping effect of Figure 14c. (**b**) The control points of the mapped curve in Figure 15a. (**c**)The enlarged mapping effect onto the targe curve Figure 14b. (**d**) The control points of the mapped curve in Figure 15c. **Figure 15.** Enlarged generated central curves after mapping (local image). (**a**) The enlarged mapping effect of Figure 14c. (**b**) The control points of the mapped curve in Figure 15a. (**c**)The enlarged mapping effect onto the targe curve Figure 14b. (**d**) The control points of the mapped curve in Figure 15c. **Figure 15.** Enlarged generated central curves after mapping (local image). (**a**) The enlarged mapping effect of Figure 14c. (**b**) The control points of the mapped curve in Figure 15a. (**c**) The enlarged mapping effect onto the targe curve Figure 14b. (**d**) The control points of the mapped curve in Figure 15c.

**Figure 16.** Real effect yarn bending diagram as compared with Figure 14c. (**a**) A full repeat unit of the real bent source yarn corresponding to Appendix A.1. (**b**) A full repeat unit of the straightened source yarn. (**c**) The mapping effect of the real yarns corresponding to Figure 14c. **Figure 16.** Real effect yarn bending diagram as compared with Figure 14c. (**a**) A full repeat unit of the real bent source yarn corresponding to Appendix A.1. (**b**) A full repeat unit of the straightened source yarn. (**c**) The mapping effect of the real yarns corresponding to Figure 14c.

#### *4.2. Applying Irregular 3D Yarns in Fabric Structures 4.2. 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. 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.

#### 4.2.1. Electronic Blackboard 4.2.1. 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.

**Figure 17.** The imitated electronic blackboard. **Figure 17.** The imitated electronic blackboard.

#### 4.2.2. Imitation of Woven Geometric Structures 4.2.2. 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 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.

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.

*Polymers* **2022**, *14*, x FOR PEER REVIEW 20 of 27

**Figure 18.** Woven structure with 3D slub yarns. **Figure 18.** Woven structure with 3D slub yarns. 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

4.2.3. Imitation of Weft-Knitted Geometric Structure 4.2.3. Imitation of Weft-Knitted Geometric Structure the knitted structure, each loop unit is controlled by 10 key points. The central curve of

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. 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. 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.

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. 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.

**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.

### **5. 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*<sup>1</sup> are very similar. In the following part, rationalization to such phenomena will be addressed.

### *5.1. Error Analysis*

### 5.1.1. 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*<sup>1</sup> . 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.

### 5.1.2. 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.

**Table 3.** The accumulative length errors at different mapping lengths.


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.

### *5.2. 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.

### **6. Conclusions**

This paper proposed a key-point-mapping algorithm to imitate pre-designed uneven 3D yarns in various geometric structures of fabrics. The premise for such algorithm is that the target curves of all the constituent yarns of the fabric structure are known in advance. The core of the mapping is to keep the curve lengths between the effect spots and the contour of the cross-sections corresponding to the effect spots of irregular/uneven 3D yarns unchanged whatever the central curve of the yarn changes. From the examples in this paper, the effect spots were well kept and reasonably distributed in the woven structure and knitted structure, which indicates that the key-point-mapping technique is reasonable, effective and accurate to apply pre-designed irregular/uneven 3D yarns in any fabric structure. The error analysis proves the conclusions further.

**Author Contributions:** Conceptualization, T.Z.; methodology, T.Z.; software, T.Z., W.Y. and X.W.; Error analysis, T.Z.; writing—original draft preparation, T.Z. and W.Y. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research received no external funding.

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** Not applicable.

**Conflicts of Interest:** The authors declare no conflict of interest.

### **Appendix A**

*Appendix A.1. The Data for the Source Yarn (13 Key Points)*

Zty\_zzti\_yarn, 2,1, 0,1,29.000000,0.069200,1,20.000000,230,100,120,13, 2.000000,2.000000,0.000000,1.0,1,1.000000, 0.500000, 2.000000,2.204900,0.095150,1.0,1,1.000000,0.500000,

2.000000,2.409800,0.000000,1.0,1,1.000000,0.500000,

2.000000,2.614700,−0.095150,1.0,1,1.000000,0.500000,

2.000000,2.819600,0.000000,1.0,1,1.000000,0.500000, 2.000000,3.024500,0.095150,1.7,1,1.000000,0.500000,

```
2.000000,3.229400,0.000000,1.0,1,1.000000,0.500000,
2.000000,3.434300,−0.095150,1.0,1,1.000000,0.500000,
2.000000,3.639200,0.000000,1.0,1,1.000000,0.500000,
2.000000,3.844100,0.095150,1.4,1,1.000000,0.500000,
2.000000,4.049000,0.000000,1.0,1,1.000000,0.500000,
2.000000,4.253900,−0.095150,1.0,1,1.000000,0.500000,
2.000000,4.458800,0.000000,1.0,1,1.000000,0.500000;
!
```
For the format of the file data, see Zheng [11].

*Appendix A.2. The Data for Target Curve 1 (10 Key Points)*

0.00,0.0,−0.08, 0.18,0.05,−0.08, 0.30,0.20,0.08, 0.10,1.00,0.08, 0.30,1.2,−0.08, 0.50,1.2,−0.08, 0.70,1.0,0.08, 0.50,0.20,0.08, 0.62, 0.05 −0.08, 0.80,0.0,−0.08,

*Appendix A.3. The Data for Target Curve 2 (13 Key Points)*

1.2,0.1,0.000000, 1.2,0.7,0.5, 1.2,1.3,0.000000, 1.2,1.9,−0.5, 1.2,2.5,0.000000, 1.2,3.1,0.5, 1.2,3.7,0.000000, 1.2,4.3,−0.5, 1.2,4.9,0.000000, 1.2,5.5,0.5, 1.2,6.1,0.000000, 1.2,6.7,−0.5, 1.2,7.3,0.0,

*Appendix A.4. The Data for Target Curve 3 (13 Key Points)*

4.2,0.1,−0.3, 4.2,0.7,0.6, 4.2,1.3,−0.3, 4.2,1.9,−0.3, 4.2,2.5,−0.3, 4.2,3.1,0.6, 4.2,3.7,−0.3, 4.2,4.3,−0.3, 4.2,4.9,−0.3, 4.2,5.5,0.6, 4.2,6.1,−0.3, 4.2,6.7,−0.3, 4.2,7.3,−0.3, *Appendix A.5. The Data for the Woven Sturcture Being Tested* Zty\_tiangong\_BsplineCurve, 2,12, 0,9, 0.00, 0.0, 0, 0.18,0.0,0.08, 0.36, 0.0,0.0, 0.54, 0.00,−0.08, 0.72,0.0,0.0, 0.90,0.0,0.08, 1.08,0.0,0.0, 1.26,0.00,−0.08, 1.44,0.0,−0.0; 1,9, 0.00, 0.36, 0, 0.18,0.36,−0.08, 0.36, 0.36,0.0, 0.54, 0.36,0.08, 0.72,0.36,0.0, 0.90,0.36,−0.08, 1.08,0.36,0.0, 1.26,0.36,0.08, 1.44,0.36,−0.0; 2,9, 0.00, 0.72, 0, 0.18,0.72,0.08, 0.36, 0.72,0.0, 0.54, 0.72,−0.08, 0.72,0.72,0.0, 0.90,0.72,0.08, 1.08,0.72,0.0, 1.26,0.72,−0.08, 1.44,0.72,0.0; 3,9, 0.00, 1.08, 0, 0.18,1.08,−0.08, 0.36, 1.08,0.0, 0.54, 1.08,0.08, 0.72,1.08,0.0, 0.90,1.08,−0.08, 1.08,1.08, 0.0, 1.26,1.08,0.08, 1.44,1.08,−0.0; 4,9, 0.00, 1.44, 0, 0.18,1.44,0.08, 0.36, 1.44,0.0, 0.54, 1.44,−0.08, 0.72,1.44,0.0, 0.90,1.44,0.08, 1.08,1.44,0.0, 1.26,1.44,−0.08, 1.44,1.44,−0.0; 5,9,

0.00, 1.8, 0, 0.18,1.8,−0.08, 0.36, 1.8,0.0, 0.54, 1.8,0.08, 0.72,1.8,0.0, 0.90,1.8,−0.08, 1.08,1.8,0.0, 1.26,1.8,0.08, 1.44,1.8,−0.0; 6,9, 0.18, −0.18, 0, 0.18,0,−0.08, 0.18, 0.18,0.0, 0.18, 0.36,0.08, 0.18,0.54,0.0, 0.18,0.72,−0.08, 0.18,0.9,0.0, 0.18,1.08,0.08, 0.18,1.26,0.0; 7,9, 0.54, −0.18, 0, 0.54,0,0.08, 0.54, 0.18,0.0, 0.54, 0.36,−0.08, 0.54,0.54,0.0, 0.54,0.72,0.08, 0.54,0.9,0.0, 0.54,1.08,−0.08, 0.54,1.26,0.0; 8,9, 0.9, −0.18, 0, 0.9,0,−0.08, 0.9, 0.18,0.0, 0.9, 0.36,0.08, 0.9,0.54,0.0, 0.9,0.72,−0.08, 0.9,0.9,0.0, 0.9,1.08,0.08, 0.9,1.26,0.0; 9,9, 1.26, −0.18, 0, 1.26,0,0.08, 1.26, 0.18,0.0, 1.26, 0.36,−0.08, 1.26,0.54,0.0, 1.26,0.72,0.08, 1.26,0.9,0.0, 1.26,1.08,−0.08, 1.26,1.26,0.0; 10,9, 1.62, −0.18, 0, 1.62,0,−0.08, 1.62, 0.18,0.0, 1.62, 0.36,0.08,

1.62,0.54,0.0, 1.62,0.72,−0.08, 1.62,0.9,0.0, 1.62,1.08,0.08, 1.62,1.26,0.0; 11,9, 1.98, −0.18, 0, 1.98,0,0.08, 1.98, 0.18,0.0, 1.98, 0.36,−0.08, 1.98,0.54,0.0, 1.98,0.72,0.08, 1.98,0.9,0.0, 1.98,1.08,−0.08, 1.98,1.26,0.0; !

### *Appendix A.6. Data for the Knitted Structure Being Tested*

Zty\_tiangong\_BsplineCurve, 2,4, 0,10, 0.00, 0.0,−0.08, 0.18,0.05,−0.08, 0.30, 0.20,0.08, 0.10, 1.00,0.08, 0.30,1.2,−0.08, 0.50,1.2,−0.08, 0.70,1.0,0.08, 0.50,0.20,0.08, 0.62,0.05,−0.08, 0.80,0.0,−0.08; 1,10, 0.00, 0.6, −0.08, 0.18,0.65,−0.08, 0.30, 0.80,0.08, 0.10, 1.60,0.08, 0.30,1.8,−0.08, 0.50,1.8,−0.08, 0.70,1.6,0.08, 0.50,0.80,0.08, 0.62,0.65,−0.08, 0.80,0.6,−0.08; 2,10, 0.00, 1.2, −0.08, 0.18,1.25,−0.08, 0.30, 1.40,0.08, 0.10, 2.20,0.08, 0.30,2.4,-0.08, 0.50,2.4,−0.08, 0.70,2.2,0.08, 0.50,1.40,0.08, 0.62,1.25,−0.08, 0.80,1.2,−0.08; 3,10, 0.00, 1.8, −0.08,

0.18,1.85,−0.08, 0.30, 2.00,0.08, 0.10, 2.80,0.08, 0.30,3.0,−0.08, 0.50,3.0,−0.08, 0.70,2.8,0.08, 0.50,2.00,0.08, 0.62,1.85,−0.08, 0.80,1.8,−0.08;

### **References**

