A simple parametric model of plain-knit yarn curves, with C code and other resources.
TeX
68
15 commits
updated Jun 28, 2023
A simple parametric model of plain-knit yarn curves, with C code and other resources.

This repository provides code implementing closed-form expressions for smooth curves resembling a plain-knit stitch, suitable for appearance modeling and previsualization. A unique feature of this model is that it also describes the twisted yarn fibers running along this stitch, making it suitable for modeling marled yarn. Adjustable parameters control the knit spacing, loop roundness, yarn thickness, and rate of fiber twisting. Tileable displacement maps and code for generating curves are also provided.
Note. The note YarnCurve.pdf provides a more thorough description of the plain-knit curves, including a step-by-step derivation. The LaTeX source files for this note can be found in the note subdirectory.
Implementation. The code subdirectory contains a plain-C (ANSI C90) implementation of the curve functions, as well as routines for writing curves to the Wavefront OBJ mesh file format. This code should be easily portable to most other languages. Several implementations have been developed, in a variety of packages:
| front | back | alpha |
|---|---|---|
![]() | ![]() | ![]() |

A Simple Parametric Model of Plain-Knit Yarns by Keenan Crane is licensed under a Creative Commons Attribution 4.0 International License. Code is released under an MIT License.
@misc{Crane:2023:SPM,
title = {{A Simple Parametric Model of Plain-Knit Yarns}},
author = {Crane, Keenan},
month = {3},
year = {2023},
howpublished = {online},
url = {https://github.com/keenancrane/plain-knit-yarn},
}
TeX
74.3%
C
23.6%
Makefile
1.3%
A simple parametric model of plain-knit yarn curves, with C code and other resources.
TeX
68
15 commits
updated Jun 28, 2023
A simple parametric model of plain-knit yarn curves, with C code and other resources.

This repository provides code implementing closed-form expressions for smooth curves resembling a plain-knit stitch, suitable for appearance modeling and previsualization. A unique feature of this model is that it also describes the twisted yarn fibers running along this stitch, making it suitable for modeling marled yarn. Adjustable parameters control the knit spacing, loop roundness, yarn thickness, and rate of fiber twisting. Tileable displacement maps and code for generating curves are also provided.
Note. The note YarnCurve.pdf provides a more thorough description of the plain-knit curves, including a step-by-step derivation. The LaTeX source files for this note can be found in the note subdirectory.
Implementation. The code subdirectory contains a plain-C (ANSI C90) implementation of the curve functions, as well as routines for writing curves to the Wavefront OBJ mesh file format. This code should be easily portable to most other languages. Several implementations have been developed, in a variety of packages:
| front | back | alpha |
|---|---|---|
![]() | ![]() | ![]() |

A Simple Parametric Model of Plain-Knit Yarns by Keenan Crane is licensed under a Creative Commons Attribution 4.0 International License. Code is released under an MIT License.
@misc{Crane:2023:SPM,
title = {{A Simple Parametric Model of Plain-Knit Yarns}},
author = {Crane, Keenan},
month = {3},
year = {2023},
howpublished = {online},
url = {https://github.com/keenancrane/plain-knit-yarn},
}
TeX
74.3%
C
23.6%
Makefile
1.3%