1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import three;
/* Reference:
@article{Qin97,
title={{Representing quadric surfaces using NURBS surfaces}},
author={Qin, K.},
journal={Journal of Computer Science and Technology},
volume={12},
number={3},
pages={210--216},
year={1997},
publisher={Springer}
}
*/
size(10cm);
currentprojection=perspective(5,4,2,autoadjust=false);
// udegree=2, vdegree=3, nu=3, nv=4;
real[] W={2/3,1/3,1};
real[] w={1,1/3,1/3,1};
// 10 distinct control points
triple[][] P={{(0,0,1),(-2,-2,1),(-2,-2,-1),(0,0,-1)},
{(0,0,1),(2,-2,1),(2,-2,-1),(0,0,-1)},
{(0,0,1),(2,2,1),(2,2,-1),(0,0,-1)},
{(0,0,1),(-2,2,1),(-2,2,-1),(0,0,-1)}};
P.cyclic=true;
real[][] weights=new real[3][4];
for(int i=0; i < 3; ++i)
for(int j=0; j < 4; ++j)
weights[i][j]=W[i]*w[j];
real[] uknot={0,0,1/3,1/2,1,1};
real[] vknot={0,0,0,0,1,1,1,1};
int N=1;
for(int k=0; k < N; ++k)
for(int i=0; i < 4; ++i)
draw(shift(k*Z)*P[i:i+3],uknot,vknot,weights,blue);
// draw(unitsphere,red+opacity(0.1));
|