LYGIA Shader Library

mul (lygia/v1.2.0/math/quat/mul)

Quaternion multiplication. Based on http://mathworld.wolfram.com/Quaternion.html

Dependencies:

Use:

<QUAT> quatMul(<QUAT> a, <QUAT> b)

Check it on Github



#ifndef FNC_QUATMUL
#define FNC_QUATMUL
QUAT quatMul(QUAT q1, QUAT q2) {
    return QUAT(
        q2.xyz * q1.w + q1.xyz * q2.w + cross(q1.xyz, q2.xyz),
        q1.w * q2.w - dot(q1.xyz, q2.xyz)
    );
}

QUAT quatMul(QUAT q, float s) {
    return QUAT(q.xyz * s, q.w * s);
}
#endif

License

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository