File: bonnet_movie.cmd

package info (click to toggle)
evolver 2.70+ds-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 17,148 kB
  • sloc: ansic: 127,395; makefile: 209; sh: 98
file content (208 lines) | stat: -rw-r--r-- 6,871 bytes parent folder | download | duplicates (2)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// bonnet_movie.cmd

// Makes in-memory movie of Bonnet rotation of minimal surface,
// one frame per degree for 360 degrees.

// Programmer: Ken Brakke, brakke@susqu.edu, http://www.susqu.edu/brakke

// Usage: Evolve initial minimal surface, remove all level-set constraints
//        and boundaries, get nice view in graphics window.
//        Run "make_movie" to calculate Bonnet rotations.
//        Run "show_movie" to see screen display of Bonnet rotation.
//        Run "movie" to see endlessly repeating Bonnet rotation.
//        Run "postscript_movie" to create sequence of PostScript files.

read "adjoint.cmd"

frame_delay := 0.03  // seconds between frames

// Store coordinates for complete Bonnet rotation
define vertex attribute bonnet real[360][3]
movie_made_flag := 0;
make_movie := {
  local midx,midy,midz;

  // Check assumptions
if torus then
  { errprintf "Cannot run 'make_movie' command in torus mode. Do 'detorus' first.\n";
    abort;
  };

  if symmetry_group then
  { errprintf "Cannot run 'make_movie' command in symmetry group mode. Do 'detorus' first.\n";
    abort;
  };

  if space_dimension != 3 then
  { errprintf "The 'make_movie' command must be run in three-dimensional space.\n";
    abort;
  };

  if surface_dimension == 1 then
  { errprintf "The 'make_movie' command is not meant for the string model.\n";
    abort;
  };

  if simplex_representation then
  { errprintf "The 'make_movie' command is not meant for the simplex model.\n";
    abort;
  };

  if lagrange_order >= 2 then
  { errprintf "The 'make_movie' command is meant for the linear model, not quadratic or Lagrange.\n";
    abort;
  };


  // Center of original surface.
  midx := avg(vertex,x);
  midy := avg(vertex,y);
  midz := avg(vertex,z);

  quiet on;
  for ( bangle := 0 ; bangle < 359.5 ; bangle += 1 )
  { local bmidx,bmidy,bmidz; // Center of rotated surface
    adjoint;
    bmidx := avg(vertex,x);
    bmidy := avg(vertex,y);
    bmidz := avg(vertex,z);
   
    foreach vertex vv do
    { vv.bonnet[bangle+1][1] := vv.x-bmidx+midx;
      vv.bonnet[bangle+1][2] := vv.y-bmidy+midx;
      vv.bonnet[bangle+1][3] := vv.z-bmidz+midx;
    };
    flip;
  };
  movie_made_flag := 1;
  quiet off;
}

procedure set_bonnet(integer angle)
{ 
  if !movie_made_flag then
  { errprintf "Error.  Run \"make_movie\" before set_bonnet.\n";
    abort;
  };

   foreach vertex vv do
     vv.__x := vv.bonnet[angle+1];

   recalc;
}

show_movie := {
  local next_time;
  next_time := clock;
  for ( angle := 0; angle < 359.5 ; angle += 1 )
  { while clock < next_time do {};
    next_time += frame_delay;
    set_bonnet(angle);
  } 
}

// write postscript file for each frame
postscript_movie := {
  local angle;
  full_bounding_box on;
  for ( angle := 0; angle < 359.5 ; angle += 1 )
  {
    set_bonnet(angle);
    postscript sprintf"%s.%03d",datafilename,angle;
  } 
}
  
// continuous loop
movie := { for (;;) show_movie; }


// Write split-vertex "nonconforming" adjoint datafile.  To be done after conconj;
// uses ad_enewx from "adjoint" to compute vertices.
define facet attribute split_bonnet real[3][360][3]
write_split_movie := {
  printf "// split-vertex discrete adjoint of %s, rotation angle %f.\n",
    datafilename,bangle;
  printf "\ndefine vertex attribute bonnet real[360][3]\n\n";
  printf "\nvertices\n";
  foreach facet ff do
  { printf "%d   %15.10f %15.10f %15.10f bonnet ",3*ff.id-2,
      ff.edge[1].ad_enewx[1]+ff.edge[2].ad_enewx[1]-ff.edge[3].ad_enewx[1],
      ff.edge[1].ad_enewx[2]+ff.edge[2].ad_enewx[2]-ff.edge[3].ad_enewx[2],
      ff.edge[1].ad_enewx[3]+ff.edge[2].ad_enewx[3]-ff.edge[3].ad_enewx[3];
    print ff.split_bonnet[1];
    printf "\n";
    printf "%d   %15.10f %15.10f %15.10f bonnet ",3*ff.id-1,
     -ff.edge[1].ad_enewx[1]+ff.edge[2].ad_enewx[1]+ff.edge[3].ad_enewx[1],
     -ff.edge[1].ad_enewx[2]+ff.edge[2].ad_enewx[2]+ff.edge[3].ad_enewx[2],
     -ff.edge[1].ad_enewx[3]+ff.edge[2].ad_enewx[3]+ff.edge[3].ad_enewx[3];
    print ff.split_bonnet[2];
    printf "\n";
    printf "%d   %15.10f %15.10f %15.10f bonnet ",3*ff.id,
      ff.edge[1].ad_enewx[1]-ff.edge[2].ad_enewx[1]+ff.edge[3].ad_enewx[1],
      ff.edge[1].ad_enewx[2]-ff.edge[2].ad_enewx[2]+ff.edge[3].ad_enewx[2],
      ff.edge[1].ad_enewx[3]-ff.edge[2].ad_enewx[3]+ff.edge[3].ad_enewx[3];
    print ff.split_bonnet[3];
    printf "\n";
  };
  printf "\nedges\n";
  foreach facet ff do
  { printf "%d   %d %d\n",3*ff.id-2,3*ff.id-2,3*ff.id-1;
    printf "%d   %d %d\n",3*ff.id-1,3*ff.id-1,3*ff.id;
    printf "%d   %d %d\n",3*ff.id,3*ff.id,3*ff.id-2;
  };
  printf "\nfaces\n";
  foreach facet ff do 
    printf "%d    %d %d %d\n",ff.id,3*ff.id-2,3*ff.id-1,3*ff.id;
  printf "\nread\n";
  printf "read \"bonnet_movie.cmd\"\n";
}

make_split_movie := {
  local midx,midy,midz;
  midx := avg(edge,ad_enewx[1]);
  midy := avg(edge,ad_enewx[2]);
  midz := avg(edge,ad_enewx[3]);
  quiet on;
  for ( bangle := 0 ; bangle < 359.5 ; bangle += 1 )
  { adjoint;
   
    foreach edge ee  do
    { ee.ad_enewx[1] -= midx;
      ee.ad_enewx[2] -= midy;
      ee.ad_enewx[3] -= midz;
    };
    foreach facet ff do
    { 
      ff.split_bonnet[1][bangle+1][1] :=
        ff.edge[1].ad_enewx[1]+ff.edge[2].ad_enewx[1]-ff.edge[3].ad_enewx[1];
      ff.split_bonnet[1][bangle+1][2] :=
        ff.edge[1].ad_enewx[2]+ff.edge[2].ad_enewx[2]-ff.edge[3].ad_enewx[2];
      ff.split_bonnet[1][bangle+1][3] :=
        ff.edge[1].ad_enewx[3]+ff.edge[2].ad_enewx[3]-ff.edge[3].ad_enewx[3];
      ff.split_bonnet[2][bangle+1][1] :=
       -ff.edge[1].ad_enewx[1]+ff.edge[2].ad_enewx[1]+ff.edge[3].ad_enewx[1];
      ff.split_bonnet[2][bangle+1][2] :=
       -ff.edge[1].ad_enewx[2]+ff.edge[2].ad_enewx[2]+ff.edge[3].ad_enewx[2];
      ff.split_bonnet[2][bangle+1][3] :=
       -ff.edge[1].ad_enewx[3]+ff.edge[2].ad_enewx[3]+ff.edge[3].ad_enewx[3];
      ff.split_bonnet[3][bangle+1][1] :=
        ff.edge[1].ad_enewx[1]-ff.edge[2].ad_enewx[1]+ff.edge[3].ad_enewx[1];
      ff.split_bonnet[3][bangle+1][2] :=
        ff.edge[1].ad_enewx[2]-ff.edge[2].ad_enewx[2]+ff.edge[3].ad_enewx[2];
      ff.split_bonnet[3][bangle+1][3] :=
        ff.edge[1].ad_enewx[3]-ff.edge[2].ad_enewx[3]+ff.edge[3].ad_enewx[3];
    };
    flip;
  };
  quiet off;
}


// End bonnet_movie.cmd

// Usage: Evolve initial minimal surface, remove all level-set constraints
//        and boundaries, get nice view in graphics window.
//        Run "make_movie" to calculate Bonnet rotations.
//        Run "show_movie" to see screen display of Bonnet rotation.
//        Run "movie" to see endlessly repeating Bonnet rotation.
//        Run "postscript_movie" to create sequence of PostScript files.