home *** CD-ROM | disk | FTP | other *** search
- {
- Some useful functions, which can be included in other functions.
- }
-
- noise3d(i,x,y,z) = select(i, noise3a(x,y,z), noise3b(x,y,z), noise3c(x,y,z));
-
- and(a, b) : if (a, b, a );
- or(a, b) : if (a, a, b );
- not(a) : if (a, 1, -1 );
- abs(x) : if (x, x, -x );
- sgn(x) : if (x, 1, if(-x, -1, 0) );
- sq(x) : x*x;
- max(a, b) : if (a - b, a, b );
- min(a, b) : if (a - b, b, a );
- bound(a, x, b) : max (a, min(x, b));
- inside(a, x, b) : and (x - a, b - x);
- frac(x) : x - floor(x);
- mod(n, d) : n - floor(n / d) * d;
- tri(n, d) : abs ( d - mod(n - d, 2 * d) );
- linterp(t, p0, p1) : (1 - t) * p0 + t * p1;
-
- turbulence(x,y,z,s) = if( s-1.01, 0, abs(noise3(x/s,y/s,z/s)*s) +
- turbulence(x,y,z,2*s) );
-
- turbulencea(x,y,z,s) = if( s-1.01, 0,
- sgn(noise3(x/s,y/s,z/s))*noise3a(x/s,y/s,z/s) +
- turbulencea(x,y,z,2*s) );
- turbulenceb(x,y,z,s) = if( s-1.01, 0,
- sgn(noise3(x/s,y/s,z/s))*noise3b(x/s,y/s,z/s) +
- turbulenceb(x,y,z,2*s) );
- turbulencec(x,y,z,s) = if( s-1.01, 0,
- sgn(noise3(x/s,y/s,z/s))*noise3c(x/s,y/s,z/s) +
- turbulencec(x,y,z,2*s) );
-
- DEGREE : PI/180;
- FTINY : 1e-7;
-