
**THIS IS SOMEWHAT OBSOLETE*** - I defined many new functions since
this was written. Read the files in scheme-core.

;------------functions defined in algebra.c

    (dvector double ...)
--- (dvector 1. 2. 3.) -> #i(1. 2. 3.)

Create a vector of doubles. All vector and matrix operations assume
the arguments to be contiguous, with indices starting from 0, unless
otherwise stated.

   (v+ dvector ...)
   (v- dvector ...)
---(v+ #i(2. 0.) #i(5. 7.)) -> #i(7. 7.)

Vector addition/substraction

   (vdot dvector dvector)
---(vdot #i(1. 2. 3.) #i(5. 7. 8.)) -> 43.0

Dot product of vectors.

   (vnorm dvector)
---(vnorm #i(3. 4. 0.)) -> 5.

Norm (length) of the vector.

   (vdistance dvector ...)

The maximal distance between the vectors (this function works in the time
proportional to the square of the number of input vectors).

   (vcross dvector dvector)

Vector cross product.

   (vscale double dvector)

Multiply vector with scalar.

   (dmatrix m n double ...)
---(dmatrix 3 3   1. 0. 0.    0. 1. 0.    0. 0. 1.)

Create an m x n matrix.

   (m+ matrix ...)
   (m- matrix ...)

Add/substract matrices.

   (m* matrix/vector ...)

Matrix multiplication. Here, vector is understood as column matrix. Also,
vectors with one component less than the transformation matrix are extended
with 1 and is tranformed like homogenuous vector (division included).

   (mtranspose matrix)

Transpose the matrix. This is not yet implemented for homogenous case.

   (mscalar double matrix)

Multiply matrix with double.

   (color? data)

Returns #t if data is a color.

   (rgb red green blue)
   (hsv red greed blue)
---(rgb 0.2 0.5 0.1) -> #<RGB 0.2 0.5 0.1>

Create rgb/hsv color. HSV is still untested.

   (c+ color color)
   (cfilter color color)
   (cdot color color)
---(c+ (rgb 1. 2. 3.) (rgb 1. 2. 3.)) -> #<RGB 2. 4. 6.>
---(cfilter (rgb 1. 2. 3.) (rgb 1. 2. 3.)) -> #<RGB 1. 4. 9.>
---(cdot (rgb 1. 2. 3.) (rgb 1. 2. 3.)) -> 14.0

Return sum/componentwise product/dot product.

   (cdistance color ...)
or (cdistance array (x.y) (x.y) ...)

Find maximal distance between the listed colors (or entries in the color array).

   (cscale color double)

Multiply color with scalar.

   (rgb-pixel! array color index1 ... indexN)

Put the color to the array at positions index1...indexN 0 to index1...indexN 2.
Array can be uniform array of either strings or doubles - for strings,
color components will be truncated from range 0.0-1.0 to 0-255.

   (dvector-string vector length)

Return a string obtained by truncating components of the vector from 0-1
to 0-255.

   (convolve array filter x y output . divide)

Array is 3-dimensional uniform array of doubles; filter is 2d array of
doubles. The last index of the array is interpreted as color, and
output is a vector sized as that last index. Convolve will calculate
convolution of array with filter at (x,y), that is, it will sum the
products of array elements with filter elements, for each color
component. Filter doesn't have to be contained in the array, and x,y
don't have to be positive. Divide, if mentioned, will cause the
elements of output to be divided by total weight taken into account
(can be 0 if filter is totally outside array).

   (square-iterate (cons colors-array bool-array) function limit)

Recursive subdivision of a square. Function returns a color that is
stored into colors array. Bool-array prevents recalculation. Limit
is the maximal color distance (to clip the subdivision).


-------------stuff from render.c

   (get-material-option material option-name)

Materials are either just lambdas, or lists whose first element is
lamda while others are tags or pairs of tag-value. get-material-option
will return #t if the option is mentioned, and will retreive its value
if it is within pair.

   (set-material-option material option-name value)

Modify material by changing its option.

   (scene? data)

#t if data is a scene.

   (make-scene objectlist)
---(make-scene (list (sphere #i(0. 0. 0.) 1. (plastic red))))

Create a scene from a list of objects. If any of the objects is forcibly
changed, the scene structure is invalidated and has to be recreated.

   (ray? data)

#t if data is a ray.

   (spawn-eye-ray scene origin)

Spawn a root ray for tracing this scene. Result of this call can be
used to spawn more rays with evaler. Spawning another eye ray makes
all the children of the previous one invalid because of scrambled CSGs.

   (ray-origin ray)
   (ray-direction ray)
   (ray-normal ray)
   (ray-length ray)
   (ray-section ray)
   (ray-positon ray)
   (ray-texture ray)
   (ray-object ray)
   (ray-scene ray)
   (ray-flags ray)
   (ray-weight ray)
   (ray-csg ray)
   (ray-parent ray)

Return various fields of the ray. Ray-position is modified section
(for texture evaluation), while ray-texture is modified normal.

   (ray-displace! ray vector)
   (ray-settext! ray vector)

Set the ray's position and texture normal. This is useful for higher-level
texture calls.

   (get-ray-radiance parent direction weight flags)

Spawn a new ray from parent, and return the color coming its way.
weight is important for stopping the recursion, and flags are
detailing the purpose of the ray (see render.h).

   (check-call data ray)

If data is a lambda, call it with ray, otherwise simply return it. This
is fairly simple function, but should be used when possible, to add
flexibility.

   (set-ambient! color)

Set the ambient value.

   (eval-plastic ray data)

Data are a list of (color specularity roughness transmittance
diffuse-transmittance). The plastic material is simply freezing its
parameters into a closure that accepts ray. All the parameters except
the color are optional, and all of them can be lambdas accepting ray.

   (forward-ray ray)

Evaluate ray without checking for csgs. Don't call it unless you do it
from a csg material evaluator, as misuse could lead to unpredicted
behaviour.

   (eval-uniform-volume ray data . return-ior)

data is a list of (fog-color fog-fading-distance shine ior).
If return-ior is true, the call simply returns the ior.

   (csg? data)

#t if data is csg.

   (csg-container object ...)

Make a csg container from object. This means that objects (which are
surfaces) are assumed to bind a volume that is returned by this call.
If objects don't form a closed figure, behaviour is unpredictable.
Object can belong to at most two csgs. CSGs themselves are not objects,
and are held by the objects they contain (and are protected from GC
as long as the objects they enclose exist).

   (csg-union csg ...)
   (csg-intersection csg ...)
   (csg-minus csg ...)

CSG set operations.

;-------------- primitive.c functions

   (primitive? data)

#t if data is a primitive object.

   (make-polygon (list vertex ...) material)
   (make-point vector material)
   (make-sphere vector radius material)

Simple primitives.

   (make-tessel vertices normals material)

vertices is mxnx3 array of vertices of tesselated object. Normals are
vertex normals or #f (meaning that no smoothing is performed).

   (make-tree matrix selector (scene ....))

Create a tree primitive. Matrix is a transformation matrix for this copy.
selector is a lambda, returning the proper scene from the ray (careful
with this, you should use it to bind scenes of decreasing complexity to
greater distances, saving time. Other uses could produce artifacts).
Trees include lots of math, especially matrix transforms. Don't use
them if they contain only a few objects.

;functions from mathutils.c

   (minvert matrix)

Invert the matrix.

   (linear-spline x (list x0 val0
			  x1 val1 ...))

xi are supposed to be sorted. linear-spline returns the linearly interpolated
value between vali and val(i+1), when x is between xi and x(i+1).

   (noise vector)
   (snoise vector)
   (snoise3 vector)
   (fnoise vector . k lambda omega)
   (fnoise3 vector . k lambda omega)

Return noises. K is the number of octaves, with amplitude scale lambda
and spatial scale omega; fnoise3 returns 3d vector.

