简体   繁体   中英

Projecting a Curve in 3D Space

I am plotting a curve in a 3D space using three vectors X, Y and Z.

How can I draw the projections of the curve onto the planes 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.

For example, to plot on th XoY plane, you'd neglect the Z component and use

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()

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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