forked from ShrineFox/Persona-5-Mod-Menu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMath.flow
More file actions
71 lines (58 loc) · 1.33 KB
/
Math.flow
File metadata and controls
71 lines (58 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const float PI = 3.14159265358979323846f;
int Pow( int x, int n )
{
int number = 1;
if (n >= 0)
{
for ( int i = 0; i < n; ++i )
number *= x;
}
else
{
for ( int i = 0; i > n; --i )
number /= x;
}
return number;
}
float PowF( int x, int n )
{
float number = 1;
if (n >= 0)
{
for ( int i = 0; i < n; ++i )
number *= x;
}
else
{
for ( int i = 0; i > n; --i )
number /= x;
}
return number;
}
void QuaternionFromEulerDegrees( float x, float y, float z, out float qX, out float qY, out float qZ, out float qW )
{
x = DegreesToRadians( x );
y = DegreesToRadians( y );
z = DegreesToRadians( z );
QuaternionFromEuler( x, y, z, out qX, out qY, out qZ, out qW );
}
void QuaternionFromEuler( float x, float y, float z, out float qX, out float qY, out float qZ, out float qW )
{
x *= 0.5f;
y *= 0.5f;
z *= 0.5f;
float c1 = COS( x );
float c2 = COS( y );
float c3 = COS( z );
float s1 = SIN( x );
float s2 = SIN( y );
float s3 = SIN( z );
qW = c1 * c2 * c3 - s1 * s2 * s3;
qX = s1 * c2 * c3 + c1 * s2 * s3;
qY = c1 * s2 * c3 - s1 * c2 * s3;
qZ = c1 * c2 * s3 + s1 * s2 * c3;
}
float DegreesToRadians( float degrees )
{
return degrees * PI / 180f;
}