我想使用 PyVista 相交 2 条线,获取该交点的坐标并绘制结果。
我尝试了以下代码:
import pyvista as pv
line1 = pv.Line(pointa=(-1,0,0), pointb=(2,0,0))
line2 = pv.Line(pointa=(0,-1,0), pointb=(0,2,0))
intersection = line1.intersection(line2)
plotter = pv.Plotter()
plotter.add_mesh(line1)
plotter.add_mesh(line2)
plotter.add_mesh(intersection)
plotter.show()
但问题是我得到了一个由 3 个元素组成的元组,它们是空的并且是
PolyData
:
(PolyData (0x2634b15bee0)
N Cells: 0
N Points: 0
N Strips: 0
X Bounds: 1.000e+299, -1.000e+299
Y Bounds: 1.000e+299, -1.000e+299
Z Bounds: 1.000e+299, -1.000e+299
N Arrays: 0,
PolyData (0x2634b15bac0)
N Cells: 0
N Points: 0
N Strips: 0
X Bounds: 1.000e+299, -1.000e+299
Y Bounds: 1.000e+299, -1.000e+299
Z Bounds: 1.000e+299, -1.000e+299
N Arrays: 0,
PolyData (0x2634b14a100)
N Cells: 0
N Points: 0
N Strips: 0
X Bounds: 1.000e+299, -1.000e+299
Y Bounds: 1.000e+299, -1.000e+299
Z Bounds: 1.000e+299, -1.000e+299
N Arrays: 0)
而且我无法绘制与该行相关的元组:
plotter.add_mesh(intersection)
。这让我觉得没有交集,但那是不可能的。