home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 564a.lha / igensurf_v1.0 / examples / util.cal < prev    next >
Text File  |  1991-09-27  |  1KB  |  37 lines

  1. {
  2.     Some useful functions, which can be included in other functions.
  3. }
  4.  
  5. noise3d(i,x,y,z) = select(i, noise3a(x,y,z), noise3b(x,y,z), noise3c(x,y,z));
  6.  
  7. and(a, b)        : if (a, b, a );
  8. or(a, b)        : if (a, a, b );
  9. not(a)            : if (a, 1, -1 );
  10. abs(x)            : if (x, x, -x );
  11. sgn(x)            : if (x, 1, if(-x, -1, 0) );
  12. sq(x)            : x*x;
  13. max(a, b)        : if (a - b, a, b );
  14. min(a, b)        : if (a - b, b, a );
  15. bound(a, x, b)        : max (a, min(x, b));
  16. inside(a, x, b)    : and (x - a, b - x);
  17. frac(x)        : x - floor(x);
  18. mod(n, d)        : n - floor(n / d) * d;
  19. tri(n, d)        : abs ( d - mod(n - d, 2 * d) );
  20. linterp(t, p0, p1) : (1 - t) * p0 + t * p1;
  21.  
  22. turbulence(x,y,z,s) = if( s-1.01, 0, abs(noise3(x/s,y/s,z/s)*s) +
  23.             turbulence(x,y,z,2*s) );
  24.  
  25. turbulencea(x,y,z,s) = if( s-1.01, 0,
  26.             sgn(noise3(x/s,y/s,z/s))*noise3a(x/s,y/s,z/s) +
  27.             turbulencea(x,y,z,2*s) );
  28. turbulenceb(x,y,z,s) = if( s-1.01, 0,
  29.             sgn(noise3(x/s,y/s,z/s))*noise3b(x/s,y/s,z/s) +
  30.             turbulenceb(x,y,z,2*s) );
  31. turbulencec(x,y,z,s) = if( s-1.01, 0,
  32.             sgn(noise3(x/s,y/s,z/s))*noise3c(x/s,y/s,z/s) +
  33.             turbulencec(x,y,z,2*s) );
  34.  
  35. DEGREE     : PI/180;
  36. FTINY     : 1e-7;
  37.