-
Notifications
You must be signed in to change notification settings - Fork 0
/
vect.h
94 lines (81 loc) · 1.44 KB
/
vect.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef __VECT_H__
#define __VECT_H__
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
class Vect
{
public:
double x,y,z;
Vect()
{
this->x = 0;
this->y = 0;
this->z = 0;
}
Vect(double _x, double _y, double _z)
{
this->x = _x;
this->y = _y;
this->z = _z;
}
Vect operator-(const Vect& v)
{
Vect r;
r.x = this->x - v.x;
r.y = this->y - v.y;
r.z = this->z - v.z;
return r;
}
Vect operator+(const Vect& v)
{
Vect r;
r.x = this->x + v.x;
r.y = this->y + v.y;
r.z = this->z + v.z;
return r;
}
Vect operator+=(const Vect& v)
{
this->x += v.x;
this->y += v.y;
this->z += v.z;
return *this;
}
Vect operator*=(const double& scalar)
{
this->x *= scalar;
this->y *= scalar;
this->z *= scalar;
return *this;
}
Vect operator/=(const double& scalar)
{
this->x /= scalar;
this->y /= scalar;
this->z /= scalar;
return *this;
}
Vect operator*(const double& scalar)
{
Vect re;
re.x = this->x * scalar;
re.y = this->y * scalar;
re.z = this->z * scalar;
return re;
}
Vect operator/(const double& scalar)
{
Vect re;
re.x = this->x / scalar;
re.y = this->y / scalar;
re.z = this->z / scalar;
return re;
}
double Int()
{
return sqrt(this->x * this->x + this->y * this->y + this->z + this->z);
}
};
#endif