overview | basic concepts | gops | gprims | animation | rendering | math | index

al math


vectors | matrices | splines | other math tools

Other Math Tools

(atan2 y x)

tan-1(y/x) in range [-PI,PI].

(clamp x a b)

Clamps x (any AL math type except for mat3 or mat4) to the range [a, b] of the same type.

(degrees x)
(radians x)

Converts x (a real) from radians to degrees and vice-versa respectively.

(hsv->rgb vec3)
(rgb->hsv vec3)

Convert color specified as hue-saturation-value (each in the range [0,1]) to rgb and vice-versa.

(lerp a b x)

Linear interpolation between a and b (both of any AL math type) by x (a real) in [0,1].

(log10 x)

Base 10 logarithm, log10(x), x > 0.

(mod x y)

Floating point remainder of x/y. Unlike fmod() from the C math library, if x is negative, mod computes the remainder x/y + x. I.e., it is always in the range [0,1] and does not reflect about x-axis as fmod() does. This matches the definition of mod() in the RenderMan Shading Language.

(noise x)
(noise x y)
(noise x y z)
(noise vec3)

Pseudo-random, noise functions using 1D, 2D or 3D seeds respectively. Each returns a value in the range [-1,1].

PI

Returns the constant for "pi."

(rand)

Returns result of Scheme random but normalized to [0,1]. (Use srandom for seeding.)

(slerp a b x)

Smooth (hermite) interpolation between a and b (both of any AL math type) by x (a real) in [0,1].

(smoothstep min max val)

Returns 0 if val < min. Returns 1 if val > max. And otherwise returns a smooth (hermite) interpolation between 0 and 1.

(sqr x)

Returns x * x.

(step min val)

Returns 0 if val < min. Returns 1 if val > min.


AL: The Animation Language is Copyright © 1995,1996, Stephen F. May

Last updated: 12/13/95 / Steve May ( smay@cgrg.ohio-state.edu )
Any comments or suggestions appreciated.