9 #ifndef UTIL_MATH_VECTOR4_H__ 10 #define UTIL_MATH_VECTOR4_H__ 17 #include "base/integral_types.h" 19 template <
typename VType>
class Vector4;
22 template <
typename VType>
class Vector2;
23 template <
typename VType>
class Vector3;
26 template <
typename VType>
33 typedef typename std::conditional<std::is_integral<VType>::value,
34 double, VType>::type FloatType;
38 typedef VType BaseType;
42 Vector4(
const VType x,
const VType y,
const VType z,
const VType w);
54 template <
typename VType2>
57 bool operator==(
const Self& vb)
const;
58 bool operator!=(
const Self& vb)
const;
61 bool aequal(
const Self &vb, FloatType margin)
const;
64 bool operator<(
const Self &vb)
const;
65 bool operator>(
const Self &vb)
const;
66 bool operator<=(
const Self &vb)
const;
67 bool operator>=(
const Self &vb)
const;
70 static int Size() {
return 4; }
72 void Set(
const VType x,
const VType y,
const VType z,
const VType w);
73 Self& operator=(
const Self& vb);
75 Self& operator+=(
const Self& vb);
77 Self& operator-=(
const Self& vb);
79 Self& operator*=(
const VType k);
81 Self& operator/=(
const VType k);
83 Self MulComponents(
const Self &vb)
const;
85 Self DivComponents(
const Self &vb)
const;
87 Self operator+(
const Self &vb)
const;
89 Self operator-(
const Self &vb)
const;
92 VType DotProd(
const Self &vb)
const;
94 Self operator*(
const VType k)
const;
96 Self operator/(
const VType k)
const;
98 VType& operator[](
const int b);
100 VType operator[](
const int b)
const;
102 void x(
const VType &v);
104 void y(
const VType &v);
106 void z(
const VType &v);
108 void w(
const VType &v);
113 const VType* Data()
const;
116 VType Norm2(
void)
const;
120 FloatType Norm(
void)
const;
123 Self Normalize()
const;
154 template <
typename VType>
157 template <
typename ScalarType,
typename VType>
160 template <
typename ScalarType,
typename VType>
163 template <
typename VType>
166 template <
typename VType>
169 template <
typename VType>
170 std::ostream &operator <<(std::ostream &out,
178 #endif // UTIL_MATH_VECTOR4_H__