import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
定義引數u和v
u = np.linspace(-2, 2, 400)
v = np.linspace(0, 2 * np.pi, 400)
U, V = np.meshgrid(u, v)
根據引數方程計算x, y, z
x = np.sqrt(1 + U2 + V2) * np.cos(V)
y = np.sqrt(1 + U2 + V2) * np.sin(V)
z = U
建立圖形和座標軸
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
繪製曲面
ax.plot_surface(x, y, z, cmap='viridis', edgecolor='none')
設定座標軸標籤
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
顯示圖形
plt.show()
print("學號:3004")
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
定義引數u和v
u = np.linspace(-2, 2, 400)
v = np.linspace(-2, 2, 400)
U, V = np.meshgrid(u, v)
根據方程計算x, y, z
X, Y = U, V
Z = X2 + Y2
建立圖形和座標軸
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
繪製曲面
ax.plot_surface(X, Y, Z, cmap='viridis', edgecolor='none')
設定座標軸標籤
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
顯示圖形
plt.show()
print("學號:3025")