-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6ace5f
commit 2c5e065
Showing
29 changed files
with
858 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
all: | ||
cc -O3 -ansi -pedantic plain-knit.c -o plain-knit | ||
|
||
clean: | ||
rm -f plain-knit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,248 @@ | ||
#include <stdio.h> | ||
#include <math.h> | ||
|
||
struct Vector3 | ||
{ | ||
double x; | ||
double y; | ||
double z; | ||
}; | ||
|
||
double sqr( double x ) | ||
{ | ||
return x*x; | ||
} | ||
|
||
double norm2( struct Vector3 v ) | ||
{ | ||
return sqr(v.x) + sqr(v.y) + sqr(v.z); | ||
} | ||
|
||
double norm( struct Vector3 v ) | ||
{ | ||
return sqrt( norm2( v )); | ||
} | ||
|
||
struct Vector3 scale( double c, struct Vector3 v ) | ||
{ | ||
struct Vector3 cv; | ||
cv.x = c * v.x; | ||
cv.y = c * v.y; | ||
cv.z = c * v.z; | ||
return cv; | ||
} | ||
|
||
struct Vector3 cross( struct Vector3 u, struct Vector3 v ) | ||
{ | ||
struct Vector3 w; | ||
w.x = u.y*v.z - u.z*v.y; | ||
w.y = u.z*v.x - u.x*v.z; | ||
w.z = u.x*v.y - u.y*v.x; | ||
return w; | ||
} | ||
|
||
struct Vector3 yarnCurve( double t, double a, double h, double d ) | ||
{ | ||
struct Vector3 gamma_t; | ||
|
||
gamma_t.x = t + a*sin(2.*t); | ||
gamma_t.y = h * cos(t); | ||
gamma_t.z = d * cos(2.*t); | ||
|
||
return gamma_t; | ||
} | ||
|
||
void frenetFrame( double t, double a, double h, double d, | ||
struct Vector3* e1, struct Vector3* e2, struct Vector3* e3 ) | ||
{ | ||
double u_t, v_t, x_t, y_t; | ||
|
||
e1->x = 1. + 2.*a*cos(2.*t); | ||
e1->y = -h*sin(t); | ||
e1->z = -2.*d*sin(2.*t); | ||
|
||
u_t = norm2(*e1); | ||
v_t = 2.*h*h*cos(t)*sin(t) + 16.*d*d*cos(2.*t)*sin(2.*t) - | ||
8.*a*(1. + 2.*a*cos(2.*t))*sin(2.*t); | ||
x_t = 1./sqrt(u_t); | ||
y_t = v_t/(2.*pow(u_t,3./2.)); | ||
|
||
e2->x = y_t*(-1. - 2.*a*cos(2.*t)) - x_t*4.*a*sin(2.*t); | ||
e2->y = y_t*h*sin(t) - x_t*h*cos(t); | ||
e2->z = y_t*2.*d*sin(2.*t) - x_t*4.*d*cos(2.*t); | ||
|
||
*e1 = scale( x_t, *e1 ); | ||
*e2 = scale( 1./norm(*e2), *e2 ); | ||
*e3 = cross( *e1, *e2 ); | ||
} | ||
|
||
struct Vector3 fiberCurve( double t, double a, double h, double d, | ||
double r, double omega, double phi ) | ||
{ | ||
struct Vector3 gamma_t; | ||
struct Vector3 eta_t; | ||
struct Vector3 e1, e2, e3; | ||
double theta_t; | ||
|
||
gamma_t = yarnCurve( t, a, h, d ); | ||
frenetFrame( t, a, h, d, &e1, &e2, &e3 ); | ||
theta_t = t*omega - 2.*cos(t) + phi; | ||
|
||
eta_t.x = gamma_t.x + r*( cos(theta_t)*e2.x + sin(theta_t)*e3.x ); | ||
eta_t.y = gamma_t.y + r*( cos(theta_t)*e2.y + sin(theta_t)*e3.y ); | ||
eta_t.z = gamma_t.z + r*( cos(theta_t)*e2.z + sin(theta_t)*e3.z ); | ||
|
||
return eta_t; | ||
} | ||
|
||
void writeYarnCurves( | ||
const char* filename, /* output filename */ | ||
int nRows, /* number of rows in wale direction */ | ||
double rowOffset, /* row spacing in wale direction */ | ||
int nLoops, /* number of loops in course direction */ | ||
int samplesPerLoop, /* sample points for each loop */ | ||
double a, /* loop roundness */ | ||
double h, /* loop height */ | ||
double d ) /* loop depth */ | ||
{ | ||
double t; | ||
int row, loop, sample; | ||
int nPoints; | ||
double dt, y0, t0; | ||
struct Vector3 gamma_t; | ||
FILE* out; | ||
|
||
out = fopen( filename, "w" ); | ||
|
||
nPoints = 0; | ||
dt = (2.*M_PI)/(double)samplesPerLoop; | ||
|
||
/* write vertices */ | ||
for( row = 0; row < nRows; row++ ) | ||
{ | ||
y0 = rowOffset * (double)row; | ||
|
||
for( loop = 0; loop < nLoops; loop++ ) | ||
{ | ||
t0 = 2.*M_PI * loop; | ||
for( sample = 0; sample < samplesPerLoop; sample++ ) | ||
{ | ||
t = t0 + dt*(double)sample; | ||
|
||
gamma_t = yarnCurve( t, a, h, d ); | ||
|
||
fprintf( out, "v %e %e %e\n", | ||
gamma_t.x, | ||
gamma_t.y + y0, | ||
gamma_t.z ); | ||
} | ||
} | ||
} | ||
|
||
/* write polylines */ | ||
for( row = 0; row < nRows; row++ ) | ||
{ | ||
fprintf( out, "l" ); | ||
for( loop = 0; loop < nLoops; loop++ ) | ||
{ | ||
for( sample = 0; sample < samplesPerLoop; sample++ ) | ||
{ | ||
fprintf( out, " %d", nPoints+1 ); | ||
nPoints++; | ||
} | ||
} | ||
fprintf( out, "\n" ); | ||
} | ||
fclose( out ); | ||
} | ||
|
||
void writeFiberCurves( | ||
const char* filename, /* output filename */ | ||
int nRows, /* number of rows in wale direction */ | ||
double rowOffset, /* row spacing in wale direction */ | ||
int nLoops, /* number of loops in course direction */ | ||
int samplesPerLoop, /* sample points for each loop */ | ||
double a, /* loop roundness */ | ||
double h, /* loop height */ | ||
double d, /* loop depth */ | ||
double r, /* yarn radius */ | ||
double omega, /* amount of fiber twist */ | ||
int nFibers ) /* number of fibers around yarn */ | ||
{ | ||
int row, fiber, loop, sample; | ||
int nPoints; | ||
double y0, t0; | ||
double dt, dphi; | ||
struct Vector3 eta_t; | ||
FILE* out; | ||
|
||
out = fopen( filename, "w" ); | ||
|
||
nPoints = 0; | ||
dt = (2.*M_PI)/(double)samplesPerLoop; | ||
dphi = (2.*M_PI)/(double)nFibers; | ||
|
||
/* write vertices */ | ||
for( row = 0; row < nRows; row++ ) | ||
{ | ||
y0 = rowOffset * (double)row; | ||
|
||
for( fiber = 0; fiber < nFibers; fiber++ ) | ||
{ | ||
double phi = dphi * (double)fiber; | ||
|
||
for( loop = 0; loop < nLoops; loop++ ) | ||
{ | ||
t0 = 2.*M_PI * loop; | ||
for( sample = 0; sample < samplesPerLoop; sample++ ) | ||
{ | ||
double t = t0 + dt*(double)sample; | ||
eta_t = fiberCurve( t, a, h, d, r, omega, phi ); | ||
fprintf( out, "v %e %e %e\n", eta_t.x, y0 + eta_t.y, eta_t.z ); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/* write polylines */ | ||
for( row = 0; row < nRows; row++ ) | ||
{ | ||
y0 = rowOffset * (double)row; | ||
|
||
for( fiber = 0; fiber < nFibers; fiber++ ) | ||
{ | ||
fprintf( out, "l" ); | ||
for( loop = 0; loop < nLoops; loop++ ) | ||
{ | ||
for( sample = 0; sample < samplesPerLoop; sample++ ) | ||
{ | ||
fprintf( out, " %d", nPoints+1 ); | ||
nPoints++; | ||
} | ||
} | ||
fprintf( out, "\n" ); | ||
} | ||
} | ||
} | ||
|
||
int main( int argc, char** argv ) | ||
{ | ||
const int nRows = 16; /* number of rows generated */ | ||
const int nLoops = 12; /* number of loops in each row */ | ||
const int samplesPerLoop = 64; /* points sampled per period */ | ||
const int nFibers = 4; /* number of twisted fibers */ | ||
const double a = 3/2.; /* loop roundness */ | ||
const double d = 1.; /* loop depth */ | ||
const double h = 4.; /* loop height */ | ||
const double w = h + 1./2.; /* row spacing */ | ||
const double r = 1./2.; /* yarn radius */ | ||
const double omega = 5.; /* fiber twist */ | ||
const double phi = M_PI/2.; /* fiber offset */ | ||
|
||
writeYarnCurves( "yarn.obj", nRows, w, nLoops, samplesPerLoop, a, h, d ); | ||
writeFiberCurves( "fibers.obj", nRows, w, nLoops, samplesPerLoop, a, h, d, | ||
r, omega, nFibers ); | ||
|
||
return 0; | ||
} | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FILE = YarnCurve | ||
|
||
all: | ||
pdflatex -shell-escape $(FILE) | ||
bibtex $(FILE) | ||
pdflatex -shell-escape $(FILE) | ||
|
||
clean: | ||
rm -f YarnCurve.aux | ||
rm -f YarnCurve.bbl | ||
rm -f YarnCurve.blg | ||
rm -f YarnCurve.log | ||
rm -f YarnCurve.pdf | ||
rm -rf _minted-YarnCurve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
@article{yuksel2012stitch, | ||
title={Stitch meshes for modeling knitted clothing with yarn-level detail}, | ||
author={Yuksel, Cem and Kaldor, Jonathan M and James, Doug L and Marschner, Steve}, | ||
journal={ACM Transactions on Graphics (TOG)}, | ||
volume={31}, | ||
number={4}, | ||
pages={1--12}, | ||
year={2012}, | ||
publisher={ACM New York, NY, USA} | ||
} | ||
|
||
@incollection{kaldor2010efficient, | ||
title={Efficient yarn-based cloth with adaptive contact linearization}, | ||
author={Kaldor, Jonathan M and James, Doug L and Marschner, Steve}, | ||
booktitle={ACM SIGGRAPH 2010 papers}, | ||
pages={1--10}, | ||
year={2010} | ||
} | ||
|
||
@article{wadekar2020geometric, | ||
title={Geometric modeling of knitted fabrics using helicoid scaffolds}, | ||
author={Wadekar, Paras and Goel, Prateek and Amanatides, Chelsea and Dion, Genevieve and Kamien, Randall D and Breen, David E}, | ||
journal={Journal of Engineered Fibers and Fabrics}, | ||
volume={15}, | ||
pages={1558925020913871}, | ||
year={2020}, | ||
publisher={SAGE Publications Sage UK: London, England} | ||
} | ||
|
||
@article{gonzalez1999global, | ||
title={Global curvature, thickness, and the ideal shapes of knots}, | ||
author={Gonzalez, Oscar and Maddocks, John H}, | ||
journal={Proceedings of the National Academy of Sciences}, | ||
volume={96}, | ||
number={9}, | ||
pages={4769--4773}, | ||
year={1999}, | ||
publisher={National Acad Sciences} | ||
} | ||
|
||
@incollection{ashton2005fast, | ||
title={A fast octree-based algorithm for computing ropelength}, | ||
author={Ashton, Ted and Cantarella, Jason}, | ||
booktitle={Physical And Numerical Models In Knot Theory: Including Applications to the Life Sciences}, | ||
pages={323--341}, | ||
year={2005}, | ||
publisher={World Scientific} | ||
} | ||
|
||
@article{Leaf:1955:GPK, | ||
title={The geometry of a plain knitted loop}, | ||
author={Leaf, GAV and Glaskin, A}, | ||
journal={Journal of the Textile Institute Transactions}, | ||
volume={46}, | ||
number={9}, | ||
pages={T587--T605}, | ||
year={1955}, | ||
publisher={Taylor \& Francis} | ||
} | ||
|
||
@article{Munden:1959:GDP, | ||
title={The geometry and dimensional properties of plain-knit fabrics}, | ||
author={Munden, DL}, | ||
journal={Journal of the Textile Institute Transactions}, | ||
volume={50}, | ||
number={7}, | ||
pages={T448--T471}, | ||
year={1959}, | ||
publisher={Taylor \& Francis} | ||
} | ||
|
||
@article{Peirce:1947:GPA, | ||
title={Geometrical principles applicable to the design of functional fabrics}, | ||
author={Peirce, Frederick Thomas}, | ||
journal={Textile Research Journal}, | ||
volume={17}, | ||
number={3}, | ||
pages={123--147}, | ||
year={1947}, | ||
publisher={Sage Publications Sage CA: Thousand Oaks, CA} | ||
} | ||
|
||
@article{Chamberlain:1926:HYF, | ||
title={Hosiery Yarns and Fabrics}, | ||
author={J. Chamberlain}, | ||
year={1926}, | ||
publisher={J. W. Hemming \& Capey, Leicester} | ||
} | ||
|
||
@article{zhao2016fitting, | ||
title={Fitting procedural yarn models for realistic cloth rendering}, | ||
author={Zhao, Shuang and Luan, Fujun and Bala, Kavita}, | ||
journal={ACM Transactions on Graphics (TOG)}, | ||
volume={35}, | ||
number={4}, | ||
pages={1--11}, | ||
year={2016}, | ||
publisher={ACM New York, NY, USA} | ||
} | ||
|
||
@incollection{jakob2010radiative, | ||
title={A radiative transfer framework for rendering materials with anisotropic structure}, | ||
author={Jakob, Wenzel and Arbree, Adam and Moon, Jonathan T and Bala, Kavita and Marschner, Steve}, | ||
booktitle={ACM SIGGRAPH 2010 papers}, | ||
pages={1--13}, | ||
year={2010} | ||
} | ||
|
||
@inproceedings{xu2001photorealistic, | ||
title={Photorealistic rendering of knitwear using the lumislice}, | ||
author={Xu, Ying-Qing and Chen, Yanyun and Lin, Stephen and Zhong, Hua and Wu, Enhua and Guo, Baining and Shum, Heung-Yeung}, | ||
booktitle={Proceedings of the 28th annual conference on Computer graphics and interactive techniques}, | ||
pages={391--398}, | ||
year={2001} | ||
} | ||
|
Oops, something went wrong.