Face Engine SDK
5.23.1
A face detection, recognition and tracking engine.
|
00001 #pragma once 00002 00003 #include <cassert> 00004 00005 namespace fsdk { 00009 template <typename T> 00010 struct Vector2 { 00011 T x; 00012 T y; 00013 00016 Vector2() noexcept 00017 : x((T)0) 00018 , y(T(0)) { 00019 } 00020 00024 explicit Vector2(T x_) noexcept 00025 : x(x_) 00026 , y(x_) { 00027 } 00028 00033 Vector2(T x_, T y_) noexcept 00034 : x(x_) 00035 , y(y_) { 00036 } 00037 00041 template <typename Other> 00042 Vector2<T>(const Vector2<Other>& other) noexcept { 00043 *this = other; 00044 } 00045 00050 template <typename Other> 00051 Vector2<T>& operator=(const Vector2<Other>& other) noexcept { 00052 x = static_cast<T>(other.x); 00053 y = static_cast<T>(other.y); 00054 return *this; 00055 } 00056 00057 // Vector2<T> 00058 00063 bool operator==(const Vector2& other) const noexcept { 00064 return x == other.x && y == other.y; 00065 } 00066 00071 bool operator!=(const Vector2& other) const noexcept { 00072 return !(*this == other); 00073 } 00074 00080 bool operator>(const Vector2& other) const noexcept { 00081 return x > other.x && y > other.y; 00082 } 00083 00089 bool operator>=(const Vector2& other) const noexcept { 00090 return x >= other.x && y >= other.y; 00091 } 00092 00098 bool operator<(const Vector2& other) const noexcept { 00099 return x < other.x && y < other.y; 00100 } 00101 00107 bool operator<=(const Vector2& other) const noexcept { 00108 return x <= other.x && y <= other.y; 00109 } 00110 00115 T& operator[](int n) noexcept { 00116 assert(n < 2); 00117 if(n == 0) 00118 return x; 00119 else 00120 return y; 00121 } 00122 00127 const T& operator[](int n) const noexcept { 00128 assert(n < 2); 00129 if(n == 0) 00130 return x; 00131 else 00132 return y; 00133 } 00134 00138 Vector2 operator-(void) const noexcept { 00139 return Vector2(-x, -y); 00140 } 00141 00146 Vector2 operator+(const Vector2& rhs) const noexcept { 00147 return Vector2(x + rhs.x, y + rhs.y); 00148 } 00149 00154 Vector2 operator-(const Vector2& rhs) const noexcept { 00155 return Vector2(x - rhs.x, y - rhs.y); 00156 } 00157 00162 Vector2 operator*(const Vector2& rhs) const noexcept { 00163 return Vector2(x * rhs.x, y * rhs.y); 00164 } 00165 00170 Vector2 operator/(const Vector2& rhs) const noexcept { 00171 return Vector2(x / rhs.x, y / rhs.y); 00172 } 00173 00178 Vector2& operator+=(const Vector2& rhs) noexcept { 00179 *this = *this + rhs; 00180 return *this; 00181 } 00182 00187 Vector2& operator-=(const Vector2& rhs) noexcept { 00188 *this = *this - rhs; 00189 return *this; 00190 } 00191 00196 Vector2& operator*=(const Vector2& rhs) noexcept { 00197 *this = *this * rhs; 00198 return *this; 00199 } 00200 00205 Vector2& operator/=(const Vector2& rhs) noexcept { 00206 *this = *this / rhs; 00207 return *this; 00208 } 00209 00215 Vector2 operator+(T rhs) const noexcept { 00216 return Vector2(x + rhs, y + rhs); 00217 } 00218 00224 Vector2 operator-(T rhs) const noexcept { 00225 return Vector2(x - rhs, y - rhs); 00226 } 00227 00233 Vector2 operator*(T rhs) const noexcept { 00234 return Vector2(x * rhs, y * rhs); 00235 } 00236 00242 Vector2 operator/(T rhs) const noexcept { 00243 return Vector2(x / rhs, y / rhs); 00244 } 00245 00251 Vector2& operator+=(T rhs) noexcept { 00252 *this = *this + rhs; 00253 return *this; 00254 } 00255 00261 Vector2& operator-=(T rhs) noexcept { 00262 *this = *this - rhs; 00263 return *this; 00264 } 00265 00271 Vector2& operator*=(T rhs) noexcept { 00272 *this = *this * rhs; 00273 return *this; 00274 } 00275 00281 Vector2& operator/=(T rhs) noexcept { 00282 *this = *this / rhs; 00283 return *this; 00284 } 00285 }; 00286 00288 typedef Vector2<float> Point2f; 00289 00291 typedef Vector2<double> Point2d; 00292 00294 typedef Vector2<int> Point2i; 00295 00297 typedef Vector2<unsigned int> Point2u; 00298 00300 typedef Vector2<unsigned short> Point2us; 00301 00303 typedef Vector2<int> Size; 00304 } // namespace fsdk