Note: This is taken from the Chicken Wiki, where a more recent version could be available.
The SO31 egg provides functions to manipulate elements of the Lorentz group in four dimensions, commonly denoted SO(3,1). The group elements can be represented by either the standard 4x4 matrices or by six parameters.
Note that the egg provides a syntax-case module named SO31, which must be imported into the current namespace before any of the listed functions become available.
The parameterization used by the egg is:
vx, vy, vz, x, y, z :-> M = Bx(vx)*By(vy)*Bz(vz)*Rx(x)*Ry(y)*Rz(z),
where the Ri are the usual rotation matrices in terms of the angles x,y,z, and the Bi are the usual boost matrices, expressed in terms of the rapidity vi.
The following example composes two boosts in the x-direction with rapidity 1.0
(use syntax-case) (use SO31) (import SO31) (let ((p (f64vector 1 0 0 0 0 0))) ; Boost in x direction w/rapidity 1 (params-compose p p)) ; => close to '#f64(2 0 0 0 0 0) because the rapidity adds
SO31 is released under the GPL:
Copyright © 2007 Will M. Farr <email@example.com>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The following procedures are brought into the local environment when (import SO31) is issued:
[procedure] (matrix? obj)
Evaluates to #f unless obj is a 4x4 matrix (actually, any 16-element f64vector will do).
[procedure] (params? obj)
Evaluates to #f unless obj is a 6-element f64vector.
[f64vector] Tvx [f64vector] Tvy [f64vector] Tvz [f64vector] Tx [f64vector] Ty [f64vector] Tz
Values representing the corresponding generator matrices for SO(3,1).
[procedure] (Bx vx) [procedure] (By vy) [procedure] (Bz vz) [procedure] (Rx x) [procedure] (Ry y) [procedure] (Rz z)
Produce Boost and Rotation matrices with the given parameters. Boosts are parameterized in terms of the rapidity along a given axis, while rotations are parameterized by an angle of rotation about a given axis.
The Minkowski metric. eta = diag(-1,1,1,1).
[procedure] (params->matrix p)
Takes a 6-element f64vector, p, and returns the matrix representing the corresponding Lorentz transformation: if p is '#f64(vx vy vz x y z), then the result M is M = Bx(vx)*By(vy)*Bz(vz)*Rx(x)*Ry(y)*Rz(z).
[procedure] (matrix->params m)
The inverse of params->matrix.
[procedure] (matrix-compose m1 m2)
Returns the matrix product of m1 and m2—i.e. implements the group multiplication operation.
[procedure] (params-compose p1 p2)
Implements the group multiplication operation on the parameters p1 and p2.
[procedure] (matrix-inverse m) [procedure] (params-inverse p)
Implement the group inverse operation.