3d quaternions

1.0.0

A utility library implementing quaternion and dual-quaternion functionality.

About 3d-quaternions

This is a library for quaternions. It contains most of the quaternion operations one would usually expect out of such a library and offers them both in non-modifying and modifying versions where applicable. It also tries to be efficient where plausible. Each quaternion is made up of floats, which by default are single-floats, as they do not require value boxing on most modern systems and compilers.

How To

Load it through ASDF or Quicklisp

(ql:quickload :3d-quaternions)
(use-package :org.shirakumo.flare.quaternion)

Create a quaternion:

(quat)

Quaternions always use floats. Where sensible, operations should accept real numbers for convenience. All quaternion operations are prefixed with a q to allow importing the package without conflicts.

(q+ (quat 1 2 3 4) 4 5 6)
(qfrom-angle +vz+ PI)

3d-quaternions implements pretty much all quaternion operations you might need, including comparators, dot product, matrix conversion, and so forth. There's also modifying variants of most operators, which have the same name, except they are prefixed by an n.

(let ((q (quat)))
  (nq* (nq+ q (quat 1 2 3 4)) 3)
  q)

quats are dumpable, meaning you can insert them as literals into your code and they will be properly saved to and restored from a FASL.

If you require higher precision than single-floats ensure, you can add :3d-vectors-double-floats to *features* and recompile the library (asdf:compile-system :3d-quaternions :force T). Similarly, if you want to switch back to single-floats, you can remove the feature and recompile. Both at the same time is not supported as it would increase complexity in the library massively and make certain operations much slower.

Also See

  • 3d-vectors for Vector operations in conjunction with this library.

  • 3d-matrices for Matrix operations in conjunction with this library.

System Information

1.0.0
Nicolas Hafner
zlib

Definition Index