/vecmath

Simple 2d and 3d vector and matrix math library.

Primary LanguageCommon LispMIT LicenseMIT

This is a simple linear algebra math library in Common-Lisp.
It contains datatypes for 2 and 3 dimensions.

It provides some simple algorithms commonly used for computer
graphics, like rotation, transformation, scaling and interpolation
of vectors. It also provides functions to convert between different
representations of rotations, namely matrices, quaternions, euler
angles (yaw, pitch, roll) and axis/angle.

The aim is to have algorithms that work on simple vector/matrix types,
but can also be mapped over a flat array of this vector types, so you
can write:

  (defparameter *coords* (vec 1.0 2.0 3.0  1.0 2.0 3.0  ...))
  (defparameter *world-transform*  (mat4))

  (vec3-map nil (vec3-transformer *world-transform*) *coords*))

The library should be as efficient as possible without resorting to
implementation specific tricks. It excessivly uses multiple-values for
this purpose. This is probably overdone and might even hurt
performance under some implementations. My initial benchmarking with
sbcl and ccl did show some promising numbers compared to a straight
forward implementation of the same algorithms.

For similar approaches see also:
 - sb-cga: http://nikodemus.github.com/sb-cga/
 - cl-tuples: http://repo.or.cz/w/cl-tuples.git