math compiles again.
[fail.git] / include / math / Vector4f.h
blobd30ce1e07ffc3bc49f2769b406388142fb1c3e65
1 #ifndef AWFUL_MATH_VECTOR4F_H_
2 #define AWFUL_MATH_VECTOR4F_H_
4 #include "core/core.h"
6 namespace awful { namespace math
8 struct Vector4f
10 Vector4f() :
11 m_x( 0.f ),
12 m_y( 0.f ),
13 m_z( 0.f ),
14 m_w( 0.f )
18 Vector4f( float x_, float y_, float z_, float w_ ) :
19 m_x( x_ ),
20 m_y( y_ ),
21 m_z( z_ ),
22 m_w( w_ )
26 float& x() { return m_x; }
27 float& y() { return m_y; }
28 float& z() { return m_z; }
29 float& w() { return m_w; }
30 const float& x() const { return m_x; }
31 const float& y() const { return m_y; }
32 const float& z() const { return m_z; }
33 const float& w() const { return m_w; }
35 Vector4f operator+( const Vector4f& b ) const
37 return Vector4f( m_x + b.m_x, m_y + b.m_y, m_z + b.m_z, m_w + b.m_w );
40 Vector4f operator-( const Vector4f& b ) const
42 return Vector4f( m_x - b.m_x, m_y - b.m_y, m_z + b.m_z, m_w + b.m_w );
45 const Vector4f& operator+=( const Vector4f& b )
47 m_x += b.m_x;
48 m_y += b.m_y;
49 m_z += b.m_z;
50 m_w += b.m_w;
51 return *this;
54 const Vector4f& operator-=( const Vector4f& b )
56 m_x -= b.m_x;
57 m_y -= b.m_y;
58 m_z -= b.m_z;
59 m_w -= b.m_w;
60 return *this;
63 const Vector4f& operator*=( float f )
65 m_x *= f;
66 m_y *= f;
67 m_z *= f;
68 m_w *= f;
69 return *this;
72 bool operator==( const Vector4f& b ) const
74 // Placeholder, need to do the comparison right
75 return m_x == b.m_x &&
76 m_y == b.m_y &&
77 m_z == b.m_z &&
78 m_w == b.m_w; }
80 bool operator!=( const Vector4f& b ) const
82 return m_x != b.m_x ||
83 m_y != b.m_y ||
84 m_z != b.m_z ||
85 m_w != b.m_w;
88 bool operator<( const Vector4f& b_ ) const
90 // TODO: You fail it (it is floating point comparisons)
91 if( m_x < b_.m_x )
92 return true;
93 if( m_x != b_.m_x )
94 return false;
96 if( m_y < b_.m_y )
97 return true;
98 if( m_y != b_.m_y )
99 return false;
101 if( m_z < b_.m_z )
102 return true;
103 if( m_z != b_.m_z )
104 return false;
106 if( m_w < b_.m_w )
107 return true;
109 return false;
112 private:
113 float m_x;
114 float m_y;
115 float m_z;
116 float m_w;
120 #endif