summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/featpost/example/gnupost3Dlogo.mp
blob: aca279ef0e90f27b7652376f86ecd6c488553d8e (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
% gnupost3Dlogo.mp
% 2006
% L. Nobre G.

input featpost3Dplus2D;

% bash: export TEX=latex
% tcsh: setenv TEX latex

prologues := 1;

def converterfunc( expr Pair ) =
  begingroup
    save factconv, angstart, ystart, cx, cy, raux, aaux, xaux, yaux, zaux;
    numeric factconv, angstart, ystart, cx, cy, raux, aaux, xaux, yaux, zaux;
    save overtang, factang;
    numeric overtang, factang;
    ystart = 2;
    factconv = 0.0046;
    angstart = 70;
    overtang = 55;
    factang = 12;
    cx = factconv*(ypart Pair);
    cy = ystart+factconv*(xpart Pair);
    raux = cy*sind(overtang);
    aaux = angstart-factang*factconv*(xpart Pair)-(180/3.14159)*cx/raux;
    zaux = cy*cosd(overtang);
    yaux = raux*sind(aaux);
    xaux = raux*cosd(aaux);
    ( rp( ( xaux, yaux, zaux ) ) )
  endgroup
enddef;

beginfig(1);
  numeric u, nstripes, aspecratio, minskip, maxskip, shiftlim, shiftmin;
  numeric nbreaks, i, j, ymax, shiftx, lefh, righ, actualx, newx;
  numeric prevlefh, prevrigh, xmax, auxan, auxr, cdiam;
  path lefp[], rigp[], strp[], backpath;
  pair shif, reflef, refrig, auxa, auxb;
  boolean exitcondition;
  u = 1cm;
  nstripes = 7;
  aspecratio = 1.7;
  minskip = 0.5u; % must not be too small
  maxskip = 4u;
  shiftlim = 0.7u;
  shiftmin = 0.25u;
  cdiam = 0.65u;
  xmax = (2*nstripes-1)*u;
  ymax = aspecratio*xmax;
  backpath = origin--(0,xmax)--(ymax,xmax)--(ymax,0)--cycle;
  prevlefh = ymax;
  prevrigh = ymax;
  actualx = u;
  for i=1 upto nstripes:
    lefp[i] = ((2*i-1)*u,ymax);
    rigp[i] = ((2*i-1)*u,ymax)--(2*i*u,ymax);
  endfor;
  exitcondition = false;
  forever:
    auxr := uniformdeviate(2)-1;
    if auxr > 0:
      newx := actualx + shiftmin + (shiftlim-shiftmin)*auxr;
    else:
      newx := actualx - shiftmin + (shiftlim-shiftmin)*auxr;
    fi;
    lefh := prevlefh - minskip - uniformdeviate(maxskip-minskip);
    righ := prevrigh - minskip - uniformdeviate(maxskip-minskip);
    if lefh < minskip:
      lefh := minskip;
      exitcondition := true;
    fi;
    if righ < minskip:
      righ := minskip;
      exitcondition := true;
    fi;    
    reflef := (newx,lefh);
    refrig := (newx+xmax,righ);
    auxan := angle(refrig-reflef);
    shif := (newx-actualx)*(1,sind(auxan)/cosd(auxan));
    for i=1 upto nstripes:
      auxa := point (length lefp[i]) of lefp[i];
      auxb := point (length rigp[i]) of rigp[i];
      pair poil, poir;
      poil = auxa+whatever*down;
      poil = whatever[reflef,refrig];
      poir = auxb+whatever*down;
      poir = whatever[reflef,refrig];
      lefp[i] := lefp[i]--poil--(poil+shif);
      rigp[i] := rigp[i]--poir--(poir+shif);
    endfor;
    actualx := newx;
    prevlefh := lefh;
    prevrigh := righ;
    exitif exitcondition;
  endfor;
  for i=1 upto nstripes:
    auxa := point (length lefp[i]) of lefp[i];
    auxb := point (length rigp[i]) of rigp[i];
    pair poil, poir;
    poil = auxa+whatever*down;
    poil = whatever[origin,right];
    poir = auxb+whatever*down;
    poir = whatever[origin,right];
    lefp[i] := lefp[i]--poil--poir;
    rigp[i] := rigp[i]--poir;
    strp[i] = buildcycle( lefp[i], reverse rigp[i] );
  endfor;
  fill backpath withcolor (0.55blue);
  for i=nstripes+1 upto nstripes+50:
    strp[i] = fullcircle scaled cdiam shifted
              (u+uniformdeviate(ymax-2u),u+uniformdeviate(xmax-2u));
    fill strp[i];
  endfor;		   
  ShiftV := (0.3*ymax,0);
  viewcentr := (0,0.7,1);
  f := (3,0,0);
  Spread := 70;
  for i=1 upto nstripes:
    fill closedpathinspace( strp[i], 8, converterfunc ) withcolor red;
  endfor;
  clip currentpicture to backpath;
endfig;

end.