Link text
1import numpy as np
2import matplotlib.pyplot as plt
3fig = plt.figure()
4ax = plt.axes(projection='3d')
5# Surface ------------------
6# Create the mesh in polar coordinates and compute corresponding Z
7r0 = 5
8r = np.linspace(0, r0, 50)
9p = np.linspace(0, 2*np.pi, 50)
10R, P = np.meshgrid(r, p)
11Z = -R**2 + r0**2
12# Express the mesh in the cartesian system
13X, Y = R*np.cos(P), R*np.sin(P)
14# Plot the surface
15ax.plot_surface(X, Y, Z, linewidth=0, antialiased=False, alpha=0.2)
16# Spiral -------------------
17u = np.arange(0, 29, 0.1)
18x = 0.17*u*np.cos(u)
19y = 0.17*u*np.sin(u)
20z = -(x**2 + y**2) + r0**2
21# Plot spiral
22ax.plot3D(x, y, z, 'r')
23plt.savefig("ex397.png", dpi=100)
24plt.show()

Discover more from Tips and Hints for Aerospace Engineers

Subscribe now to keep reading and get access to the full archive.

Continue reading