Add is_zero for vector magnitude

This commit is contained in:
Danny Robson 2012-05-03 15:56:56 +10:00
parent f8ad4c0c04
commit 68adb32472
2 changed files with 10 additions and 0 deletions

View File

@ -184,6 +184,14 @@ vector::cartesian_to_spherical (const vector &c) {
} }
bool
vector::is_zero (void) const {
return almost_equal (x, 0.0) &&
almost_equal (y, 0.0) &&
almost_equal (z, 0.0);
}
void void
vector::sanity (void) const { vector::sanity (void) const {
check_soft (!std::isnan (x)); check_soft (!std::isnan (x));

View File

@ -56,6 +56,8 @@ namespace util {
static vector spherical_to_cartesian (const vector &); static vector spherical_to_cartesian (const vector &);
static vector cartesian_to_spherical (const vector &); static vector cartesian_to_spherical (const vector &);
bool is_zero (void) const;
void sanity (void) const; void sanity (void) const;
}; };