libkovan  1
The kovan standard library
geom.hpp
Go to the documentation of this file.
1 #ifndef _GEOM_HPP_
2 #define _GEOM_HPP_
3 
4 #include "geom.h"
5 #include "export.h"
6 
7 template<typename T>
9 {
10 public:
11  Point2(const T& x, const T &y)
12  : m_x(x),
13  m_y(y)
14  {
15  }
16 
17  const T &x() const
18  {
19  return m_x;
20  }
21 
22  const T &row() const
23  {
24  return m_y;
25  }
26 
27  const T &y() const
28  {
29  return m_y;
30  }
31 
32  const T &column() const
33  {
34  return m_x;
35  }
36 
37  void setX(const T &x)
38  {
39  m_x = x;
40  }
41 
42  void setColumn(const T &column)
43  {
44  m_x = column;
45  }
46 
47  void setY(const T &y)
48  {
49  m_y = y;
50  }
51 
52  void setRow(const T &row)
53  {
54  m_y = row;
55  }
56 
57  point2 toCPoint2() const
58  {
59  return create_point2(m_x, m_y);
60  }
61 
62 private:
63  T m_x;
64  T m_y;
65 };
66 
67 template<typename T>
69 {
70 public:
71  Point3(const T& x, const T &y, const T &z)
72  : m_x(x),
73  m_y(y),
74  m_z(z)
75  {
76  }
77 
78  const T &x() const
79  {
80  return m_x;
81  }
82 
83  const T &y() const
84  {
85  return m_y;
86  }
87 
88  const T &z() const
89  {
90  return m_z;
91  }
92 
93  void setX(const T &x)
94  {
95  m_x = x;
96  }
97 
98  void setY(const T &y)
99  {
100  m_y = y;
101  }
102 
103  void setZ(const T &z)
104  {
105  m_z = z;
106  }
107 
109  {
110  return create_point3(m_x, m_y, m_z);
111  }
112 
113 private:
114  T m_x;
115  T m_y;
116  T m_z;
117 };
118 
119 template<typename T>
121 {
122 public:
123  Rect(const T &x, const T &y, const T &width, const T &height)
124  : m_x(x),
125  m_y(y),
126  m_width(width),
127  m_height(height)
128  {
129  }
130 
131  const T &x() const
132  {
133  return m_x;
134  }
135 
136  const T &y() const
137  {
138  return m_y;
139  }
140 
141  const T &width() const
142  {
143  return m_width;
144  }
145 
146  const T &height() const
147  {
148  return m_height;
149  }
150 
152  {
153  return Point2<T>(m_x + m_width / 2, m_y + m_height / 2);
154  }
155 
156  void setX(const T &x)
157  {
158  m_x = x;
159  }
160 
161  void setY(const T &y)
162  {
163  m_y = y;
164  }
165 
166  void setWidth(const T &width)
167  {
168  m_width = width;
169  }
170 
171  void setHeight(const T &height)
172  {
173  m_x = height;
174  }
175 
176  T area() const
177  {
178  return m_width * m_height;
179  }
180 
182  {
183  return create_rectangle(m_x, m_y, m_width, m_height);
184  }
185 
186 private:
187  T m_x;
188  T m_y;
189  T m_width;
190  T m_height;
191 };
192 
193 #endif
const T & width() const
Definition: geom.hpp:141
Rect(const T &x, const T &y, const T &width, const T &height)
Definition: geom.hpp:123
void setX(const T &x)
Definition: geom.hpp:156
VF EXPORT_SYM point3 create_point3(int x, int y, int z)
T area() const
Definition: geom.hpp:176
const T & y() const
Definition: geom.hpp:136
Definition: geom.hpp:120
Point2< T > center() const
Definition: geom.hpp:151
const T & height() const
Definition: geom.hpp:146
Definition: geom.h:37
Point2(const T &x, const T &y)
Definition: geom.hpp:11
rectangle toCRectangle() const
Definition: geom.hpp:181
const T & y() const
Definition: geom.hpp:83
point2 toCPoint2() const
Definition: geom.hpp:57
const T & x() const
Definition: geom.hpp:131
Definition: geom.hpp:68
const T & column() const
Definition: geom.hpp:32
const T & y() const
Definition: geom.hpp:27
VF EXPORT_SYM point2 create_point2(int x, int y)
void setWidth(const T &width)
Definition: geom.hpp:166
Definition: geom.h:44
VF EXPORT_SYM rectangle create_rectangle(int ulx, int uly, int width, int height)
void setX(const T &x)
Definition: geom.hpp:37
Definition: geom.hpp:8
Definition: geom.h:31
point3 toCPoint3() const
Definition: geom.hpp:108
void setZ(const T &z)
Definition: geom.hpp:103
void setY(const T &y)
Definition: geom.hpp:98
void setHeight(const T &height)
Definition: geom.hpp:171
#define EXPORT_SYM
Definition: export.h:7
void setX(const T &x)
Definition: geom.hpp:93
const T & z() const
Definition: geom.hpp:88
Point3(const T &x, const T &y, const T &z)
Definition: geom.hpp:71
void setColumn(const T &column)
Definition: geom.hpp:42
void setY(const T &y)
Definition: geom.hpp:161
void setRow(const T &row)
Definition: geom.hpp:52
const T & x() const
Definition: geom.hpp:17
const T & x() const
Definition: geom.hpp:78
void setY(const T &y)
Definition: geom.hpp:47
const T & row() const
Definition: geom.hpp:22