来自点和方向向量的 3D 矢量线
我试图使用线上 P(0) 上的点和方向向量 V 获取 3D 线,
我发现 SymPy 有库可以使用两个点获取线,但不能使用向量和点获取线。有什么方法可以将线作为对象吗?
我的最终动机是找到该线与平面之间的交点。 这是我到目前为止的代码
import numpy as np
from sympy import Plane, Line3D, Point3D #it's not needed here
#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 = # Need to find the line
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}")
I am trying to get a 3D line using a point on the line P(0) and directional vector V
I found SymPy has libraries to obtain lines using two points but not with vector and point. Is there any way that I can get the line as an object?
My final motive is to find the intersection between that line and the plane.
This is my code so far
import numpy as np
from sympy import Plane, Line3D, Point3D #it's not needed here
#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 = # Need to find the line
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}")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仔细浏览图书馆后,我找到了问题的答案。
当您有线(方向比)v0 和向量 p0 上的点时,可以使用以下方法来获取 3D 线向量。
line = Line3D(p0,direction_ratio=v0)
因此完整的代码将是。
After carefully going through the libraries I was able to find out the answer to the question.
When you have Line ( direction ratio) v0 and point on vector p0 the following method can be used to obtain the 3D line vector.
line = Line3D(p0,direction_ratio=v0)
Hence the complete code will be.