ITK/Examples/SimpleOperations/DistanceBetweenPoints: Difference between revisions
From KitwarePublic
Jump to navigationJump to search
Daviddoria (talk | contribs) mNo edit summary |
Daviddoria (talk | contribs) mNo edit summary |
||
Line 33: | Line 33: | ||
cmake_minimum_required(VERSION 2.6) | cmake_minimum_required(VERSION 2.6) | ||
PROJECT( | PROJECT(DistanceBetweenPoints) | ||
FIND_PACKAGE(ITK REQUIRED) | FIND_PACKAGE(ITK REQUIRED) | ||
INCLUDE(${ITK_USE_FILE}) | INCLUDE(${ITK_USE_FILE}) | ||
ADD_EXECUTABLE( | ADD_EXECUTABLE(DistanceBetweenPoints DistanceBetweenPoints.cxx) | ||
TARGET_LINK_LIBRARIES( | TARGET_LINK_LIBRARIES(DistanceBetweenPoints ITKNumerics) | ||
</source> | </source> |
Revision as of 00:58, 12 February 2011
Compute the distance between two 3D points. This can easily be extended to ND by changing the Point template parameter.
DistanceBetweenPoints.cxx
<source lang="cpp">
- include "itkPoint.h"
- include <iostream>
- include <string>
int main(int, char *[]) {
itk::Point<double,3> p0; p0[0] = 0.0; p0[1] = 0.0; p0[2] = 0.0;
itk::Point<double,3> p1; p1[0] = 1.0; p1[1] = 1.0; p1[2] = 1.0;
double dist = p0.EuclideanDistanceTo(p1); std::cout << "Dist: " << dist << std::endl;
return EXIT_SUCCESS;
}
</source>
CMakeLists.txt
<source lang="cmake"> cmake_minimum_required(VERSION 2.6)
PROJECT(DistanceBetweenPoints)
FIND_PACKAGE(ITK REQUIRED) INCLUDE(${ITK_USE_FILE})
ADD_EXECUTABLE(DistanceBetweenPoints DistanceBetweenPoints.cxx) TARGET_LINK_LIBRARIES(DistanceBetweenPoints ITKNumerics)
</source>