-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMath.cpp
43 lines (34 loc) · 877 Bytes
/
Math.cpp
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
#include "stdafx.h"
#include "Math.h"
#include <math.h>
void ComputeFrontAndRight(Vector3& front, Vector3& right, GLfloat pitch, GLfloat heading)
{
GLfloat sinP = sinf(DEG2RAD(pitch));
GLfloat cosP = cosf(DEG2RAD(pitch));
GLfloat sinH = sinf(DEG2RAD(heading));
GLfloat cosH = cosf(DEG2RAD(heading));
right.x = cosP;
right.y = 0;
right.z = sinP;
front.x = -sinP * cosH;
front.y = sinH;
front.z = cosP * cosH;
}
void Vector3::Set(GLfloat xx, GLfloat yy, GLfloat zz){
x = xx; y = yy; z = zz;
}
Vector3 Vector3::operator+(Vector3 vect){
Vector3 result;
result.Set(x + vect.x, y + vect.y, z + vect.z);
return result;
}
Vector3 Vector3::operator-(Vector3 vect){
Vector3 result;
result.Set(x - vect.x, y - vect.y, z - vect.z);
return result;
}
Vector3 Vector3::operator*(GLfloat alfa){
Vector3 result;
result.Set(x*alfa, y*alfa, z*alfa);
return result;
}