来自点和方向向量的 3D 矢量线

发布于 2025-01-09 21:06:13 字数 728 浏览 1 评论 0原文

我试图使用线上 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一个人的旅程 2025-01-16 21:06:13

仔细浏览图书馆后,我找到了问题的答案。

当您有线(方向比)v0 和向量 p0 上的点时,可以使用以下方法来获取 3D 线向量。

line = Line3D(p0,direction_ratio=v0)
因此完整的代码将是。


from sympy import Plane, Line3D, Point3D 

#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}")```

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.


from sympy import Plane, Line3D, Point3D 

#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}")```

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文