判断线段与面是否相交

  // Inputs
  double p1[3] = {0.1, 0, -1.0};
  double p2[3] = {0.1, 0, 1.0};
  double tolerance = 0.001;
  // Outputs
  double t; // Parametric coordinate of intersection (0 (corresponding to p1) to 1 (corresponding to p2))
  double x[3]; // The coordinate of the intersection
  double pcoords[3];
  int subId;

  vtkIdType iD = polygon->IntersectWithLine(p1, p2, tolerance, t, x, pcoords, subId);

  std::cout << "intersected? " << iD << std::endl;
  std::cout << "intersection: " << x[0] << " " << x[1] << " " << x[2] << std::endl;

demo:https://lorensen.github.io/VTKExamples/site/Cxx/GeometricObjects/PolygonIntersection/

猜你喜欢

转载自blog.csdn.net/yuxing55555/article/details/80475913