## 3d-quaternions

2022-04-01

A utility library implementing quaternion and dual-quaternion functionality.

### Upstream URL

### Author

Nicolas Hafner <shinmera@tymoon.eu>

### Maintainer

Nicolas Hafner <shinmera@tymoon.eu>

### License

zlib

## 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 ``float``s, which by default are ``single-float``s, 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 ``float``s. 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)
::
``quat``s 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-float``s 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-float``s, 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"(https://shinmera.github.io/3d-vectors) for Vector operations in conjunction with this library.
- "3d-matrices"(https://shinmera.github.io/3d-matrices) for Matrix operations in conjunction with this library.