lygia
/v1.1.6
/math
/quat
/2mat3
)given a quaternion, returns a rotation 3x3 matrix
Dependencies:
Use:
<mat3> quat2mat3(<QUAT> Q)
#ifndef FNC_QUAT2MAT3
#define FNC_QUAT2MAT3
mat3 quat2mat3(QUAT q) {
float qxx = q.x * q.x;
float qyy = q.y * q.y;
float qzz = q.z * q.z;
float qxz = q.x * q.z;
float qxy = q.x * q.y;
float qyw = q.y * q.w;
float qzw = q.z * q.w;
float qyz = q.y * q.z;
float qxw = q.x * q.w;
return mat3(
vec3(1.0 - 2.0 * (qyy + qzz), 2.0 * (qxy - qzw), 2.0 * (qxz + qyw)),
vec3(2.0 * (qxy + qzw), 1.0 - 2.0 * (qxx + qzz), 2.0 * (qyz - qxw)),
vec3(2.0 * (qxz - qyw), 2.0 * (qyz + qxw), 1.0 - 2.0 * (qxx + qyy))
);
}
#endif
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.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository