SpatialOps
DoubleVec.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 The University of Utah
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to
6  * deal in the Software without restriction, including without limitation the
7  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8  * sell copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20  * IN THE SOFTWARE.
21  */
22 
26 #ifndef SpatialOps_DoubleVec_h
27 #define SpatialOps_DoubleVec_h
28 
29 #include <spatialops/structured/Numeric3Vec.h>
30 
31 #include <cmath>
32 #include <limits>
33 
34 
35 namespace SpatialOps{
41 
42  // specialize the comparison operators
43 
44  template<>
45  inline bool DoubleVec::operator==( const DoubleVec& v ) const
46  {
47  const static double eps = 2.0*std::numeric_limits<double>::epsilon();
48  return std::abs( v.ijk[0]-ijk[0] ) < eps
49  && std::abs( v.ijk[1]-ijk[1] ) < eps
50  && std::abs( v.ijk[2]-ijk[2] ) < eps;
51  }
52 
53  template<>
54  inline bool DoubleVec::operator!=( const DoubleVec& v ) const{
55  return !( *this == v );
56  }
57 
58 } // namespace SpatialOps
59 
60 
61 #endif /* SpatialOps_DoubleVec_h */
provides a template lightweight class for storing 3d vectors of numbers.
Definition: Numeric3Vec.h:45