shigens 0.1.0

A math library for calculate quaternion.
Documentation
  • Coverage
  • 4.76%
    1 out of 21 items documented1 out of 1 items with examples
  • Size
  • Source code size: 31.52 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 8.71 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kan1-u

Shigens

The shigens is a math library for calculate quaternion.

When there was such a variable

x = 1 + 2i + 3j + 4k

in shigens can write like this.

use shigens::*;

let x = quaternion(1, 2, 3, 4);
// or
let x = r(1) + i(2) + j(3) + k(4);

Examples

So far, I have implemented only basic operations.

use shigens::*;

assert_eq!(i(1) * i(1), r(-1));
assert_eq!(j(1) * j(1), r(-1));
assert_eq!(k(1) * k(1), r(-1));
use shigens::*;

let x1 = quaternion(2, 3, 4, 5);
let x2 = quaternion(6, 7, 8, 9);
let y = x1 + x2;

assert_eq!(y.r.get_value(), 2 + 6);
assert_eq!(y.i.get_value(), 3 + 7);
assert_eq!(y.j.get_value(), 4 + 8);
assert_eq!(y.k.get_value(), 5 + 9);
use shigens::*;

let x1 = quaternion(2, 3, 4, 5);
let x2 = quaternion(6, 7, 8, 9);
let y = x1 * x2;

assert_eq!(y.r.get_value(), 2 * 6 - 3 * 7 - 4 * 8 - 5 * 9);
assert_eq!(y.i.get_value(), 2 * 7 + 3 * 6 + 4 * 9 - 5 * 8);
assert_eq!(y.j.get_value(), 2 * 8 + 4 * 6 + 5 * 7 - 3 * 9);
assert_eq!(y.k.get_value(), 2 * 9 + 5 * 6 + 3 * 8 - 4 * 7);
use shigens::*;

let x = quaternion(2, 3, 4, 5);
let y = x * i(2);

assert_eq!(y.r.get_value(), 3 * 2 * -1);
assert_eq!(y.i.get_value(), 2 * 2);
assert_eq!(y.j.get_value(), 5 * 2);
assert_eq!(y.k.get_value(), 4 * 2 * -1);