Some reorganisation of the abf directories.
[fail.git] / math / Vector2.h
blob2e0beb6a533516c1a88b2a85c193847b68e179e4
1 #ifndef AWFUL_MATH_VECTOR2_H_
2 #define AWFUL_MATH_VECTOR2_H_
4 #include "core/core.h"
6 namespace awful { namespace math
8 struct Vector2
10 Vector2() :
11 m_x( 0.f ),
12 m_y( 0.f )
16 Vector2( float x_, float y_ ) :
17 m_x( x_ ),
18 m_y( y_ )
22 float& x() { return m_x; }
23 float& y() { return m_y; }
24 const float& x() const { return m_x; }
25 const float& y() const { return m_y; }
27 Vector2 operator+( const Vector2& b ) const
29 return Vector2( m_x + b.m_x, m_y + b.m_y );
32 Vector2 operator-( const Vector2& b ) const
34 return Vector2( m_x - b.m_x, m_y - b.m_y );
37 const Vector2& operator+=( const Vector2& b )
39 m_x += b.m_x;
40 m_y += b.m_y;
41 return *this;
44 const Vector2& operator-=( const Vector2& b )
46 m_x -= b.m_x;
47 m_y -= b.m_y;
48 return *this;
51 bool operator==( const Vector2& b ) const
53 return m_x == b.m_x && m_y == b.m_y;
56 private:
57 float m_x;
58 float m_y;
62 #endif