| Face Engine SDK 5.7.0 A face detection, recognition and tracking engine.

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Vector2.h
1 #pragma once
2
3 #include <cassert>
4
5 namespace fsdk
6 {
10 template<typename T>
11 struct Vector2 {
12 T x;
13 T y;
14
17 Vector2() noexcept
18 : x((T)0), y(T(0)) {}
19
23 explicit Vector2(T x_) noexcept
24 : x(x_), y(x_) {}
25
30 Vector2(T x_, T y_) noexcept
31 : x(x_), y(y_) {}
32
36 template<typename Other>
37 Vector2<T>(const Vector2<Other>& other) noexcept {
38 *this = other;
39 }
40
45 template <typename Other>
46 Vector2<T>& operator = (const Vector2<Other>& other) noexcept {
47 x = static_cast<T>(other.x);
48 y = static_cast<T>(other.y);
49 return *this;
50 }
51
52 //Vector2<T>
53
58 bool operator == (const Vector2& other) const noexcept {
59 return x == other.x &&
60 y == other.y;
61 }
62
67 bool operator != (const Vector2& other) const noexcept {
68 return !(*this == other);
69 }
70
76 bool operator > (const Vector2& other) const noexcept {
77 return x > other.x && y > other.y;
78 }
79
85 bool operator >= (const Vector2& other) const noexcept {
86 return x >= other.x && y >= other.y;
87 }
88
94 bool operator < (const Vector2& other) const noexcept {
95 return x < other.x && y < other.y;
96 }
97
103 bool operator <= (const Vector2& other) const noexcept {
104 return x <= other.x && y <= other.y;
105 }
106
111 T& operator [] (int n) noexcept {
112 assert(n < 2);
113 if (n == 0)
114 return x;
115 else
116 return y;
117 }
118
123 const T& operator [] (int n) const noexcept {
124 assert(n < 2);
125 if (n == 0)
126 return x;
127 else
128 return y;
129 }
130
134 Vector2 operator - (void) const noexcept {
135 return Vector2(-x, -y);
136 }
137
142 Vector2 operator + (const Vector2& rhs) const noexcept {
143 return Vector2(x + rhs.x, y + rhs.y);
144 }
145
150 Vector2 operator - (const Vector2& rhs) const noexcept {
151 return Vector2(x - rhs.x, y - rhs.y);
152 }
153
158 Vector2 operator * (const Vector2& rhs) const noexcept {
159 return Vector2(x * rhs.x, y * rhs.y);
160 }
161
166 Vector2 operator / (const Vector2& rhs) const noexcept {
167 return Vector2(x / rhs.x, y / rhs.y);
168 }
169
174 Vector2& operator += (const Vector2& rhs) noexcept {
175 *this = *this + rhs;
176 return *this;
177 }
178
183 Vector2& operator -= (const Vector2& rhs) noexcept {
184 *this = *this - rhs;
185 return *this;
186 }
187
192 Vector2& operator *= (const Vector2& rhs) noexcept {
193 *this = *this * rhs;
194 return *this;
195 }
196
201 Vector2& operator /= (const Vector2& rhs) noexcept {
202 *this = *this / rhs;
203 return *this;
204 }
205
211 Vector2 operator + (T rhs) const noexcept {
212 return Vector2(x + rhs, y + rhs);
213 }
214
220 Vector2 operator - (T rhs) const noexcept {
221 return Vector2(x - rhs, y - rhs);
222 }
223
229 Vector2 operator * (T rhs) const noexcept {
230 return Vector2(x * rhs, y * rhs);
231 }
232
238 Vector2 operator / (T rhs) const noexcept {
239 return Vector2(x / rhs, y / rhs);
240 }
241
247 Vector2& operator += (T rhs) noexcept {
248 *this = *this + rhs;
249 return *this;
250 }
251
257 Vector2& operator -= (T rhs) noexcept {
258 *this = *this - rhs;
259 return *this;
260 }
261
267 Vector2& operator *= (T rhs) noexcept {
268 *this = *this * rhs;
269 return *this;
270 }
271
277 Vector2& operator /= (T rhs) noexcept {
278 *this = *this / rhs;
279 return *this;
280 }
281 };
282
284 typedef Vector2<float> Point2f;
285
287 typedef Vector2<double> Point2d;
288
290 typedef Vector2<int> Point2i;
291
293 typedef Vector2<unsigned int> Point2u;
294
296 typedef Vector2<unsigned short> Point2us;
297
299 typedef Vector2<int> Size;
300 }
fsdk::Vector2::operator*=
Vector2 & operator*=(const Vector2 &rhs) noexcept
Multiplies (per-element) two vectors.
Definition: Vector2.h:192
fsdk::Vector2::operator*
Vector2 operator*(const Vector2 &rhs) const noexcept
Multiplies (per-element) two vectors.
Definition: Vector2.h:158
fsdk::Vector2::operator[]
T & operator[](int n) noexcept
Indexes the vector.
Definition: Vector2.h:111
fsdk::Point2i
Vector2< int > Point2i
Definition: Vector2.h:290
fsdk::Vector2::operator=
Vector2< T > & operator=(const Vector2< Other > &other) noexcept
Copies another vector.
Definition: Vector2.h:46
fsdk::Vector2::operator<=
bool operator<=(const Vector2 &other) const noexcept
Checks if both coordinates are smaller or equal to respective coordinates of another vector...
Definition: Vector2.h:103
fsdk::Vector2::operator+
Vector2 operator+(const Vector2 &rhs) const noexcept
Adds (per-element) two vectors.
Definition: Vector2.h:142
fsdk::Vector2::Vector2
Vector2() noexcept
Initializes a vector with zeroes.
Definition: Vector2.h:17
fsdk::Vector2::x
T x
x coordinate.
Definition: Vector2.h:12
fsdk::Vector2::Vector2
Vector2(T x_) noexcept
Initializes all elements with the same value.
Definition: Vector2.h:23
fsdk::Point2u
Vector2< unsigned int > Point2u
Definition: Vector2.h:293
fsdk::Vector2::operator==
bool operator==(const Vector2 &other) const noexcept
Checks if two vectors are equal.
Definition: Vector2.h:58
fsdk::Vector2::operator>
bool operator>(const Vector2 &other) const noexcept
Checks if both coordinates are greater then respective coordinates of another vector.
Definition: Vector2.h:76
fsdk::Vector2::operator/
Vector2 operator/(const Vector2 &rhs) const noexcept
Divides (per-element) two vectors.
Definition: Vector2.h:166
fsdk::Vector2::operator<
bool operator<(const Vector2 &other) const noexcept
Checks if both coordinates are smaller then respective coordinates of another vector.
Definition: Vector2.h:94
fsdk::Vector2::operator/=
Vector2 & operator/=(const Vector2 &rhs) noexcept
Divides (per-element) two vectors.
Definition: Vector2.h:201
fsdk::Vector2::y
T y
y coordinate.
Definition: Vector2.h:13
fsdk::Point2d
Vector2< double > Point2d
Definition: Vector2.h:287
fsdk::Point2f
Vector2< float > Point2f
Definition: Vector2.h:284
fsdk::Vector2::operator!=
bool operator!=(const Vector2 &other) const noexcept
Checks if two vectors are not equal.
Definition: Vector2.h:67
fsdk::Vector2::operator+=
Vector2 & operator+=(const Vector2 &rhs) noexcept
Adds (per-element) two vectors.
Definition: Vector2.h:174
fsdk::Vector2::operator-
Vector2 operator-(void) const noexcept
Negates all elements.
Definition: Vector2.h:134
fsdk::Vector2::operator>=
bool operator>=(const Vector2 &other) const noexcept
Checks if both coordinates are greater or equal to respective coordinates of another vector...
Definition: Vector2.h:85
fsdk::Vector2::operator-=
Vector2 & operator-=(const Vector2 &rhs) noexcept
Subtracts (per-element) two vectors.
Definition: Vector2.h:183
fsdk::Size
Vector2< int > Size
Definition: Vector2.h:299
fsdk::Point2us
Vector2< unsigned short > Point2us
Definition: Vector2.h:296
fsdk::Vector2
Generic 2D vector.
Definition: Vector2.h:11
fsdk::Vector2::Vector2
Vector2(T x_, T y_) noexcept
Initializes elements with given value.
Definition: Vector2.h:30