Forum Discussion
anupambit1797
Aug 23, 2024Iron Contributor
How to draw a cone and it's Frustum in 3D in Excel
Dear Experts, Can some one please help me , with how to draw a Frustum(part of a Cone) in Excel in 3D, Definition as below for Frustum , choose any values for R1,R2,and h. ...
Patrick2788
Oct 10, 2024Silver Contributor
If you have access to Python in Excel, here is some stock code you can play with (r1, r2, and h can even refer to cells in this sheet. For now, all is contained within the code):
from mpl_toolkits.mplot3d import Axes3D
# Parameters for the frustum
r1 = 1 # Radius at the bottom
r2 = 0.5 # Radius at the top
h = 2 # Height
# Create the mesh grid for the frustum
theta = np.linspace(0, 2 * np.pi, 30)
z = np.linspace(0, h, 30)
theta, z = np.meshgrid(theta, z)
x = (r2 + (r1 - r2) * (h - z) / h) * np.cos(theta)
y = (r2 + (r1 - r2) * (h - z) / h) * np.sin(theta)
# Plotting the frustum
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(x, y, z, color='b', alpha=0.6)
# Labels and title
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set_title('Conical Frustum')
plt.show()