Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/lib/src/guRotateF.c
7857 views
1
#include "libultra_internal.h"
2
3
void guRotateF(float m[4][4], float a, float x, float y, float z) {
4
float sin_a;
5
float cos_a;
6
float sp2c;
7
float sp28;
8
float sp24;
9
float xx, yy, zz;
10
static float D_80365D70 = GU_PI / 180;
11
12
guNormalize(&x, &y, &z);
13
14
a = a * D_80365D70;
15
16
sin_a = sinf(a);
17
cos_a = cosf(a);
18
19
sp2c = x * y * (1 - cos_a);
20
sp28 = y * z * (1 - cos_a);
21
sp24 = z * x * (1 - cos_a);
22
23
guMtxIdentF(m);
24
xx = x * x;
25
m[0][0] = (1 - xx) * cos_a + xx;
26
m[2][1] = sp28 - x * sin_a;
27
m[1][2] = sp28 + x * sin_a;
28
yy = y * y;
29
m[1][1] = (1 - yy) * cos_a + yy;
30
m[2][0] = sp24 + y * sin_a;
31
m[0][2] = sp24 - y * sin_a;
32
zz = z * z;
33
m[2][2] = (1 - zz) * cos_a + zz;
34
m[1][0] = sp2c - z * sin_a;
35
m[0][1] = sp2c + z * sin_a;
36
}
37
38
void guRotate(Mtx *m, float a, float x, float y, float z) {
39
float mf[4][4];
40
guRotateF(mf, a, x, y, z);
41
guMtxF2L(mf, m);
42
}
43
44