-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector3D.cpp
More file actions
122 lines (101 loc) · 1.71 KB
/
Vector3D.cpp
File metadata and controls
122 lines (101 loc) · 1.71 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "Vector3D.h"
vector3D::vector3D()
{
x = 0;
y = 0;
z = 0;
}
vector3D::vector3D(float X, float Y, float Z) : x(X), y(Y), z(Z) {}
float vector3D::mangitude()
{
float out = 0;
out = sqrtf((powf(x,2) + powf(y,2) + powf(z,2)));
return out;
}
float * vector3D::returnAsArray()
{
_dataAsArray[0] = x;
_dataAsArray[1] = y;
_dataAsArray[2] = z;
return _dataAsArray;
}
vector3D vector3D::operator*(float val)
{
float x = this->x;
float y = this->y;
float z = this->z;
x *= val;
y *= val;
z *= val;
vector3D out(x,y,z);
return out;
}
vector3D vector3D::operator*(vector3D val)
{
float x = val.x;
float y = val.y;
float z = val.z;
x *= this->x;
y *= this->y;
z *= this->z;
vector3D out(x,y,z);
return out;
}
vector3D vector3D::operator*=(float val)
{
return *(this) * val;
}
vector3D vector3D::operator*=(vector3D val)
{
return *(this) * val;
}
vector3D vector3D::operator /=(float val)
{
return *(this) / val;
}
vector3D vector3D::operator /(float val)
{
float x = this->x;
float y = this->y;
float z = this->z;
x /= val;
y /= val;
z /= val;
vector3D out(x,y,z);
return out;
}
vector3D vector3D::operator /=(vector3D val)
{
return *(this) / val;
}
vector3D vector3D::operator /(vector3D val)
{
float x = val.x;
float y = val.y;
float z = val.z;
x /= this->x;
y /= this->y;
z /= this->z;
vector3D out(x,y,z);
return out;
}
vector3D vector3D::operator+(vector3D val)
{
float x = val.x;
float y = val.y;
float z = val.z;
x += this->x;
y += this->y;
z += this->z;
vector3D out(x,y,z);
return out;
}
vector3D vector3D::operator+=(vector3D val)
{
return *(this) + val;
}
vector3D vector3D::operator=(const vector3D& val)
{
vector3D out = vector3D(val.x, val.y, val.z);
return out;
}