import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# Create figure and 3D axis
fig = plt.figure(figsize=(8, 6))
ax = fig.add_subplot(111, projection='3d')
# Cone parameters
radius = 1.0 # Base radius
height = 2.0 # Height of cone
resolution = 100 # Number of points in circumference and height
# Create the angular and height parameters
theta = np.linspace(0, 2 * np.pi, resolution)
h = np.linspace(0, height, resolution)
# Create the cone surface
# The radius decreases linearly from base to apex
theta_grid, h_grid = np.meshgrid(theta, h)
x = radius * (1 - h_grid/height) * np.cos(theta_grid)
y = radius * (1 - h_grid/height) * np.sin(theta_grid)
z = h_grid
# Plot the cone surface
ax.plot_surface(x, y, z, color='royalblue', alpha=0.8)
# Add labels and title
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
ax.set_title('3D Cone Visualization', pad=20)
# Set equal aspect ratio for better visualization
ax.set_box_aspect([1, 1, 1]) # Equal aspect ratio
# Show the plot
plt.tight_layout()
plt.show()
aW1wb3J0IG51bXB5IGFzIG5wCmltcG9ydCBtYXRwbG90bGliLnB5cGxvdCBhcyBwbHQKZnJvbSBtcGxfdG9vbGtpdHMubXBsb3QzZCBpbXBvcnQgQXhlczNECgojIENyZWF0ZSBmaWd1cmUgYW5kIDNEIGF4aXMKZmlnID0gcGx0LmZpZ3VyZShmaWdzaXplPSg4LCA2KSkKYXggPSBmaWcuYWRkX3N1YnBsb3QoMTExLCBwcm9qZWN0aW9uPSczZCcpCgojIENvbmUgcGFyYW1ldGVycwpyYWRpdXMgPSAxLjAgICAjIEJhc2UgcmFkaXVzCmhlaWdodCA9IDIuMCAgICMgSGVpZ2h0IG9mIGNvbmUKcmVzb2x1dGlvbiA9IDEwMCAgIyBOdW1iZXIgb2YgcG9pbnRzIGluIGNpcmN1bWZlcmVuY2UgYW5kIGhlaWdodAoKIyBDcmVhdGUgdGhlIGFuZ3VsYXIgYW5kIGhlaWdodCBwYXJhbWV0ZXJzCnRoZXRhID0gbnAubGluc3B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