Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /branches/lamont/test/implicit-surface/unit-circle.diderot
ViewVC logotype

Annotation of /branches/lamont/test/implicit-surface/unit-circle.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2131 - (view) (download)

1 : lamonts 2131 // unit-circle
2 :     //
3 :     // Demo of distributing particles on the unit circle
4 :     //
5 :     int numOfParticles = 1000;
6 :    
7 :    
8 :     strand Particle (int i) {
9 :     output vec2 pos = [lerp(0.0, 1.0, -0.5, real(ui), real(gridSize)-0.5),
10 :     lerp(0.0, 1.0, -0.5, real(vi), real(gridSize)-0.5)];
11 :    
12 :     real isoval = 1;
13 :     int steps = 0;
14 :    
15 :     update {
16 :     // We bail if we're no longer inside or taken too many steps.
17 :     /* if (!inside(pos, F) || steps > stepsMax) {
18 :     die;
19 :     } */
20 :    
21 :     vec2 grad = ∇F(pos);
22 :     if (|grad| == 0.0) { // can't compute step if |∇F|, so have to bail
23 :     die;
24 :     }
25 :     vec2 norm = normalize(grad);
26 :     vec2 delta = -((F(pos) - isoval)/|grad|)*norm; // Newton-Raphson step
27 :     if (|delta| < epsilon) { // we've converged if step is small enough
28 :     stabilize;
29 :     }
30 :     pos += stepScale * delta;
31 :     steps += 1;
32 :     }
33 :     }
34 :     initially {Particle(i) | i in 0 .. numOfParticles-1 };
35 :    

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0