1 |
{ |
2 |
Uniform Rational Patch |
3 |
|
4 |
02Mar90 |
5 |
|
6 |
Define Px(i,j), Py(i,j), Pz(i,j) and W(i,j), nrows, ncols |
7 |
} |
8 |
{ default basis functions } |
9 |
br(a,b,c,d,s) = b3(a,b,c,d,s); |
10 |
bc(a,b,c,d,t) = b3(a,b,c,d,t); |
11 |
b3(a,b,c,d,p) = bezier(a,b,c,d,p); |
12 |
{ default patch interpolation } |
13 |
rint = interpolate; |
14 |
cint = interpolate; |
15 |
interpolate = 1; |
16 |
|
17 |
x(s,t) = patch(s,t,Px); |
18 |
y(s,t) = patch(s,t,Py); |
19 |
z(s,t) = patch(s,t,Pz); |
20 |
|
21 |
patch(s,t,p) = bc(P2(s,c0(t)+1,p), P2(s,c0(t)+2,p), |
22 |
P2(s,c0(t)+3,p), P2(s,c0(t)+4,p), cf(t)) / |
23 |
bc(W2(s,c0(t)+1), W2(s,c0(t)+2), |
24 |
W2(s,c0(t)+3), W2(s,c0(t)+4), cf(t)) ; |
25 |
|
26 |
P2(s,j,p) = br(W(1+r0(s),j)*p(1+r0(s),j), W(2+r0(s),j)*p(2+r0(s),j), |
27 |
W(3+r0(s),j)*p(3+r0(s),j), W(4+r0(s),j)*p(4+r0(s),j), rf(s)) ; |
28 |
|
29 |
W2(s,j) = br(W(1+r0(s),j), W(2+r0(s),j), W(3+r0(s),j), W(4+r0(s),j), rf(s)) ; |
30 |
|
31 |
r0(s) = rmult*floor(clamp(s)*npr); |
32 |
rf(s) = s*npr - floor(clamp(s)*npr); |
33 |
c0(t) = cmult*floor(clamp(t)*npc); |
34 |
cf(t) = t*npc - floor(clamp(t)*npc); |
35 |
|
36 |
rmult = if(rint, 4, 1); |
37 |
cmult = if(cint, 4, 1); |
38 |
npr = if(rint, nrows/4, nrows-3); |
39 |
npc = if(cint, ncols/4, ncols-3); |
40 |
|
41 |
clamp(p) = if(p, if(1-p, p, .9999999), .0000001); |