The spica renderer
vector2d.h
1 #ifdef _MSC_VER
2 #pragma once
3 #endif
4 
5 #ifndef _SPICA_VECTOR2D_H_
6 #define _SPICA_VECTOR2D_H_
7 
8 #include <type_traits>
9 
10 namespace spica {
11 
16 template <class T>
17 class Vector2_ {
18 public:
19  Vector2_();
20  Vector2_(T x, T y);
21  Vector2_(const Vector2_& v);
22 
23  ~Vector2_();
24 
25  Vector2_& operator=(const Vector2_& v);
26  Vector2_& operator+=(const Vector2_& v);
27  Vector2_& operator-=(const Vector2_& v);
28  Vector2_& operator*=(double s);
29 
30  T x() const { return _x; }
31  T y() const { return _y; }
32 
33 private:
34  T _x, _y;
35 
36  static_assert(std::is_arithmetic<T>::value,
37  "Template type must be arithmetic!!");
38 };
39 
40 using Vector2i = Vector2_<int>;
41 using Vector2f = Vector2_<float>;
42 using Vector2d = Vector2_<double>;
43 
44 } // namespace spica
45 
46 template <class T>
47 spica::Vector2_<T> operator+(const spica::Vector2_<T>& v1,
48  const spica::Vector2_<T>& v2);
49 
50 template <class T>
51 spica::Vector2_<T> operator-(const spica::Vector2_<T>& v1,
52  const spica::Vector2_<T>& v2);
53 
54 template <class T>
55 spica::Vector2_<T> operator*(const spica::Vector2_<T>& v, double s);
56 
57 template <class T>
58 spica::Vector2_<T> operator*(double s, const spica::Vector2_<T>& v);
59 
60 #include "vector2d_detail.h"
61 
62 #endif // _SPICA_VECTOR2D_H_
Two-dimensional vector.
Definition: core.hpp:50