-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVector3.h
72 lines (47 loc) · 1.12 KB
/
Vector3.h
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
72
#ifndef VECTOR3_H
#define VECTOR3_H
#include "glut.h"
class Vector3 {
protected:
double _x;
double _y;
double _z;
public:
Vector3(){}
Vector3(double x, double y, double z){ _x = x; _y = y; _z = z;}
~Vector3(){}
double getX(){ return _x; }
double getY(){ return _y; }
double getZ(){ return _z; }
void setX(double x){ _x = x; }
void setY(double y){ _y = y; }
void setZ(double z){ _z = z; }
void set(double x, double y, double z){ _x = x; _y = y; _z = z; }
Vector3 operator+(const Vector3& vec){
Vector3 res;
res._x = this->getX() + vec._x;
res._y = this->getY() + vec._y;
res._z = this->getZ() + vec._z;
return res;
}
Vector3 operator-(const Vector3& vec){
Vector3 res;
res._x = this->getX() - vec._x;
res._y = this->getY() - vec._y;
res._z = this->getZ() - vec._z;
return res;
}
Vector3 operator*(double multiplier){
Vector3 res;
res._x = this->getX() * multiplier;
res._y = this->getY() * multiplier;
res._z = this->getZ() * multiplier;
return res;
}
void operator=(const Vector3& vec){
this->setX(vec._x);
this->setY(vec._y);
this->setZ(vec._z);
}
};
#endif