9 #ifndef UTIL_MATH_VECTOR3_H__ 10 #define UTIL_MATH_VECTOR3_H__ 13 #include <type_traits> 17 #include "base/integral_types.h" 19 template <
typename VType>
class Vector3;
22 template <
typename VType>
class Vector2;
23 template <
typename VType>
class Vector4;
29 template <
typename VType>
37 typedef typename std::conditional<std::is_integral<VType>::value,
38 double, VType>::type FloatType;
42 typedef VType BaseType;
46 Vector3(
const VType x,
const VType y,
const VType z);
55 template <
typename VType2>
58 bool operator==(
const Self& vb)
const;
59 bool operator!=(
const Self& vb)
const;
62 bool aequal(
const Self &vb, FloatType margin)
const;
65 bool operator<(
const Self &vb)
const;
66 bool operator>(
const Self &vb)
const;
67 bool operator<=(
const Self &vb)
const;
68 bool operator>=(
const Self &vb)
const;
71 static int Size() {
return 3; }
73 void Set(
const VType x,
const VType y,
const VType z);
74 Self& operator=(
const Self& vb);
76 Self& operator+=(
const Self &vb);
78 Self& operator-=(
const Self &vb);
80 Self& operator*=(
const VType k);
82 Self& operator/=(
const VType k);
84 Self MulComponents(
const Self &vb)
const;
86 Self DivComponents(
const Self &vb)
const;
88 Self operator+(
const Self &vb)
const;
90 Self operator-(
const Self &vb)
const;
93 VType DotProd(
const Self &vb)
const;
95 Self operator*(
const VType k)
const;
97 Self operator/(
const VType k)
const;
100 Self CrossProd(
const Self& vb)
const;
102 VType& operator[](
const int b);
104 VType operator[](
const int b)
const;
106 void x(
const VType &v);
108 void y(
const VType &v);
110 void z(
const VType &v);
115 const VType* Data()
const;
118 VType Norm2(
void)
const;
122 FloatType Norm(
void)
const;
125 Self Normalize()
const;
129 int LargestAbsComponent()
const;
133 FloatType Angle(
const Self &va)
const;
164 template <
typename VType>
167 template <
typename ScalarType,
typename VType>
170 template <
typename ScalarType,
typename VType>
173 template <
typename VType>
176 template <
typename VType>
179 template <
typename VType>
180 std::ostream &operator <<(std::ostream &out,
189 #endif // UTIL_MATH_VECTOR3_H__