3D线向量和平面交点

3D line vector and plane Intersection

我有一个 3D 线向量ai + bj + ck 的形式给出。我正在使用下面给出的 3 个点计算 平面

from sympy import Point3D, Plane
def def_surface (a1,a2,a3):
    Flat1 = Plane(Point3D(a1), Point3D(a2), Point3D(a3)) 
    S = Flat1.equation()
    return S

我想找到直线与平面相交的点P(x,y,z)

P.S。 找到直线上的点后是否必须创建参数方程? 或者有什么简单的方法可以直接到交点吗?

假设我在直线 S = (d,e,f) 上有一个点,有没有简单的方法找到交点?

使用 sympy 时,重要的是要保存整个对象以找到交点,而不仅仅是方程。

假设你有方向和直线上的一个点,你可以这样做:


from sympy import Plane, Line3D #Point3D it's not needed here

#plane Points
a1 = [1,0,0]
a2 = [0,1,0]
a3 = [0,0,1]
#line Points
p0 = [0,0,0] #point in line
v0 = [1,1,1] #line direction as vector

#create plane and line
plane = Plane(a1,a2,a3)
line = Line3D(p0,direction_ratio=v0)

print(f"plane equation: {plane.equation()}")
print(f"line equation: {line.equation()}")

#find intersection:

intr = plane.intersection(line)

print(f"intersection: {intr}")

输出

plane equation: x + y + z - 1
line equation: (-x + y, -x + z)
intersection: [Point3D(1/3, 1/3, 1/3)]

@Ulises Bussi 的回答应该略有调整。 Line = Line3D(p0,v0) 没有给出我们需要的输出。当 p0 是一个点,v0 是一个向量时,正确的直线方程将给出,

line = Line3D(p0,direction_ratio=v0)

因此正确的做法是:


#plane Points
a1 = Point3D (-5,15,-5)
a2 = Point3D (5,15,-5)
a3 = Point3D (5,15,5)
#line Points
p0 = Point3D (0,3,1) #point in line
v0 = [0, 1 ,1] #line direction as vector

#create plane and line
plane = Plane(a1,a2,a3)

line = Line3D(p0,direction_ratio=v0)


print(f"plane equation: {plane.equation()}")
print(f"line equation: {line.equation()}")

#find intersection:

intr = plane.intersection(line)

intersection =np.array(intr[0],dtype=float)
print(f"intersection: {intersection}")