reference repos
FWGS/regamelite
rpasta42/csgo
sharplife
xash
Matrix
void AngleQuaternion(float* angles, float* quaternion)
{
float sy, cy, sp_, cp;
float angle;
float sr, cr;
float ftmp0;
float ftmp1;
float ftmp2;
angle = angles[ROLL] * 0.5;
sy = sin(angle);
cy = cos(angle);
angle = angles[YAW] * 0.5;
sp_ = sin(angle);
cp = cos(angle);
angle = angles[PITCH] * 0.5;
sr = sin(angle);
cr = cos(angle);
ftmp0 = sr * cp;
ftmp1 = cr * sp_;
*quaternion = ftmp0 * cy - ftmp1 * sy;
quaternion[1] = ftmp1 * cy + ftmp0 * sy;
ftmp2 = cr * cp;
quaternion[2] = ftmp2 * sy - sp_ * sr * cy;
quaternion[3] = sp_ * sr * sy + ftmp2 * cy;
}
void QuaternionMatrix(vec_t *quaternion, float (*matrix)[4])
{
matrix[0][0] = 1.0 - 2.0 * quaternion[1] * quaternion[1] - 2.0 * quaternion[2] * quaternion[2];
matrix[1][0] = 2.0 * quaternion[0] * quaternion[1] + 2.0 * quaternion[3] * quaternion[2];
matrix[2]