liballofw
geometry.h
Go to the documentation of this file.
1 #ifndef IV_MATH_GEOMETRY_H
2 #define IV_MATH_GEOMETRY_H
3 
4 #include "vector.h"
5 
6 namespace allofw {
7 
14 
15  template<typename number_t>
16  struct Rectangle2_ {
17  union {
19  struct {
20  number_t x;
21  number_t y;
22  };
23  };
24  union {
26  struct {
27  number_t w;
28  number_t h;
29  };
30  };
31  Rectangle2_() = default;
32  Rectangle2_(const Vector2_<number_t>& position_, const Vector2_<number_t>& size_)
33  : position(position_), size(size_) { }
34  Rectangle2_(number_t w, number_t h)
35  : position(0, 0), size(w, h) { }
36  Rectangle2_(number_t x, number_t y, number_t w, number_t h)
37  : position(x, y), size(w, h) { }
38  };
39 
43  typedef Rectangle2d Rectangle2;
44 
45  template<typename number_t>
46  struct Rectangle3_ {
49  Rectangle3_() = default;
50  Rectangle3_(const Vector3_<number_t>& position_, const Vector3_<number_t>& size_)
51  : position(position_), size(size_) { }
52  Rectangle3_(number_t w, number_t h, number_t d)
53  : position(0, 0, 0), size(w, h, d) { }
54  Rectangle3_(number_t x, number_t y, number_t z, number_t w, number_t h, number_t d)
55  : position(x, y, z), size(w, h, d) { }
56  };
57 
61  typedef Rectangle3d Rectangle3;
62 
63 }
64 
65 #endif
Vector3_< int > Size3i
Definition: geometry.h:9
Vector2_< int > Size2i
Definition: geometry.h:8
Rectangle3_< float > Rectangle3f
Definition: geometry.h:59
Rectangle2d Rectangle2
Definition: geometry.h:43
number_t h
Definition: geometry.h:28
number_t w
Definition: geometry.h:27
Rectangle2_< double > Rectangle2d
Definition: geometry.h:42
Vector3_< double > Size3d
Definition: geometry.h:13
Vector3_< number_t > size
Definition: geometry.h:48
Rectangle2_< float > Rectangle2f
Definition: geometry.h:41
Vector2_< double > Size2d
Definition: geometry.h:12
Definition: allofw.h:12
Rectangle3_< double > Rectangle3d
Definition: geometry.h:60
Vector3_< float > Size3f
Definition: geometry.h:11
Rectangle2_< int > Rectangle2i
Definition: geometry.h:40
Vector2_< number_t > position
Definition: geometry.h:18
Vector2_< number_t > size
Definition: geometry.h:25
Rectangle2_(number_t w, number_t h)
Definition: geometry.h:34
number_t x
Definition: geometry.h:20
Rectangle3_< int > Rectangle3i
Definition: geometry.h:58
Definition: geometry.h:16
Definition: geometry.h:46
Rectangle3_(number_t w, number_t h, number_t d)
Definition: geometry.h:52
Rectangle3_(number_t x, number_t y, number_t z, number_t w, number_t h, number_t d)
Definition: geometry.h:54
Rectangle3_(const Vector3_< number_t > &position_, const Vector3_< number_t > &size_)
Definition: geometry.h:50
Definition: vector.h:63
Vector2_< float > Size2f
Definition: geometry.h:10
Rectangle2_(number_t x, number_t y, number_t w, number_t h)
Definition: geometry.h:36
Vector3_< number_t > position
Definition: geometry.h:47
number_t y
Definition: geometry.h:21
Rectangle2_(const Vector2_< number_t > &position_, const Vector2_< number_t > &size_)
Definition: geometry.h:32
Rectangle3d Rectangle3
Definition: geometry.h:61