forked from tharvik/COG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVvector.h
192 lines (167 loc) · 3.26 KB
/
Vvector.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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#pragma once
#include <array>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
/**
* Represent a tri-dimensionnal vector of float
*/
class Vvector {
private:
/**
* Elements of the array
*/
std::array<float, 3> scalar;
public:
/**
* Construct a Vvector of (0,0,0)
*/
Vvector();
/**
* Construct a Vvector with the given values
*
* \param x Value of x
* \param y Value of y
* \param z Value of z
*/
Vvector(const float x, const float y, const float z);
/**
* Set the values
*
* \param x Value of x
* \param y Value of y
* \param z Value of z
*/
void set(const float x, const float y, const float z);
/**
* Set the Vvector to (0,0,0)
*/
void setNull();
/**
* Transform to an unit Vvector
*/
void normalize();
/**
* Return the norm
*
* \return Norm
*/
float length() const;
/**
* Print the values
*/
void print() const;
/**
* Add this Vvector with the given one
*
* \param a Vvector to add
*
* \return Resulting Vvector
*/
Vvector operator+(Vvector const& a) const;
/**
* Substract this Vvector with the given one
*
* \param a Vvector to substract
*
* \return Resulting Vvector
*/
Vvector operator-(Vvector const& a) const;
/**
* Cross product this Vvector with the given one
*
* \param a Vvector to cross product
*
* \return Resulting Vvector
*/
Vvector operator^(Vvector const& a) const;
/**
* Multiply this Vvector by the given factor
*
* \param a Factor
*
* \return Resulting Vvector
*/
Vvector operator*(const float a) const;
/**
* Add to this Vvector, the given one
*
* \param a Vvector to add to
*/
void operator+=(Vvector const& a);
/**
* Substract to this Vvector, the given one
*
* \param a Vvector to substract to
*/
void operator-=(Vvector const& a);
/**
* Cross product to this Vvector, the given one
*
* \param a Vvector to cross product to
*/
void operator^=(Vvector const& a);
/**
* Update this Vvector by multipling by the given factor
*
* \param a Factor
*/
void operator*=(const float a);
/**
* Dot product this Vvector with the given one
*
* \param a to dot product
*
* \return Result
*/
double operator*(Vvector const& a) const;
/**
* Test if the given Vvector is equal
*
* \param a to test
*
* \return true if it is equal
*/
bool operator==(Vvector const& a) const;
/**
* Test if the given Vvector is different
*
* \param a to test
*
* \return true if it is different
*/
bool operator!=(Vvector const& a) const;
/**
* Return a reference of the value at given indices
*
* \param a Indice in \ref scalar to return
*
* \return Reference of the value at the given indice
*/
float& operator[](const unsigned short a);
/**
* Return the value of x
*
* \return The value of x
*/
float x() const;
/**
* Return the value of y
*
* \return The value of y
*/
float y() const;
/**
* Return the value of z
*
* \return The value of z
*/
float z() const;
/**
* Return a copy of \ref scalar
*
* \return a copy of \ref scalar
*/
std::array<float, 3> scalars() const;
};