This is a wrapper for the quaternion-core crate.
Provides various operations on quaternion.
Add this to your Cargo.toml
:
toml
[dependencies]
quaternion-wrapper = "0.1"
See the quaternion-core crate documentation for details on each feature.
```toml [dependencies.quaternion-wrapper] version = "0.1"
```
src/main.rs
:
```rust use quaternion_wrapper::{QuaternionWrapper, Vector3Wrapper};
const PI: f64 = std::f64::consts::PI; const EPSILON: f64 = 1e-14;
fn main() { // Generates a quaternion representing the // rotation of π/2[rad] around the y-axis. let q = QuaternionWrapper::fromaxisangle([0.0, 1.0, 0.0], PI/2.0);
// Vector
let v = Vector3Wrapper([2.0, 2.0, 0.0]);
let result = (q * v * q.conj()).get_vector_part();
//let result = q.vector_rotation(v); // <--- It could be written like this
// Check if the calculation is correct.
let true_val = Vector3Wrapper([0.0, 2.0, -2.0]);
let diff: [f64; 3] = (true_val - result).unwrap();
for val in diff.iter() {
assert!(val.abs() < EPSILON);
}
} ```
Licensed under either of Apache License, Version 2.0 or MIT License at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.