ITK/Examples/SimpleOperations/DistanceBetweenPoints
From KitwarePublic
Compute the distance between two 3D points. This can easily be extended to ND by changing the Point template parameter.
DistanceBetweenPoints.cxx
#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; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.8) project(DistanceBetweenPoints) find_package(ITK REQUIRED) include(${ITK_USE_FILE}) add_executable(DistanceBetweenPoints DistanceBetweenPoints.cxx) if( "${ITK_VERSION_MAJOR}" LESS 4 ) target_link_libraries(DistanceBetweenPoints ITKReview ${ITK_LIBRARIES}) else( "${ITK_VERSION_MAJOR}" LESS 4 ) target_link_libraries(DistanceBetweenPoints ${ITK_LIBRARIES}) endif( "${ITK_VERSION_MAJOR}" LESS 4 )