Vectors, quaternions, and matrices for general purposes, and computer graphics.
Vector, matrix, and quaternion data structures and operations. Uses f32 or f64 based types.
Example use cases:
- Computer graphics
- Biomechanics
- Robotics and unmanned aerial vehicles.
- Structural chemistry and biochemistry
- Cosmology modeling
- Various scientific and engineering applications
- Aircraft attitude systems and autopilots
Vector and Quaternion types are copy.
For Compatibility with no_std tgts, e.g. embedded, Use the no_std
feature. This feature omits std::fmt::Display
implementations. For computer-graphics
functionality (e.g. specialty matrix constructors, and [de]serialization to byte arrays for passing to and from GPUs), use the computer_graphics
feature. For bincode binary encoding and decoding, use the encode
feature.
For information on practical quaternion operations: Quaternions: A practical guide.
The From
trait is implemented for most types, for converting between f32
and f64
variants using the into()
syntax.
See the official documentation (Linked above) for details. Below is a brief, impractical syntax overview:
use TAU;
use ;
If using for computer graphics, this functionality may be helpful:
let a = new;
let bytes = a.to_bytes; // Send this to the GPU. `Quaternion` and `Matrix` have similar methods.
let model_mat = new_translation
* self.orientation.to_matrix
* new_scaler_partial;
let proj_mat = new_perspective_lh;
let view_mat = self.orientation.inverse.to_matrix * new_translation;
// Example of rolling a camera around the forward axis:
let fwd = orientation.rotate_vec;
let rotation = from_axis_angle;
orientation = rotation * orientation;
A practical geometry example:
/// Calculate the dihedral angle between 4 positions (3 bonds).
/// The `bonds` are one atom's position, substracted from the next. Order matters.