rendered paste body// blockland 1.2 plugin snippet
void QuatToEuler(const quat_t *quat, double *rotx, double *roty, double *rotz)
{
double sqw;
double sqx;
double sqy;
double sqz;
double rotxrad;
double rotyrad;
double rotzrad;
sqw = quat->w * quat->w;
sqx = quat->x * quat->x;
sqy = quat->y * quat->y;
sqz = quat->z * quat->z;
rotxrad = (double)atan2l(2.0 * ( quat->y * quat->z + quat->x * quat->w ) , ( -sqx - sqy + sqz + sqw ));
rotyrad = (double)asinl(-2.0 * ( quat->x * quat->z - quat->y * quat->w ));
rotzrad = (double)atan2l(2.0 * ( quat->x * quat->y + quat->z * quat->w ) , ( sqx - sqy - sqz + sqw ));
*rotx = rad2deg(rotxrad);
*roty = rad2deg(rotyrad);
*rotz = rad2deg(rotzrad);
return;
}