VtkMath.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2016 Imperial College London
5  * Copyright 2016 Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef MIRTK_VtkMath_H
21 #define MIRTK_VtkMath_H
22 
23 #include "vtkConfigure.h" // VTK version macros
24 
25 
26 // See http://www.paraview.org/Bug/view.php?id=14164
27 #if VTK_MAJOR_VERSION == 6 && VTK_MINOR_VERSION == 0 && VTK_PATCH_VERSION == 0
28 # define isnan ::std::isnan
29 # define isinf ::std::isinf
30 # define isfinite ::std::isfinite
31 #endif
32 
33 #include <vtkMath.h> // DO NOT use double quotes which would cause endless recursive
34  // include of this file when filesystem is not case sensitive!
35 
36 #if VTK_MAJOR_VERSION == 6 && VTK_MINOR_VERSION == 0 && VTK_PATCH_VERSION == 0
37 # undef isnan
38 # undef isinf
39 # undef isfinite
40 #endif
41 
42 namespace mirtk { namespace vtkmath {
43 
44 
45 // -----------------------------------------------------------------------------
46 /// Subtract two 2D vectors
47 inline void Subtract2D(const double a[2], const double b[2], double c[2])
48 {
49  c[0] = a[0] - b[0];
50  c[1] = a[1] - b[1];
51 }
52 
53 // -----------------------------------------------------------------------------
54 /// Compute squared distance between 2D points
55 inline double Distance2BetweenPoints2D(const double a[2], const double b[2])
56 {
57  const double dx = b[0] - a[0];
58  const double dy = b[1] - a[1];
59  return dx * dx + dy * dy;
60 }
61 
62 
63 } } // namespace mirtk::vtkmath
64 
65 
66 #endif // MIRTK_VtkMath_H
Definition: IOConfig.h:41