Numerical Optimization of Polygon Tessellation for Generating Machine-producible Crochet Patterns Numerična optimizacija teselacije z mnogokotniki za generiranje

The automation of current crocheting technology offers many possibilities. To fully exploit this potential, it is necessary to develop not only hardware, but also methods that enable the design of novel machine-cro-cheted fabrics. In the case of manual crocheting, approaches for an automated generation of crochet patterns according to 3D shapes have already been presented in the literature. However, the most technically advanced crocheting machine prototype currently proposed automates the crocheting of flat fabrics starting from a chain row. Given the limitations and operation of this so-called CroMat crocheting machine, a tool for shaping flat machine-crocheted fabrics according to 2D convex polygons is presented here. With this, surfaces can be divided into crochet stitches using a tessellation process and numerical optimization. The rules of the automated crocheting process were thus followed to ensure the machine manufacturability of generated patterns. Computer models of the fabrics were used as previews. In addition, the shaping possibilities of the CroMat crocheting machine, in particular with respect to increase and decrease stitches, are presented and discussed by means of the tessellation optimization of exemplary polygon shapes. Generally speaking, the algorithm extends the toolbox for designing machine-crocheted fabrics through the automated generation of valid crochet patterns corresponding to input shapes and according to the possibilities of the CroMat crocheting machine prototype.


Introduction
The first developments for the automation of the textile technology of crocheting have recently started.A prototype for the flat crocheting of rectangular fabrics [1][2][3] and a prototype for the circular crocheting of seamless tubes [4] have been presented, while digital methods for designing crocheted textiles have been developed [3,[5][6][7][8][9][10][11].Some already established industrial textile machines are mistakably referred to as crocheting machines, although they are warp knitting machines that can only produce structures similar to crocheting [3,5,6].The machine production of crocheted textiles offers great potential in the replacement of commercial crocheted products, which have thus far been produced exclusively by hand under poor working conditions [3,4].Moreover, automation will enable the use of crocheted fabrics as a novel technology in the field of technical textiles.In this regard, promising applications have already been proposed, such as tissue engineering scaffolds [12], fibrous sound absorbers [13] and textile sensors [14].
Crocheting is similar to knitting but is more difficult to perform by machine because the loops of a new stitch are drawn both vertically and laterally through old stitches (in knitting, they are only drawn vertically) [15,16].Additionally, the formation of one stitch must be completed before the next one can be created [5,6].Due to crocheting's potential for creating diverse stitches and complex structures, such as hyperbolic planes, [17,18] the automation of this technology should give particular attention to shaping possibilities.Increase (INC) and decrease (DEC) are the fundamental shaping methods used in crocheting to change the number of stitches in one course (fabric row) in flat crocheting or in one round in circular crocheting [4][5][6].
Perry et al. [4] were the first to present an approach for the creation of crocheted INC and DEC using a circular crocheting machine (called Croche-Matic) based on a magic ring and crocheting in spirals, which is a crocheting technology with similarities to circular knitting.On account of its mechatronic design, chain stitches (CH) and single crochet stitches (SC) can be automatically created.However, the Croche-Matic prototype has encountered major reproducibility problems due to its 50.7% success rate in terms of stitch completion [4].
The first prototype for automating the crocheting of flat rectangular fabrics, through crocheting slip stitches (SL) in courses with alternating directions based on a chain row, was presented back in 2019 [2].This likewise mechatronic prototype was further developed independently of Croche-Matic and can now produce half double crochet stitches (HDCs) for the first time, in addition to previously automated CHs, SL and SCs [3].On account of the suitable suspension of crocheted stitches, no serious limitations of reproducibility occur, such those reported by Perry et al.Together with this approach, referred to as CroMat, the first tool specific to the machine for designing machine crocheted fabrics, including a modelling preview and a generation of the machine code for manufacturing, was recently proposed [3].
Introduced in this paper is the supplementation of the CroMat with the capability of INC and DEC, and with alternative operations for changing the width of courses.Also presented is an alternative approach for the automated designing of flat-crocheted textiles according to the given shapes of 2D polygons.Producibility by the CroMat of the generated crochet pattern and machine instructions are ensured.This method can thus be used in the future in an industrial context for the rapid design of crocheted textiles, without requiring knowledge of crocheting.In this regard, extended topology-based modelling is beneficial as a preview option.
In terms of control of versatile V-bed knitting machines, there is a trend in research towards high-level programming with shape primitives or 3D objects and automated transfer to knitting patterns, [19,20] as well as translation to machine commands for production [21][22][23][24].For manually crocheted textiles, similar tools have been presented for the automated generation of textual crocheting instructions based on 2D sketches, which are transferred into 3D shape primitives [7], or based on 3D objects [8,9].These breakdowns of geometries into individual stitches in a crochetable sequence relates to the technology of circular crocheting based on a magic ring, which can be used to create 3D structures.In addition, there are some programs for the design of hand-crocheted textiles.These are based on the graphical arrangement of crochet symbols in charts to store patterns and provide no automatic generation of instructions for production [5,6].
In contrast to these fabric design approaches and in the context of high-level programming, the shapes of 2D geometries are transferred to flat-crocheted patterns based on a chain row.Machine instructions for the crocheting of fabric can be automatically generated from output crochet patterns.The focus on the producibility of the CroMat crocheting machine distinguishes the design approach presented herein from related manual crocheting approaches.Moreover, the structure of flat-crocheted textiles is different than circular-crocheted textiles, especially in terms of stitch sequence, so that it is necessary to develop a new logic for dividing geometry into stitches.An algorithm for subdividing the 2D polygon according to the rules and restrictions of machine-crocheting with the CroMat is thus proposed, and the possibilities of shaping the fabric are discussed by considering automatically generated crochet models.

Representation of crocheted fabrics
Crocheted fabrics are commonly described by text-based instructions on how to crochet them [5,6].Pattern information is given by the sequence of stitches, which are represented by short strings.Standardizations and guidelines are introduced by the Craft Yarn Council [25].
Such a representation is used for the programming of the crocheting machine, and information regarding the structure of the crocheted fabric is stored as short strings for stitches in a two-dimensional array.In such an array, as shown in Figure 1, the arrangement of elements corresponds to the topology of the technical face of an automated crocheted fabric.A stitch position is defined by the course and wale (or row and column) numbers.The bottom row represents the first CH course that was initially manually crocheted to the left, while the second course is crocheted by the machine to the right.INC and DEC each comprise two elements, depending on the stitch type (for example sl_inc_a and sl_inc_b for INC with SL, or sc_dec_a and sc_dec_b for DEC with SC).T1 denotes a turn with one CH as the first element of a new course.The first turn after the CH course, with which machine production starts, is called the first lay over (FLO).Such a pattern array with the information about the structure of the crocheted fabric is the output of the developed crochet polygon subdividing algorithm, and input of the topology-based modelling and of the G-code generation.It is also common to represent and visualize crochet patterns graphically with crochet chart symbols, which describe the stitches used and how they are connected [5,6,26].Some of the stitch symbols are explained in Figure 2 b).The slanted orientations of the slightly modified symbols for INC and DEC illustrate the stitch connections [5,6].These are additionally explained in Figure 2 a) by the small red arrows, while the normal stitch connections are indicated by blue arrows.A crochet stitch is connected to the element in the course beneath, and to the previous element from the same course, which is the result of drawing loops during the stitch formation through two previously existing stitches.Conveniently, the arrangement of the symbols in rows and columns corresponds to the arrangement of the strings in the two-dimensional array.The modelling as an additional fabric representation, which was presented in reference 3, was extended here by INC and DEC.In short, the models are based on parameterized key points that are defined for each stitch type as a unit cell and are virtually shifted in space to meet the arrangement of the stitches in the crochet pattern array.A Python script, which is described in more detail regarding the modelling of manually crocheted fabrics in reference 27, was devel-oped for this purpose.The freeware TexMind Viewer tool [28] was used for the spline interpolation of the key point curves, volume-sweeping along the centre yarn path and the visualization of the freeware tool.
Figure 3 depicts such a topology-based key point model of the yarn path generated as a visualization from the crochet pattern array representation.The construction of the stitches as well as their interlooping are obtained from the idealized illustration of a fabric crocheted by the machine.As indicated, different stitches have different heights, while the highest stiches set the height of a course.It is also remarkable that courses are positioned staggered to each other, which is due to the fashion of the walewise connections of crocheted fabrics.This renders the structure of crocheted textiles different from the regular wales of knitted fabrics.With regard to INC with SC at the beginning of the third course, Figure 3 illustrates how two SCs in a course emerge from one stitch in the course beneath.In comparison, the structure of INC with SL (at the beginning of the fourth course) is slightly less obvious, although INC follows the same principle, as can be seen from the symbolic representation in Figure 2. Regarding DEC, however, both stitch types illustrate the drawing of the loops of one stitch through two stitches in the course beneath.Due to machine limitations, only one stitch can be added with INC at the start of a course, while DEC removes only one stitch at the course's end.If it is necessary to add or remove more than one stitch in a course, further operations described in the supplementary materials are used for these additional stitches.Additional details regarding INC and DEC as well as the CroMat crocheting machine are also presented in those materials.
Similar to the text-based instructions of crochet patterns, the G-code for machine production can be seen as a further representation of automatically crocheted fabrics.Such a G-code program can be generated by traversing the crochet pattern array according to the crocheting sequence and mapping the elements to G-code macros, which are programmed for each stitch in relative coordinates.This has the advantage of easy interchangeability, so that modifications in the stitch formation procedure can be implemented flexibly.More details can be found in reference 3.
2 Subdivision of shaping polygons by crochet stitches

Principle of subdividing by stitches
Fundamentally, the breakdown of a polygon into a crochet pattern is a tessellation problem, since the polygon can be seen as a space that is to be partitioned into smaller stitch cells and uncovered areas [29].To ensure machine manufacturability, pattern generation must follow the constraints of the automated crocheting process.Due to the various rules to be considered, no well-known area tessellation algorithms, for example centroidal Voronoi tessellation [30], can be applied.Moreover, good algorithms excel by being problem-specific, especially regarding real-life applications [31].A new algorithm was therefore developed which traverses a 2D polygon according to the crocheting process, and decides stitch by stitch whether it may be set according to the rules.
For the purpose of simplification, stitches are represented by rectangles with the width as stitch length (/) and the height corresponding to the stitch height (h).The stitch dimensions relate to the values used for modelling.The rectangles for modelled SL and SC stitches are shown in Figure 4.It should be noted that the stitches largely overlap with the surrounding stitches, while the stitch rectangles are defined without these overlaps for reasons of simplicity.According to the taxonomy of Lee et al., [29] such partitioning by polygons representing stitches relates to vector or feature-primary tessellation, where the boundaries of features are described as polylines.In this regard, the shaping polygon is first divided into a course as a feature.This sub-polygon is then further partitioned by the stitch rectangles.Afterwards, the next course is partitioned.Stitches are placed in the polygon according to the sequence of crocheting, gradually filling the two-dimensional array with information regarding the resulting crochet pattern.
The main steps of the basic structure of the developed tessellation algorithm are shown in Figure 5.If no further course fits into the polygon, or no element can be inserted at the beginning of the course or only one element was inserted in a course (which is then removed), the algorithm terminates and outputs the results.Note that a course with only one element, namely a turn, is not a valid course because the turn aligns next to the last stitch of the previous course.The stitch type and its width, which is set by default to 5 mm according to the needle gauge of the machine, as well as a convex polygon with an arbi-trary size and degree must be defined by the user.One polygon edge must be in line with the x-axis of a Cartesian coordinate system.It can also be decided whether the stitch rectangles are allowed to exceed the polygon within certain limits, i.e. 30% of the stitch area by default, or without this tolerance, i.e. the polygon limits may not be exceeded.

Exemplary crochet tessellation of a triangle
In Figure 6, the principle of the crochet tessellation is illustrated without (a to c) and with a tolerance (d to f) for exceeding the polygon's boundaries.A stitch is indicated by two green vertical segments, each consisting of two points, which are taken into account for deciding on stitch placement.
According to the first step of the flow chart (cf. Figure 5), it is checked whether the corresponding sub-polygon with the CH height fits into the shaping polygon.The sub-polygon is then calculated (step 2), as well as the start of the course (step 3), which is the position of the outermost segment of the first stitch.This starting point, which can be shifted later to achieve better results, is at the right end of the sub-polygon (the first course goes to the left).In the sub-polygon, stitches are then inserted according to steps 6 and 7 (cf.Figure 5) until their segments exceed the polygon boundaries or no longer meet the tolerance condition.
An exception occurs at the end of the CH course due to the specificity of the machine, and the CH before the following special turn is removed.This is because the last CH is used as the FLO with which machine production starts (cf. Figure 1).The removed segment is indicated in Figure 6 b) by the dashed line in the area marked u 2 .
Following steps 8 and 9 of the flow chart (Figure 5), the next course is calculated taking into account the stitch height, and steps 1 to 4 are computed.As can be seen in Figure 6 b), the first element of the second course (5), i.e. the FLO, is placed according to the alternating crochet direction and staggered stitch pattern.With the overlapping tolerance, four elements can be fitted in the second course as shown in Figure 6 f) instead of the two elements depicted in Figure 6 c).
In the third course of partitioning without taking into account a tolerance (Figure 6 c), no element is placed.This is because the pattern and the polygon

Figure 6: Crochet subdivision of a triangle without allowing the stitches to exceed the shaping polygon (a to c) and with exceeding allowed as long as 70% of a stitch area is inside the polygon: a) placement of the first CH stitch in the first course; b) start of second course; c) result of the crochet subdivision without tolerance; d) initial situation of the subdivision with permitted exceeding of the borders by the stitches; e) start of the second course; f) result of the respective crochet subdivision
shape only allow the placement of one stitch, which is then removed due to the check in step 8 and step 10 of the flow chart (Figure 5).
In partitioning taking into account a tolerance, the program's termination is also the result of the deletion of a single element, but here in the fourth course.Previously, the third course was filled with the turn 10' and the stitch 11'.To illustrate the logic of determining the x-position of the turn's first segment, an alternative position is indicated by the dashed line (near area v 2' ).
Generally, only discrete stitch positions corresponding to the offset of the stitches from different courses are possible.For example, the dashed segment (near area v 2' ) is an option but was deemed unsuitable because the respective stitch would exceed the polygon boundaries by more than 30%.For each turn, the algorithm checks first whether it is possible to add a stitch before it checks the possibilities to not change the number of stitches or to remove a stitch in the beginning of the course (RB; see supplementary materials).If RB is not sufficient to fit the shape, a stitch is dropped at the end of the previous course to allow suitable turn placing.

Assessment of the quality of crochet tessellation
Only uncovered areas (u i ) are present in the case of subdivision without exceeding polygon borders (cf. Figure 6 a to c).When the polygon boundaries may be exceeded, equation 1 is used to calculate the uncovered (u i ) and overlapping (o j ) areas based on the difference between the border area (ba) and the stitch area (sa).A ba refers to the area at the beginning or end of a course, including the first or last stitch (cf. the red dashed lines in Figure 6).In this regard, p i is the area of a stitch exceeding the polygon while v i is the part of the stitch inside the polygon (cf. Figure 6 f).
If no stitches are set in a course, the resulting areas are also counted as uncovered areas u i (cf. Figure 6 c and f).The absolute values of areas u i and o j are added to a total area-error value (Z; see equation 2).The lower this value is, the better the shaping polygon is filled with crochet stitches, and the better mimicking of the shape.
With the strict condition not to exceed the polygon's boundaries (cf. Figure 6 c), the uncovered area totals 173.61 mm 2 .With regard to the area of the shaping polygon, the subdivision error is 58.45%, which means that most of the area was not covered.In contrast, the error of the second approach, taking into account a tolerance (cf. Figure 6 f), is only 30.00%, with 74.72 mm 2 of non-covered area and  6: a) output stitch array for the first partitioning approach without a tolerance for stitches exceeding the shaping polygon's border; b) array of the second partitioning approach with a tolerance taken into account; c) computer-generated model of the first approach; d) model of the second approach 14.38 mm 2 overlapping the shaping polygon.Evidence that this approach yielded a better result can also be seen in Figure 7 by comparing the models generated from the output stitch arrays.
Regarding the crochet pattern in Figure 7 b), it is noteworthy that two stitch positions are removed in the second course by combining DEC and removing a stitch at the end (RE).The latter is an additional shaping method described in the supplementary materials.DEC is always used for removing the first stitch at the end of a course, while potential additional stitches are then removed with RE.At the beginning of the third course, the number of stitches is further reduced by one using the RB operation.Below, in order to present better results, only the subdivision with a tolerance for exceeding the polygon boundaries with stitches will be considered.
In general, the stitch pattern and the respective area-error are determined from the starting point, as the first point on the right segment of the first stitch set in the polygon.This first stitch is placed, by default, as far as possible to the right side of the first course without exceeding the polygon borders.To improve the coverage of all possible polygon shapes, the tessellation can be optimized, depending on the first stitch position.

Optimization of the tessellation by shifting the starting point
The changing of uncovered and overlapping areas, as well as crochet patterns, depending on a starting point shift in x-direction, is illustrated in Figure 8.Here, a section of the triangle from Figure 6 is considered.Moreover, the specific calculation of u i (uncovered) and o j (overlapping), depending on the border area according to equation ( 1), is demonstrated.Generally, the problem of finding an optimal subdivision of a 2D polygon by stitch rectangles is similar to the common initial situation of a bi-dimensional cutting stock problem or packing problem, where a set of smaller objects is placed on a set of larger objects under certain conditions [31,33].Usually, the partitioning of the objects is then optimized so that the waste is minimized.Optimizing the area coverage with crochet stitches similarly minimizes the uncovered areas seen as waste.
The function Z is introduced to describe the total area-error depending on the shifts in x-and y-direction of the starting point of the first stitch placed in the shaping polygon (equation 2).Regarding equations 3 and 4, the boundaries of the x-shift and y-shift, as design variables, are defined with as the stitch length and as the stitch height, respectively.
A farther shift than one stitch width or height in a positive or negative direction does not make sense because the stitch pattern would be repeated with a greater chance of error (cf. Figure 9).
Due to the complexity of subdividing countless possible shaping polygons while respecting the various rules of crocheting and the specifics of a machine, the analytical description of the functional relationship between the displacement of the starting point and the resulting area-error is unknown.A corresponding analysis would exceed the scope of this paper.For this reason, commonly known optimization algorithms from cutting stock problems [34] cannot be applied here.Instead, a numerical approach is followed, where many data points are sampled and the best one selected.This is less computationally costly and error prone than approximating function Z for computing its minimum to find the optimal starting point.
The sampled data points consist of the starting point shifts in the x-and y-direction with the associated area-error values.For the respective subdivisions, the step size (depending on the stitch size) and the number of steps for a shift are set by the user.The default value of the step size in x-direction is divided by the number of steps, while it is divided by the number of steps for the y-direction.
The algorithms are implemented in Python 3, while the SymPy library [35] is used for the geometric calculations.Also, the NumPy library [36] is utilized for the handling of data.Additionally, the open source Python library pytexlib [37] is applied for describing and saving the modelled textiles.The TexMind viewer [28] is used to visualise the models.Results are plotted using the Matplotlib library [38].The parallel computing of the tessellation runs is implemented to speed up the algorithm via multiprocessing.All the software developed for surface decomposition, machine code generation and modelling are based on open-source frameworks.

Results and discussion
Below, the chosen digital representation of crocheted fabrics is discussed and the possibilities of shaping 2D flat crocheted fabrics producible by the CroMat crocheting machine are presented.The respective crochet subdivision algorithm of shaping polygons is also discussed.

1 Computer representation of crocheted fabrics
The representation of the crochet patterns in python lists is well suited in the context of the extension of the crochet design software from reference 3, and supports the modular approach.This data structure represents the textile in the fabric space.In terms of knitted textiles, this is a known approach, with the advantage that validation is easy to perform [39].The disadvantage that manufacturability is more difficult to achieve at this level of representation [39] does not arise here, since producibility is already taken into account when populating the data structure.Due to the programming of the crocheting machine at the stitch level by grouping machine instructions to stitches, [3] machine instructions or models of the fabrics can be generated directly from the data structure.The domain-specific language developed by Seitz et al. [5,6] for designing manually crocheted textiles also ensures manufacturability and a structure's validity during the creation of a fabric.Beyond 2D, 3D textiles can be represented and visualized via crochet charts.An interesting difference lies in the modelling of SLs.According to Seitz et al., SLs do not add height to the textile and are the only stitch type that provides no insertion points for subsequent stitches.This corresponds to the conditions of manual crocheting, where it is difficult to insert the crochet hook into SLs and where these are mainly used for the seam.In contrast, machine production facilitates the efficient formation of new stitches based on SL working stitches and the construction of entire fabrics from this stitch type.Therefore, unlike Seitz et al., SLs are interpreted here as a normal crochet stitch and modelled by adding height as well (cf.Figure 10).Furthermore, Seitz et al. [5,6] consider generating machine instructions in the future.In terms of the CroMat, this would be possible with the development of the suitable mapping of the representation of Seitz et al. to the machine's G-codes.To meet the limitations of the machine and automated flat crocheting in rows, their validation would have to be revised.Moreover, SLs should be represented differently so that the manufacturing capabilities of the machine are not restricted.

Numerical optimization of the triangle crochet tessellation
In terms of the optimization of the start position, how the quality of the surface tessellation and thus the shaping of the crocheted fabric depends on the position of the first stitch as the starting point is studied.Thus, it can be estimated whether and to what extent such an optimization is necessary for the future application of the tool.In this regard, the starting point of the triangle subdivision shown in Figure 6 was shifted negatively and positively in the x-direction by 10 steps, each with a step size of one tenth of the stitch width.According to the default values, the step size in the y-direction was set to one tenth of the height of the subdividing stitches.To avoid repetition of the crochet pattern and to save computation time, only y-shifts smaller than the height of the CHs of the first course were performed.Thus, fewer subdivision runs are calculated with respect to the y-direction.A crochet pattern repetition due to y-shifts would inevitably have a larger area-error, due to the missing coverage or overlap of the entire CH course.
In terms of displacement in the x-direction, a repetition of the crochet pattern can be observed with a deviation of the starting point of one stitch width (5 mm).As shown in Figure 9, the repetitions (see -2.5 mm and 2.5 mm or 0 mm and 5 mm) differ only in the first stitch and thus have deviating area-error values.In terms of the y-shift of -1 mm, the entire first course extends beyond the polygon increasing the o j part of the area-error.However, such a shift can lead to another course being filled in the upper part of the polygon, which can be advantageous, depending on the shape of the polygon.

Figure 9: Crochet patterns resulting from exemplary starting point shifts, which were calculated during the numerical optimization of the triangle's crochet subdivision with SCs
In order to visualise the results of all crochet subdivisions of the triangle from Figure 6 and 9, the total area-errors Z (see equation 2), which depend on the starting point shifts, are colour coded and plotted in Figure 10.It is evident that a positive or negative shift in the y-direction has a greater impact on the error values than a shift in the x-direction.This is because shifting in the y-direction affects an error area below the first course (cf. Figure 9) and above the last one, while an x-shift only changes the area coverage of the courses' first and last stitches.According to the distribution of small error values in the case of no displacement in the y-direction, a sufficiently optimal crochet subdivision with an area-error value of 19.65% was found with a displacement of the starting point by 4.5 mm in the x-direction.This is shown with the resulting model in Figure 11.Due to optimization, a better tessellation solution and crochet pattern was found.
Next, the stitch types of SL and SC are compared with respect to a crochet subdivision of a scaled variant of the shaping triangle.The same starting point shifts were performed.More stitches can be placed in a larger polygon, which generally facilitates a better replication of the shape with the crocheted fabric.Accordingly, it is evident from Figure 12 that the area-error values of the initial and optimized starting points are lower and that the shape is better reproduced compared to Figure 11. Figure 12 also shows that the lower stitch height of the SLs facilitates a subdivision with more stitches.Interestingly, the best SC subdivision resulted in a smaller area-error than the best SL subdivision.However, the replication of the shape is similar.

12: Comparison of crochet subdivision with SC and with SL: a) initial subdivision with SCs and no shifting (area-error value of 18.88%); b) SC subdivision result with minimal area-error value of 5.64% and starting point shifted by 3 mm in the x-direction; c) model corresponding to b); d) initial subdivision with SL and no shifting (area-error value of 13.85%); e) SL subdivision with minimal area-error value of 9.12% and starting point shifted by 3.5 mm in x-direction; f) model corresponding to e)
For both SL and SC, the optimal tessellations show only a shift of the starting point in the x-direction.Accordingly, the area-error values shown in Figure 13 are similar to those in Figure 10 and again indicate a greater impact of the error values by shifting in the y-direction.The more common SC stitch type is used for subsequent subdivisions.

Figure 13: Area-error values of crochet subdivisions with starting point shifts of a scaled triangle: a) SC as stitch type; b) subdivision with SL
To investigate the crochet subdivision results in more detail, in particular with regard to the visible repetitions of the minima regions visible in Figure 13, the resolution is increased.Accordingly, the starting point of the division of the scaled triangle is shifted with a step size of l/20 mm or h/20 mm, respectively.The higher resolution of Figure 14 confirms the presence of two local minima repeating on the x-axis.

Figure 14: Area-error values with colour scale as crochet subdivision results with a higher resolution by using a step size of stitch length (/) / 20 mm or stitch height (h) / 20 mm for shifting the starting point
Despite the significantly higher number of data points (1,024 compared with 272), the same shift of the starting point was again chosen as the best one (cf.Figure 12).However, this may be a coincidence.Depending on the application and the available computing resources, the shifts with step sizes of one tenth of the stitch size might probably be sufficient.Nevertheless, to further explore the possibilities of the developed shaping tool and the correlation between the starting point and the quality of the subdivision, a finer optimization with a step size of l/20 mm or h/20 mm is applied.

Crochet tessellations of additional shapes
To further investigate the shaping possibilities given by the extended capabilities of the crocheting machine to change fabrics widths, polygons with higher orders are also tested.In this regard, Figure 15 shows the optimization results of the crochet subdivision of a quadrilateral.The illustrated area-error values are similar to the previous polygons in that strong y-displacements affect the area-error more than strong x-displacements.However, for shifts on the x-axis, less distinct local minima of the area-error are seen.Here, with a relatively high computational effort, the area-error of the subdivision could only be improved slightly, from 6.44% to 5.23%, by shifting the first stitch by 0.25 mm in the x-direction.
In terms of the initial and best subdivisions of the quadrilateral shown in Figure 16 a) and b), it is evident that the first stitch of the last course protrudes significantly more than the allowed 30% beyond the polygon boundaries.This is due to the difficulty of representing the slight slope of the upper edge (see also Figure 16 c).In general, with a combination of DEC at the end of the previous course and RB (see supplementary materials) at the beginning of the current course, the position of the first stitch of the corresponding course can be shifted by only two stitch positions.If more is required, the last stitch in the previous course is also removed and the beginning of the current course is set accordingly.Here it becomes apparent that the tool will have to be expanded in the future to allow the removing of more stitches in the previous course to better fit the shape.

Figure 16: Crochet patterns resulting from the subdivision optimization of the quadrilateral: a) generated crochet pattern with initial starting point; b) optimized crochet subdivision; c) modelled pattern of the best run
The generated crochet patterns according to the shape of an irregular pentagon are presented in Figure 17.Similar to the previous examples, the shape can be fundamentally recreated by the crocheted fabric, while the slopes of the edges and sharp peaks cannot be reproduced efficiently due to the limitations of the machine's shaping operations.As shown in Figure 18, the pattern of the area-error values exhibits, similar to the scaled triangle, some kind of repetition along the x-axis with two local minima.Another similarity is that an additional course could be filled with stitches due to the starting point shift (cf. Figure 17).Lastly, an exemplary crocheted fabric is shaped as a regular hexagon using the developed algorithm.In Figure 19, the corresponding model shows that the shape is fundamentally reproduced, but the symmetry of the structure is not achieved.The crochet pattern could be improved from an area-error of 6.70% to an error of 4.68% by moving the starting point 1.25 mm in the x-direction.
The visualization of the area-error, depending on the shifts shown in Figure 20

Discussion of crochet tessellation results
The observed repetitions of the area-error patterns with local minima along the x-axis emerge because the crochet pattern repeats itself, with the first stitch as the exception, when the starting point is shifted by one stitch width (5 mm) on the x-axis (cf. Figure 9).The local minima further away from the initial starting point are associated with larger error values.In a negative x-shift, the first stitch position of the initial starting point is not covered, while large positive x-shifts cause the first stitch to extend far beyond the shaping polygon.
Overall, the presented crochet subdivisions show that the developed algorithm indeed facilitate the shaping of machine-producible crocheted fabrics according to diverse convex geometries.The quality of shape matching, represented by the error of uncovered and excessively covered areas, can be improved by increasing the computational effort and calculating multiple subdivisions with shifted starting points.This simple numerical optimization yielded better results in all cases in which the starting points were shifted a few millimetres in the positive x-direction to a minimum of the error values.A step size of one tenth or one twentieth of the stitch width is suitable for this purpose.Depending on the requirements for the quality of the tessellation and shaping, the step size can be adjusted.In addition to the trend of the location of the minima, the tendency was observed that large y-shifts usually result in large area-error values.Based on these findings, computing time can be saved in future applications by scanning a smaller range in the y-direction with perhaps a coarser resolution.
The shaping possibilities of the developed Cro-Mat prototype of a real crocheting machine are much more limited compared to the almost unlimited possibilities of manual crocheting, and compared to technically advanced V-bed knitting machines.This is mainly due to missing loop transfer capabilities, so that INC and DEC can only be performed at the beginning and end of a course, respectively.Nevertheless, the development and demonstration of shaping possibilities are important for technical progress in the automation of crocheting.To expand the shaping possibilities of crocheting machines in the future, loop transfer should be integrated, for example, by means of fashioning points, as known in straight bar frames [40].

Comparison of the crochet tessellation approach with literature
Researchers have already studied the division of surfaces into crochet patterns.Çapunaman et al. [9] followed a similar procedure of inserting the courses or curves before populating them with stitches, while transferring the shape of a 3D geometry applying a non-uniform rational basis spline (NURBS) UV division to crochet patterns.The difference is that the stitches from different curves/rows are not constrained with respect to a stitch offset as it was done in this study.Thus, in contrast to the idealized offset of the stitches modelled here, Çapunaman et al. assumed that the stitches will deform appropriately according to the desired shape.As a restraint regarding manufacturability, the continuity of the stitch sequence is considered, while the rules of INC and DEC are taken into account.In the approach presented in this paper, additional rules for machine manufacturing, but only 2D geometries, are considered.
Guo et al. 's [8] algorithm for the automated generation of crochet patterns based on a manifold 3D mesh builds on a previous approach for machine-knitted textiles [21,23].The stitches are basically represented by squares containing information about topology, connections to others, and instructions for fabrication, but triangles or pentagons for INC or DEC are also used.The data structure in this paper is similar to their approach in that the stitch-representing rectangles are mapped to information about topology or fabrication.The difference is that here the stitch structure is assumed to be slightly offset from course to course, while Guo et al. modelled them without such offsets.This leads to a warped picture compared to the representation chosen here.However, the relaxed state of crocheted textiles remains unexplored.It is thus not possible to judge which representation is more realistic.In general, crocheted textiles are underresearched [27].
Overall, it is quite common in literature to mesh a surface with rectangles representing stitches on a surface [8,9,[19][20][21]23].The approach presented herein differs because not the whole surface is meshed by rectangles.Instead, the rectangles are placed only at permitted positions in a fixed orientation one after the other, taking into account rules for valid textiles and manufacturability.In this context, the consideration of the manufacturability of a crocheting machine constitutes a new approach.Corresponding to machine manufacturability, crochet pattern generation is here limited to 2D shapes.To date, the manufacturability of a real crocheting machine has only been addressed in reference 3. Thus, an important contribution is made regarding the research of the possibilities of machine-made crocheted textiles and the development of technologies for future, industrial use.

Conclusion
In this paper, a novel algorithm for automatically generating and shaping crochet patterns manufacturable by a real crochet machine according to 2D polygons is presented and discussed.Machine-producibility is ensured by successively filling a shaping polygon with crochet stitches represented by rectangles according to the rules and limitations in connection with automatically manufacturing the respective fabrics with the CroMat crochet machine prototype.As a result, only valid patterns are generated, which, given the limited capabilities of the crochet machine, can sufficiently replicate shapes of convex polygons.In this regard, the missing capability of stitch transfer is especially limiting, and stitches can only be added or removed in the beginning or end of a course.This is achieved, in particular, by INC and DEC operations, which were presented here for the first time with regard to automated flat crocheting based on a chain row.In the future, the machine will be expanded to facilitate the production of more diverse shapes.
The quality of the subdivision of a polygon by crochet stitches is determined by the area-error, which is calculated by adding the areas not covered by the rectangles and the areas exceeding the polygon boundaries.To increase the quality, the first stitch, on which the crochet pattern depends, can be shifted by fractions of the stitch size to the left, right, top and bottom for a numerical optimization of the replication of the polygon's shape by the crocheted fabric.The tessellation optimizations of exemplary polygons from triangle to hexagon were investigated.In all cases, a vertical shift of the starting point results in larger error values, while better solutions were found using horizontal shifts.Due to repetitions of the crochet pattern in a horizontal shift of one stitch width, the local minima of the error values repeat, with a trend to lower error values near the initial starting point.Based on these findings, the search range of the optimization can be narrowed in the future to reduce the computational effort.
With the developed algorithm, the previously limited possibilities for the design of machine-crocheted textiles are significantly expanded.Specifically, it is an expansion of the design tool presented in reference 3. Accordingly, the 2D shaping and automated creation of producible crochet patterns lends itself to future application in an industrial context.The tool is especially useful since it does not require any knowledge of crocheting for the design of diverse crocheted structures.The presented work constitutes an important step in the development of the thus far unexplored crocheting technology with respect to novel products and the replacement of manually produced commercial crocheted products.

Supplementary materials 1 Crocheting machine prototype and limitations
According to the process of manual flat crocheting, the stitches are formed by the CroMat crocheting machine prototype successively in the direction of the current course.At the end of the course, a turn stitch is made, which comprises one or few chain stitches (CHs) and is the first element of the next course with an alternated crochet direction.Stitches, which also include turns, are the elements produced by the machine to create a whole fabric.In contrast to manual flat crocheting, the fabric in this process is not rotated and thus all stitches are drawn through the fabric from one side.This creates a fabric with a technical front and technical back [1].
The machine features a mechatronic design, unlike conventional textile machines that are operated rather mechanically [2].The machine elements are moved by electric motors, which are centrally controlled by a microcontroller that receives G-code commands as input.For each stitch type, depending on the crochet direction, G-code macros are defined and must be arranged in the correct order according to the sequence of the crocheting process before they can be sent to the machine.Further details on the design and control of the machine can be taken from reference 1.
Implementation of the machine results in limitations compared to manual crocheting.As such, only slip stitches (SLs), single crochet stitches (SCs), half double crochet stitches (HDCs) and turns with CHs can be created.The insertion point of the special needle, which functions as a crochet hook, into the working stitch is restricted to the common case of insertion under the top loop of the working stitch, as marked in Figure 3 of the paper.The stitches of the last course can be used solely as working stitches for the creation of new stitches, while in manual crocheting the crochet hook can form a new stitch anywhere in the fabric.As another characteristic of the machine, there is never a CH below the first turn, which is the first operation formed by the machine and is called first lay over (FLO).Moreover, the first CH course, namely the chain row with which each crocheted fabric starts, is always directed to the left and must be manually crocheted on the needles of the needle bed.
Due to the single needle bed and no additional machine elements such fashioning points known in straight bar frames, [3] the loop transfer of previously produced stitches to other needles is not possible.Thus, the number of stitches in a course can only be changed at the beginning or end of a course by adding or removing needles.Adding one stitch with INC is only possible at the course's beginning, since needles can be added there without the need of a loop transfer, while removing one stitch with DEC is only possible at the end of a course.In manual crocheting, no restrictions exist regarding the position or numbers of stitches manipulated with INC or DEC.As a rule, with INC, multiple stitches are worked into one stitch of the previous course to widen the fabric.With DEC, the fabric is tapered by working one stitch in multiple stitches of the previous course.

Machine operation to alter a fabric's width
The crocheting machine is capable of adding one stitch at the start of a course by performing an INC operation.For this, the leading loop (LL) of the turn's CH is suspended at one needle position further out.Thus, the first stitch built in the working stitch can be placed in the usual position of the turn's LL, and the second stitch based on the same working stitch is suspended at the former needle position of this working stitch.The resulting INC structure is depicted in Figure 3.A special rule is that no INC can be executed at the beginning of the second course due to the special operation of the FLO.However, if the polygon shape requires this, a CH is added in the first course as a workaround.
Forming an additional stitch based on the same working stitch used for INC is not possible because the turn's LL would be stretched too far, resulting in severe forces on the machine elements due to yarn friction.Performing multiple INCs in one course is also not possible because this would require stitch transfer.For the same reasons, only one stitch can be dropped at the end of the course by DEC.The structure of INC and DEC is shown in Figure 3 of the paper.For DEC, one stitch is built on two working stitches (in crochet abbreviated as sc2tog) by drawing a loop through each working stitch and then drawing the new LL through these loops and through the old LL.
Besides these automated methods, which are commonly used in manual crocheting for altering the number of stitches in a course, additional options are provided by the machine.Again, these methods are based on adding or removing stitches in the end or at the beginning of a course.In general, removing stitches from needle positions is easier than adding additional stitches to needle positions.
As can be seen in Figure S1 a) and b), a stitch can be added at the beginning of a course (AB) by placing the CH of the turn at one needle position further outward and building a CH at the usual turn position.This is similar to INC, which is preferred here because it is more like manual crocheting, and thus only one stitch can be added in this way.
In contrast to AB, up to three stitches can be added at the end of a course (AE) by forming CHs, as illustrated in Figure S1 c) and d).The CHs are suspended on new needles and can be used as working stitches in the next course.The limited number of added CHs with an AE is to prevent them from tightening excessively due to the fabric take-off and causing errors in drawing loops through them in the next course.
Additional methods for reducing the number of stitches in a course are illustrated in Figure S2.By dropping the stitch at one position further inward next to the usual turn position and suspending the LL of the latter at this cleared position, a stitch is removed at the course's beginning (RB).With this method, shown in Figure S2   discarded stitches is limited to one to avoid stresses on the needle holding the LL, which would occur if the LL of the turn was stretched over more than one stitch position.
Lastly, stitches can be removed by dropping an arbitrary number of remaining working stitches, which were not used as working stitches to form stitches in the current course, at the end of a course (RE).This is illustrated in Figure S3 c) and d).Here, an arbitrary number of discarded stitches is possible, because no stitch transfer and no stretching of the LL over multiple needle positions is required.To make it more similar to hand crocheting, DEC is always performed for the first stitch by which the course is to be reduced at the end.Further stitch positions can then be removed with RE.

Figure 1 :
Figure 1: Computer representation in a 2D array with strings for stitches arranged topologically and corresponding to the technical face of an exemplary crocheted fabric

Figure 2 :
Figure 2: Symbolical representation of the crochet pattern shown in Figure 1: a) graphic representation of the crochet pattern with symbols; b) description of stitch symbols based on international standardization but modified slightly for INC and DEC

Figure 3 :
Figure 3: Representation of an exemplary crocheted fabric (cf.Figures 1 and 2) as a topology-based key point model of the yarn path.The red "x" marks one of the points of needle insertion to draw yarn through the working stitch.

Figure 4 :
Figure 4: Examples of the arrangement of the stitch polygons with indicated stitch length (l) and height (h): a) Part of rectangular fabric consisting of SLs; b) Respective SC fabric

Figure 5 :
Figure 5: Flow chart of the crochet tessellation algorithm based on a convex input polygon.Y and N are abbreviations for yes and no.Created using the PapDesigner freeware from Friedrich Folkmann [32].

Figure 7 :
Figure 7: Crochet pattern arrays and models of the results of the exemplary subdivisions of Figure 6: a) output stitch array for the first partitioning approach without a tolerance for stitches exceeding the shaping polygon's border; b) array of the second partitioning approach with a tolerance taken into account; c) computer-generated model of the first approach; d) model of the second approach

Figure 8 :
Figure 8: Effect of shifting the starting point in x-direction on the areas u i and o j , , and on the crochet pattern.The border area (ba) is marked with the red dashed line and the shifted right segment of the first stitch is displayed as a yellow line: a) first stitch shifted by -3 mm; b) initial starting point; c) starting point shift of 1.5 mm; d) x-shift of 3 mm

Figure 10 :
Figure 10: Area-error values depending on shifts of the start position with respect to the polygon in Figures 6 and 9 with colour scale

Figure 11 :
Figure 11: Result of the optimized crochet tessellation: a) Corresponding crochet subdivision and b) respective model

Figure
Figure 12: Comparison of crochet subdivision with SC and with SL: a) initial subdivision with SCs and no shifting (area-error value of 18.88%); b) SC subdivision result with minimal area-error value of 5.64% and starting point shifted by 3 mm in the x-direction; c) model corresponding to b); d) initial subdivision with SL and no shifting (area-error value of 13.85%); e) SL subdivision with minimal area-error value of 9.12% and starting point shifted by 3.5 mm in x-direction; f) model corresponding to e)

Figure 15 :
Figure 15: Area-error values with colour scale in terms of the crochet subdivisions of the quadrilateral polygon with starting point shifts

Figure 17 :
Figure 17: Irregular pentagon as shaping polygon for crochet pattern generation: a) First crochet subdivision pattern with initial starting point and area-error of 10.10%; b) Crochet pattern of the optimization with start position shifted by 0.75 mm in the x-direction and with an area-error of 7.47%; c) Respective model of the best run

Figure 18 :
Figure 18: Area-error values with colour scale in terms of the optimization of the irregular pentagon , again illustrates two distinct local minima with a close to zero y-shift.At the right side, a further repetition of the error pattern emerges with another potentially local minimum.With a 1.25 mm x-direction shift, the ideal position of the starting point was placed in one local minimum.Large y-shifts result once again in large area-error values.

Figure 19 :
Figure 19: Crochet patterns corresponding to a regular hexagon as shaping polygon: a) Initial crochet subdivision; b) Crochet pattern resulting from the optimization; c) Model of the optimal subdivision

Figure 20 :
Figure 20: Results of the starting point optimization of the regular hexagon with area-error values in colour scale a) and b), the number of

Figure S1 :
Figure S1: Options to increase the width of machine-crocheted fabrics.a) Crochet chart of an exemplary SL fabric by adding a stitch at the beginning of a course (AB); b) Topology-based model of the fabric with added stitches at the beginning of the course; c) Example crochet chart for adding a stitch at the end of a course (AE); d) Model of a respective fabric with added stitches at the ends of the courses.The basic CHs of the first course with crochet direction to the left and the first turn (FLO) are displayed in blue.

Figure S2 :
Figure S2: Options to decrease the width of machine-crocheted fabrics.The basic CHs (going to the left) and the FLO are marked in blue similar to Figure S1; a) Crochet chart of an exemplary machine-crocheted fabric, where a stitch is discarded at the beginning of the second and third course (RB); b) Model of the fabric with discarded stitches at the beginnings of courses; c) Crochet chart of a fabric showing the discarding of stitches at the ends of the courses (RE); d) Respective model for discarding a stitch at the end of a course.