51 data[0] = data[1] = data[2] = 0.0;
56 Vec3(
double x,
double y,
double z) {
62 assert(index >= 0 && index < 3);
66 assert(index >= 0 && index < 3);
71 return (data[0] == rhs[0] && data[1] == rhs[1] && data[2] == rhs[2]);
75 return (data[0] != rhs[0] || data[1] != rhs[1] || data[2] != rhs[2]);
87 const Vec3& lhs = *
this;
88 return Vec3(lhs[0] + rhs[0], lhs[1] + rhs[1], lhs[2] + rhs[2]);
100 const Vec3& lhs = *
this;
101 return Vec3(-lhs[0], -lhs[1], -lhs[2]);
106 const Vec3& lhs = *
this;
107 return Vec3(lhs[0] - rhs[0], lhs[1] - rhs[1], lhs[2] - rhs[2]);
119 const Vec3& lhs = *
this;
120 return Vec3(lhs[0]*rhs, lhs[1]*rhs, lhs[2]*rhs);
132 const Vec3& lhs = *
this;
133 return lhs[0]*rhs[0] + lhs[1]*rhs[1] + lhs[2]*rhs[2];
138 return Vec3(data[1]*rhs[2]-data[2]*rhs[1], data[2]*rhs[0]-data[0]*rhs[2], data[0]*rhs[1]-data[1]*rhs[0]);
145 template <
class CHAR,
class TRAITS>
146 std::basic_ostream<CHAR,TRAITS>& operator<<(std::basic_ostream<CHAR,TRAITS>& o,
const Vec3& v) {
147 o<<
'['<<v[0]<<
", "<<v[1]<<
", "<<v[2]<<
']';