These functions are optimised for 3D graphics, and the collision of computer science and maths is apparent here, so vectors representing "vectors" are in this context taken to be 3 elements long, quaternions are vectors of length 4, and matrices are vectors of 16 elements long.
result-vector
Multiplies a vector by a number
(vmul (vector 1 2 3) 2)
result-vector
Adds two vectors together
(vadd (vector 1 2 3) (vector 1 2 3))
result-vector
Subtracts a vector from another
(vsub (vector 1 2 3) (vector 1 2 3))
result-vector
Divides a vector by a number
(vdiv (vector 1 2 3) 2)
result-vector
Multiplies (transforms) a vector by a matrix
(vtransform (vector 0 1 0) (mrotate (vector 90 0 0)))
result-vector
Multiplies (transforms) a vector by a matrix, but leaves out the translation part. For operations involving normals.
(vtransform-rot (vector 0 1 0) (mrotate (vector 90 0 0)))
result-vector
Returns the normalised form of the vector (length=1)
(vtransform-rot (vector 0 1 0) (mrotate (vector 90 0 0)))
result-number
Returns the dot product of two vectors
(vdot (vector 0 1 0) (vector 1 0 0))
result-number
Returns the magnitude, or length of the vector
(vmag (vector 0 1 1))
result-number
Treating the vectors as points, returns the distance between them
(vdist (vector 100 100 0) (vector 0 0 100))
result-vector
Returns the cross product of two vectors
(vcross (vector 100 100 0) (vector 0 0 100))
matrix-vector
Multiplies two matrices together
(vmul (mtranslate (vector 1 0 0)) (mrotate (vector 0 90 0)))
matrix-vector
Adds two matrices together
(vadd (mtranslate (vector 1 0 0)) (mrotate (vector 0 90 0)))
matrix-vector
Subtracts a matrix from another
(vsub (mtranslate (vector 1 0 0)) (mrotate (vector 0 90 0)))
matrix-vector
Divides a matrix by another
(vdiv (mtranslate (vector 1 0 0)) (mrotate (vector 0 90 0)))
matrix-vector
Returns the identity matrix
(mident)
matrix-vector
Returns a matrix representing the specified transform
(mtransform (vector 100 0 0))
matrix-vector
Returns a matrix representing the specified rotation. Accepts a vector of euler angles, or a quaternion.
(mrotate (vector 0 45 0))
matrix-vector
Returns a matrix representing the specified scaling.
(mscale (vector 0.5 2 0.5))
matrix-vector
Returns the transpose of the input vector
(mtranspose (mident))
matrix-vector
Returns the inverse of the input vector
(minverse (mscale (vector 0.5 2 0.5)))
matrix-vector
Returns a matrix representing an aiming rotation so that the x axis points down the aim direction, and the y axis points up the up vector. Probably suffers from gimbal lock.
(maim (vector 0 0 1) (vector 0 1 0))
quaternion-vector
Returns the quaternion representing rotation of angle degrees about the specified axis.
(qaxisangle (vector 0 1 0) 45)
quaternion-vector
Multiplies two quaternions together.
(qmul (qaxisangle (vector 0 1 0) 45) (qaxisangle (vector 0 0 1) 180))
quaternion-vector
Normalises a quaternion.
(qnormalise (qaxisangle (vector 0 19 0) 45))
matrix-vector
Converts a quaternion into a rotation matrix.
(qtomatrix (qaxisangle (vector 0 1 0) 45))
quaternion-vector
Conjugatea a quaternion.
(qconjugate (qaxisangle (vector 0 1 0) 45))