VTK/Examples/Cxx/SimpleOperations/ProjectPointPlane
From KitwarePublic
This example projects a point onto a plane. To use this example, you must have the CVSHEAD version of VTK (as of 2/2/2010).
ProjectPointPlane.cxx
#include <vtkSmartPointer.h> #include <vtkPlane.h> int main(int, char *[]) { vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::New(); plane->SetOrigin(0.0, 0.0, 0.0); plane->SetNormal(0.0, 0.0, 1.0); double p[3] = {23.1, 54.6, 9.2}; double origin[3] = {0.0, 0.0, 0.0}; double normal[3] = {0.0, 0.0, 1.0}; double projected[3]; plane->ProjectPoint(p, origin, normal, projected); std::cout << "Projected: " << projected[0] << " " << projected[1] << " " << projected[2] << std::endl; return EXIT_SUCCESS; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.8) PROJECT(ProjectPointPlane) find_package(VTK REQUIRED) include(${VTK_USE_FILE}) if (APPLE) add_executable(ProjectPointPlane MACOSX_BUNDLE ProjectPointPlane.cxx) else() add_executable(ProjectPointPlane ProjectPointPlane.cxx) endif() if(VTK_LIBRARIES) target_link_libraries(ProjectPointPlane ${VTK_LIBRARIES}) else() target_link_libraries(ProjectPointPlane vtkHybrid vtkHybrid) endif()