File: RCThreads.sl

package info (click to toggle)
lg-issue17 3-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 2,480 kB
  • ctags: 182
  • sloc: makefile: 30; sh: 3
file content (27 lines) | stat: -rw-r--r-- 601 bytes parent folder | download | duplicates (5)
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

/*
 * threads(): wrap threads around a cylinder 
 */
displacement 
RCThreads ( 
   float   Km   =  .1,
      frequency = 5.0,
      phase     =  .0,
      offset    =  .0,
      dampzone  =  .05 )
{
   float magnitude;
 
   /* Calculate the undamped displacement */
   magnitude = (sin( PI*2*(t*frequency + s + phase))+offset) * Km;

   /* Damp the displacement to 0 at each end */
   if( t > (1-dampzone)) 
      magnitude *= (1.0-t) / dampzone;
   else if( t < dampzone )
      magnitude *= t / dampzone;

   /* Do the displacement */
   P += normalize(N) * magnitude;
   N = calculatenormal(P);
}