1 #ifndef BLUB_MATH_VECTOR3TEMPLATE_HPP
2 #define BLUB_MATH_VECTOR3TEMPLATE_HPP
4 #include "blub/math/math.hpp"
5 #include "blub/math/vector3.hpp"
6 #include "blub/serialization/access.hpp"
7 #include "blub/serialization/nameValuePair.hpp"
13 template <
typename valueType, valueType valueDefault>
17 typedef valueType t_valueType;
18 typedef vector3Template<t_valueType, valueDefault> t_thisClass;
31 vector3Template(
const valueType& x_,
const valueType& y_,
const valueType& z_)
39 vector3Template(
const t_thisClass& copy)
47 vector3Template(
const valueType& val)
55 vector3Template(
const vector3& cast)
63 bool operator == (
const t_thisClass& other)
const
65 return other.x == x && other.y == y && other.z == z;
68 bool operator != (
const t_thisClass& other)
const
70 return other.x != x && other.y != y && other.z != z;
73 bool operator <= (
const t_thisClass& other)
const
75 return x <= other.x && y <= other.y && z <= other.z;
78 bool operator < (
const t_thisClass& other)
const
80 return x < other.x && y < other.y && z < other.z;
83 bool operator >= (
const t_thisClass& other)
const
85 return x >= other.x && y >= other.y && z >= other.z;
88 bool operator > (
const t_thisClass& other)
const
90 return x > other.x && y > other.y && z > other.z;
93 t_thisClass operator * (
const t_thisClass& other)
const
95 return t_thisClass(other.x*x, other.y*y, other.z*z);
98 t_thisClass operator * (
const int32& other)
const
100 return t_thisClass(other*x, other*y, other*z);
103 t_thisClass operator + (
const t_thisClass& other)
const
105 return t_thisClass(other.x+x, other.y+y, other.z+z);
108 t_thisClass operator - (
const t_thisClass& other)
const
110 return t_thisClass(x-other.x, y-other.y, z-other.z);
113 t_thisClass operator - (
void)
const
115 return t_thisClass(-x, -y, -z);
118 t_thisClass operator / (
const t_thisClass& other)
const
120 return t_thisClass(x/other.x, y/other.y, z/other.z);
123 t_thisClass operator / (
const t_valueType& other)
const
125 return t_thisClass(x/other, y/other, z/other);
128 t_thisClass operator % (
const t_thisClass& other)
const
130 return t_thisClass(x % other.x, y % other.y, z % other.z);
133 t_thisClass operator % (
const t_valueType& other)
const
135 return t_thisClass(x % other, y % other, z % other);
138 valueType operator [] (
const blub::uint8& index)
const
141 return *((&x) + index);
144 t_thisClass getMinimum(
const t_thisClass& other)
146 return t_thisClass(math::min(other.x, x), math::min(other.y, y), math::min(other.z, z));
149 t_thisClass getMaximum(
const t_thisClass& other)
151 return t_thisClass(math::max(other.x, x), math::max(other.y, y), math::max(other.z, z));
156 BLUB_SERIALIZATION_ACCESS
158 template <
class formatType>
159 void serialize(formatType & readWrite,
const uint32& version)
163 readWrite & BLUB_SERIALIZATION_NAMEVALUEPAIR(x);
164 readWrite & BLUB_SERIALIZATION_NAMEVALUEPAIR(y);
165 readWrite & BLUB_SERIALIZATION_NAMEVALUEPAIR(z);
176 template <
typename valueType, valueType valueDefault>
177 std::ostream &operator<<(std::ostream &os, const vector3Template<valueType, valueDefault>& toCast)
179 return os <<
"(" << toCast.x <<
"," << toCast.y <<
"," << toCast.z <<
")";
182 template <
typename valueType, valueType valueDefault>
183 std::size_t hash_value(
const vector3Template<valueType, valueDefault>& value)
185 std::size_t result(value.x);
186 boost::hash_combine(result, value.y);
187 boost::hash_combine(result, value.z);
196 #endif // BLUB_MATH_VECTOR3TEMPLATE_HPP
Definition: deadlineTimer.hpp:10