简体   繁体   English

在3D空间中投影曲线

[英]Projecting a Curve in 3D Space

I am plotting a curve in a 3D space using three vectors X, Y and Z. 我正在使用三个向量X,Y和Z在3D空间中绘制曲线。

How can I draw the projections of the curve onto the planes XOY, XOZ, YOZ? 如何将曲线的投影绘制到XOY,XOZ,YOZ平面上?

import matplotlib.pylab as plt
from mpl_toolkits.mplot3d.axes3d import Axes3D
fig = plt.figure()
ax = Axes3D(fig)
X = [4, 2, 7, 4]
Y = [7, 4, 9, 6]
Z = [9, 6, 10, 3]
ax.plot(X, Y, Z, 'b-', linewidth=4, label='parametric curve')
plt.show()

Since you are simply plotting points in 3D space (meaning that even though you call it parametric, your curve is not parametric), you get the "projection" by just setting the respective dimension to zero. 由于您只是在3D空间中绘制点(这意味着即使您称其为参数化的,但曲线也不是参数化的),因此只需将各个尺寸设置为零即可获得“投影”。

For example, to plot on th XoY plane, you'd neglect the Z component and use 例如,要在XoY平面上绘图,您可以忽略Z分量并使用

zeros = [0,0,0,0]
plt.plot(X,Y,zeros)

In total this would look like 总的来说,这看起来像

import matplotlib.pylab as plt
from mpl_toolkits.mplot3d.axes3d import Axes3D
fig = plt.figure()
ax = Axes3D(fig)
X = [4, 2, 7, 4]
Y = [7, 4, 9, 6]
Z = [9, 6, 10, 3]
ax.plot(X, Y, Z, 'b-', linewidth=4, label='curve')

null = [0]*len(Z)
ax.plot(null, Y, Z)
ax.plot(X,null, Z)
ax.plot(X, Y, null)

plt.show()

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM