File: fourier.cmd

package info (click to toggle)
evolver 2.70+ds-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 17,148 kB
  • sloc: ansic: 127,395; makefile: 209; sh: 98
file content (62 lines) | stat: -rw-r--r-- 1,945 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
// fourier.cmd
// Evolver command to print Fourier components for closed curve.

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

/* Usage: f_component(order)
   Results returned in global variables
   x_sin_coeff
   y_sin_coeff
   z_sin_coeff
   x_cos_coeff
   y_cos_coeff
   z_cos_coeff
*/

procedure f_component (integer f_order)
// f_order is the order of Fourier components.
{
   local ecount,e_id,first_e,v_id,newe_id;

   x_sin_coeff := 0.0;
   y_sin_coeff := 0.0;
   z_sin_coeff := 0.0;
   x_cos_coeff := 0.0;
   y_cos_coeff := 0.0;
   z_cos_coeff := 0.0;
   ecount := 0; 
   // get starting edge, since can't assume edge[1] exists
   foreach edge do e_id := id;
   first_e := e_id;
   v_id := edge[e_id].vertex[1].id;
   // follow connected edges
   do { 
     local ss,cc,newv_id;
     ss := sin(f_order*ecount*2*pi/edge_count)*2/edge_count;
     x_sin_coeff := x_sin_coeff + vertex[v_id].x*ss; 
     y_sin_coeff := y_sin_coeff + vertex[v_id].y*ss; 
     z_sin_coeff := z_sin_coeff + vertex[v_id].z*ss; 
     cc := cos(f_order*ecount*2*pi/edge_count)*2/edge_count;
     x_cos_coeff := x_cos_coeff + vertex[v_id].x*cc; 
     y_cos_coeff := y_cos_coeff + vertex[v_id].y*cc; 
     z_cos_coeff := z_cos_coeff + vertex[v_id].z*cc; 
     foreach edge[e_id].vertex vv do 
     { if ( vv.id != v_id ) then
       { newv_id := vv.id;
         foreach vv.edge ee do 
            if ee.id != e_id then newe_id := ee.id
        }
     };
     e_id := newe_id; v_id := newv_id;
     ecount := ecount + 1;
   } while ( (e_id != first_e) and (ecount <= edge_count) );
   printf "Order %g           x                 y                 z \n",f_order;
   printf "sin: %20.15f %20.15f %20.15f\n",x_sin_coeff,y_sin_coeff,z_sin_coeff;
   printf "cos: %20.15f %20.15f %20.15f\n",x_cos_coeff,y_cos_coeff,z_cos_coeff;
}


// End fourier.cmd

// Usage: f_component(order)