so we can get identical behaviour by using
void sk_m44_set_rotate_about_degrees(sk_m44_t* matrix, float x, float y, float z, float degrees) {
sk_m44_set_rotate_about_radians(matrix, x, y, z, degrees * SK_ScalarPI / 180);
}
void sk_m44_set_rotate_about_radians(sk_m44_t* matrix, float x, float y, float z, float radians) {
SkM44* m44 = AsM44(matrix);
m44->setRotate(SkV3{ x, y, z }, radians);
}
void sk_m44_set_rotate_about_radians_unit(sk_m44_t* matrix, float x, float y, float z, float radians) {
SkM44* m44 = AsM44(matrix);
m44->setRotateUnit(SkV3{ x, y, z }, radians);
}
instead of
void sk_m44_set_rotate_about_degrees(sk_m44_t* matrix, float x, float y, float z, float degrees) {
sk_m44_set_rotate_about_radians(matrix, x, y, z, degrees * SK_ScalarPI / 180);
}
void sk_m44_set_rotate_about_radians(sk_m44_t* matrix, float x, float y, float z, float radians) {
double len2 = (double)x * x + (double)y * y + (double)z * z;
if (1 != len2) {
if (0 == len2) {
AsM44(matrix)->setIdentity();
return;
}
double scale = 1 / sqrt(len2);
x = SkScalar(x * scale);
y = SkScalar(y * scale);
z = SkScalar(z * scale);
}
sk_m44_set_rotate_about_radians_unit(matrix, x, y, z, radians);
}
void set3x3(SkM44* m44, SkScalar m_00, SkScalar m_10, SkScalar m_20,
SkScalar m_01, SkScalar m_11, SkScalar m_21,
SkScalar m_02, SkScalar m_12, SkScalar m_22) {
SMAT4(0, 0), m_00); SMAT4(0, 1), m_10); SMAT4(0, 2), m_20); SMAT4(0, 3), 0);
SMAT4(1, 0), m_01); SMAT4(1, 1), m_11); SMAT4(1, 2), m_21); SMAT4(1, 3), 0);
SMAT4(2, 0), m_02); SMAT4(2, 1), m_12); SMAT4(2, 2), m_22); SMAT4(2, 3), 0);
SMAT4(3, 0), 0); SMAT4(3, 1), 0); SMAT4(3, 2), 0); SMAT4(3, 3), 1);
}
void sk_m44_set_rotate_about_radians_unit(sk_m44_t* matrix, float x, float y, float z, float radians) {
double c = cos(radians);
double s = sin(radians);
double C = 1 - c;
double xs = x * s;
double ys = y * s;
double zs = z * s;
double xC = x * C;
double yC = y * C;
double zC = z * C;
double xyC = x * yC;
double yzC = y * zC;
double zxC = z * xC;
// if you're looking at wikipedia, remember that we're column major.
SkM44* m44 = AsM44(matrix);
set3x3(m44, SkScalar(x * xC + c), // scale x
SkScalar(xyC + zs), // skew x
SkScalar(zxC - ys), // trans x
SkScalar(xyC - zs), // skew y
SkScalar(y * yC + c), // scale y
SkScalar(yzC + xs), // trans y
SkScalar(zxC + ys), // persp x
SkScalar(yzC - xs), // persp y
SkScalar(z * zC + c)); // persp 2
}
?