示例包含:
- 求两点之间的距离
- 求点到线之间的距离
- 把一个点投射到平面上
- 透视坐标转化 perspective transform 和 transform
1. 求两点之间的距离
#include <vtkMath.h>
#include <QDebug>
int main(int, char *[])
{
double p1[3] = {0.0, 0.0, 0.0};
double p2[3] = {1.0, 1.0, 1.0};
double squaredDistance = vtkMath::Distance2BetweenPoints(p1, p2); //两点之间的距离的平方
double distance = sqrt(squaredDistance);
qDebug() << "squaredDistance : " << squaredDistance; //3
qDebug() << "distance : " << distance; //1.73205
return EXIT_SUCCESS;
}
2.求点到线之间的距离
#include <vtkLine.h>
#include <vtkPoints.h>
#include <QDebug>
int main(int, char *[])
{
double lineP0[3] = {0.0, 0.0, 0.0};
double lineP1[3] = {2.