import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
from numpy import sin, cos
import pandas as pd
fig = plt.figure()
# preferred method for creating 3d axis
ax = fig.add_subplot(111, projection='3d')
r = 10
c = 2
t = np.linspace(0, 20, 400)
# parametric equation of a helix
x = r*cos(t)
y = r*sin(t)
z = c*t
ax.scatter(x, y, z, zdir='z', lw=2, c='g', marker='.')
plt.savefig("ex394.png", dpi=100)
plt.show()
df = pd.DataFrame(x,columns=['x'])
df = df.assign(y=y)
df = df.assign(z=z)
df.to_csv('coordinates.txt', header=None, index=None, sep='\t', mode='w')

Discover more from Tips and Hints for Aerospace Engineers

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

Continue reading