00001
00002 #ifndef __vec4d_hpp__
00003 #define __vec4d_hpp__
00004
00005 #include <crbn/basic/scalar.hpp>
00006 #include <crbn/basic/vec3.hpp>
00007
00008 struct vec4 {
00009 union {
00010 struct { float x, y, z, w; };
00011 float data[4];
00012 };
00013
00014 vec4() : x(0.0), y(0.0), z(0.0), w(0.0) {}
00015 vec4( const float& a ) : x(a), y(a), z(a), w(a) {}
00016 vec4( const float& a, const float& b, const float& c, const float&d = 1.0 ) :
00017 x(a), y(b), z(c), w(d)
00018 {}
00019 vec4( const vec3& v, const float&d = 1.0 ) :
00020 x(v.x), y(v.y), z(v.z), w(d)
00021 {}
00022 vec4( const vec4& v ) : x(v.x), y(v.y), z(v.z), w(v.w) {}
00023
00024 operator vec3 () { return vec3(x/w, y/w, z/w); }
00025 };
00026
00027 #endif // __vec4d_hpp__