| 1 |
% telheiro.mp |
| 2 |
% L. Nobre G. |
| 3 |
% 2013 |
| 4 |
|
| 5 |
input featpost3Dplus2D; |
| 6 |
|
| 7 |
prologues := 1; |
| 8 |
|
| 9 |
f := (6,1,3); |
| 10 |
|
| 11 |
vardef drawpat( expr Ind )( text Nam ) = |
| 12 |
draw rp(Nam[Ind]) for i=Ind-1 downto 1: --rp(Nam[i]) endfor |
| 13 |
for i=1 upto Ind: --rp((-X(Nam[i]),Y(Nam[i]),Z(Nam[i]))) endfor |
| 14 |
enddef; |
| 15 |
|
| 16 |
vardef xz( expr C )= (X(C),Z(C)) enddef; |
| 17 |
|
| 18 |
vardef xy( expr C )= (X(C),Y(C)) enddef; |
| 19 |
|
| 20 |
vardef recter( expr Pic ) = 0.5*((llcorner Pic)+(urcorner Pic)) enddef; |
| 21 |
|
| 22 |
beginfig(1); |
| 23 |
numeric semimajor, semiminor, vertez, vertey, centery; |
| 24 |
color verte, cente, maj, min, ver[], dia[], hor[], el; |
| 25 |
numeric i, cou, ste, axe, maxang; |
| 26 |
semimajor = 1.4; |
| 27 |
semiminor = 1; |
| 28 |
vertez = 1.1; |
| 29 |
vertey = 0.25; |
| 30 |
centery = 0.35; |
| 31 |
ste = 2; |
| 32 |
axe =1.5; |
| 33 |
verte = (0,-vertey,vertez); |
| 34 |
cente = (0,centery,0); |
| 35 |
maj = (0,semimajor,0); |
| 36 |
min = (semiminor,0,0); |
| 37 |
color cen; |
| 38 |
cen = (0,vertey+centery+semimajor,-vertez); |
| 39 |
draw rp(verte)--rp(verte+cen); |
| 40 |
cou = 1; |
| 41 |
i = 1; |
| 42 |
forever: |
| 43 |
el := cente+planarrotation( maj, min, i ); |
| 44 |
ver[cou] = whatever[verte,el]; |
| 45 |
Y(ver[cou]) = 0; |
| 46 |
dia[cou] = whatever[verte,el]; |
| 47 |
Z(dia[cou]) = Y(dia[cou]); |
| 48 |
hor[cou] = whatever[verte,el]; |
| 49 |
Z(hor[cou]) = 0; |
| 50 |
exitif (Z(ver[cou])>=vertez) or (Z(ver[cou])<0) or (Y(hor[cou])<0); |
| 51 |
cou := cou+1; |
| 52 |
i := i+ste; |
| 53 |
endfor; |
| 54 |
maxang = i; |
| 55 |
cartaxes(axe,axe,axe); |
| 56 |
draw rp(black)--rp((-axe,0,0)); |
| 57 |
drawpat(cou)(ver); |
| 58 |
drawpat(cou)(hor); |
| 59 |
drawoptions( withcolor blue ); |
| 60 |
drawpat(cou)(dia); |
| 61 |
endfig; |
| 62 |
|
| 63 |
beginfig(2); |
| 64 |
numeric u; |
| 65 |
u = 5cm; |
| 66 |
draw (xz(ver[cou]) for i=cou-1 downto 1: --xz(ver[i]) endfor |
| 67 |
for i=1 upto cou: --(-X(ver[i]),Z(ver[i])) endfor |
| 68 |
for i=cou downto 1: --(-X(hor[i]),Y(hor[i])) endfor |
| 69 |
for i=1 upto cou: --xy(hor[i]) endfor --cycle) scaled u; |
| 70 |
picture surface; |
| 71 |
surface = currentpicture; |
| 72 |
currentpicture := nullpicture; |
| 73 |
numeric ang, v, d, h; |
| 74 |
pair ve[], di[], ho[], vec, possurf, posbase; |
| 75 |
possurf = recter( surface ); |
| 76 |
ang = 0; |
| 77 |
for i=1 upto cou: |
| 78 |
ang:= ang+getangle( cen, hor[i]-verte ); |
| 79 |
cen:= hor[i]-verte; |
| 80 |
v := conorm(verte-ver[i]); |
| 81 |
d := conorm(verte-dia[i]); |
| 82 |
h := conorm(cen); |
| 83 |
vec := dir(90-ang); |
| 84 |
ve[i] = u*v*vec; |
| 85 |
di[i] = u*d*vec; |
| 86 |
ho[i] = u*h*vec; |
| 87 |
endfor; |
| 88 |
draw di1 for i=2 upto cou: --di[i] endfor withcolor blue; |
| 89 |
draw for i=cou downto 1: ve[i]-- endfor for i=1 upto cou: ho[i]-- endfor cycle; |
| 90 |
draw currentpicture xscaled -1; |
| 91 |
posbase = recter( currentpicture ); |
| 92 |
draw surface shifted (posbase-possurf); |
| 93 |
produce_auto_scale; |
| 94 |
endfig; |
| 95 |
|
| 96 |
end. |