简体   繁体   English

绘制 A 3D 双曲面

[英]Plotting A 3D Hyperboloid

My teacher in class gave this formula −0.3 **2−0.3 **2+ **2=1.我在 class 的老师给出了这个公式 -0.3 **2−0.3 **2+ **2=1。

and showed its 3d graphic in class seen below.并在下面的 class 中展示了其 3d 图形。 I just perform a half graphic, and I have no idea how to plot the rest graphic.我只是执行了半个图形,我不知道如何 plot rest 图形。 The following code from matplotlib import cm import matplotlib.pyplot as plt import numpy as np以下代码来自 matplotlib import cm import matplotlib.pyplot as plt import numpy as np

X = np.linspace(-5, 5, 100)
Y = np.linspace(-5, 5, 100)
X, Y = np.meshgrid(X, Y)

Z = np.sqrt(0.3*(X **2 + Y **2) + 1)
ax = plt.gca(projection='3d')
plot1 = ax.plot_surface(X, Y, Z, cmap='jet', alpha=0.6, vmin=-5, vmax=5)
plt.colorbar(plot1)

plt.show()

enter image description here在此处输入图像描述

This is because when you change the expression about the z-axis, the result is positive no matter what value you substitute for x,y because of the square.这是因为当您更改有关 z 轴的表达式时,无论您用什么值替换 x,y,结果都是正的,因为是正方形。 Just adding -Z values is a simple solution.只需添加 -Z 值是一个简单的解决方案。

ax.plot_surface(X, Y, Z, cmap='jet', alpha=0.6, vmin=-5, vmax=5)
ax.plot_surface(X, Y, -Z, cmap='jet', alpha=0.6, vmin=-5, vmax=5)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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