我这样做了,但它不是 100% 正确的。在 x,y=0 处,函数应该是 =w0*np.sqrt(1)=w0=1.701。事实并非如此。
import numpy as np
from numpy import pi, cos, sin, sqrt, outer, ones
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(111, projection='3d')
u = np.linspace(0, 2 * pi, 100)
v = np.linspace(0, pi, 100)
one_v = ones(100)
w0=1.701
lamb=0.90846
d_in1=45
foc1=38.35
zR=np.pi*w0**(2)/(lamb)
x=np.linspace(-30,30,100)
def f(x):
return w0*np.sqrt(1+(x/zR)**(2))
# Hyperboloid
v = 2*v/pi - 1
x3 = 6 * outer(cos(u), sqrt(1 + v**2))
y3 = 6 * outer(sin(u), sqrt(1 + v**2))
z3 = f(x)
ax.plot_surface(x3, y3, z3, rstride=5, cstride=5, cmap='Spectral',
linewidth=0.5)
# Fix aspect ratio and axes details
#ax.set_xlim(-13, 13)
#ax.set_ylim(-13, 13)
#ax.set_zlim(-13, 13)
#ax.view_init(elev=35, azim=-45)
#plt.axis('off')
plt.savefig('Gaussian curvature.svg', transparent=True)
plt.show()