Sign in

    quaternion

    Quaternion math library

    math
    quaternion
    Download zip
    Author
    Version
    0.1.3
    License
    Apache-2.0
    Last updated
    5 months ago
    Downloads
    67

    #Quaternion Library for MoonBit

    MoonBit does not have num_traits::Float so this library is only using Float(i.e.f32).

    moon add tiye/quaternion

    Find docs on Mooncakes.

    let a = Quaternion::{ w: 1.0, x: 2.0, y: 3.0, z: 4.0 };
    a.w;

    // quick creates
    let b1 = q(1.0, 2.0, 3.0, 4.0);
    //
    // quick creates with integers
    let b2 = qi(1, 2, 3, 4);

    b1 + b2;
    b1 - b2;
    b1 * b2;
    b1 / b2;
    b1.conjugate();
    b1.scale(1.5);
    b1.square_length();
    b1.length();
    b1.inverse();

    a.to_array();
    a.to_xyzw()

    Quaternion::from_array([1.0, 2.0, 3.0, 4.0]);
    Quaternion::from_xyzw_array(1.0, 2.0, 3.0, 4.0);

    There are also mutable APIs:

    let mut c = Quaternion::id();
    let b = qi(1, 2, 3, 4);

    c b;
    c - b;
    c * b;
    // no division

    c.inverse_mut();
    c.conjugate_mut();
    c.scale_mut(1.5);

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io