In [1]:
import matplotlib.pyplot as plt
import numpy as np
# %matplotlib widget
In [2]:
radius = np.linspace(0, 10, 5)
center = np.array([0, 0, 0])
theta = np.linspace(0, 2*np.pi, 100)
radius_grid, theta_grid = np.meshgrid(radius, theta)
Xc = radius_grid*np.cos(theta_grid) + center[0]
Yc = radius_grid*np.sin(theta_grid) + center[1]
Zc = np.sqrt(Xc ** 2 + Yc**2) + center[2]
In [3]:
fig = plt.figure(figsize = (6, 6))
ax = plt.axes(projection='3d', box_aspect = (1, 1, 1))
ax.plot_surface(Xc, Yc, Zc, color = 'blue', alpha=0.5)
# interact(update)
Out[3]:
In [4]:
size = 2
sides = 100
length = 1
radius = np.linspace(0, 10, size)
center = np.array([0, 0, 0])
theta = np.linspace(0, 2*np.pi, sides)
zs = np.linspace(0, length, size)
radius_grid, theta_grid = np.meshgrid(radius, theta)
Xc = radius_grid*np.cos(theta_grid) + center[0]
Yc = radius_grid*np.sin(theta_grid) + center[1]
Zc = np.ones(Yc.shape)*zs + center[2]
x1 = np.outer(radius, np.cos(theta)) + center[0]
y1 = np.outer(radius, np.sin(theta)) + center[1]
z1 = np.zeros(y1.shape) + length + center[2]
In [5]:
fig = plt.figure(figsize = (6, 6))
ax = plt.axes(projection='3d', box_aspect = (1, 1, 1))
ax.plot_surface(Xc, Yc, Zc, color = 'blue', alpha=0.5)
ax.plot_surface(x1, y1, z1, color = 'red', alpha = 0.5)
Out[5]:
In [ ]:
In [6]:
radius = 3
length = 5
sides = 100
theta = np.linspace(0, 2*np.pi, sides + 1)
center = np.array([0, 0, 0])
In [7]:
fig = plt.figure(figsize = (6, 6))
ax = plt.axes(projection='3d', box_aspect = (1, 1, 1))
ax.plot(*center, color = 'red', marker = 'o')
ax.text(center[0] + 0.25, center[1] + 0.25, center[2] + 0.25, s = 'O', fontsize = 12)
for i in range(len(theta) - 1):
x1 = np.array([
[0, radius*np.cos(theta[i])],
[0, radius*np.cos(theta[i + 1])]
])
y1 = np.array([
[0, radius*np.sin(theta[i])],
[0, radius*np.sin(theta[i + 1])]
])
z1 = np.zeros(y1.shape) + length
zc = np.array([
[0, length],
[0, length]
])
ax.plot_surface(x1, y1, zc, color = 'blue', alpha = 0.5)
ax.plot_surface(x1, y1, z1, color = 'red', alpha = 0.5)
# ax.plot_surface(Xc, Yc, Zc, color = 'blue', alpha = 0.5)
ax.set_xlim(-5, 5)
ax.set_ylim(-5, 5)
ax.set_zlim(0, 5)
Out[7]:
In [ ]:
In [ ]:
In [ ]: