-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCT_helix2.py
More file actions
executable file
·50 lines (39 loc) · 1.34 KB
/
CT_helix2.py
File metadata and controls
executable file
·50 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#Parameters
n=10000 #number of sample points
thick=1.0 #slice thickness in mm
w=32 #number of slabs/slices
k=w #number of helix repetitions/loops ??
L_total=k*thick #total length along z axis
HP=21 #hellical pitch (**not sure how to use**)
# Plot a helix along the z-axis
a=1 #radius of each helix circle
#just some thinking on other ways to define b by using HP
#L=N*np.sqrt((a**2)+(b**2)) #arc length
#L_total=k*L+(k-1)*HP #total length of slab
#A=1-(1/(k**2))
#B=(2*(k-1)*HP)/k
#C=(a**2)-((k-1)*HP/(N*k))**2
#b=np.sqrt(((B**2)-4*A*C)/(2*A))
b=L_total/N #since by definition of z it should be that for theta max (N) we should get z max (L_total)
N = k*2*np.pi
theta= np.linspace(0, N, n)
x = a*np.cos(theta)
z = b*theta
y = a*np.sin(theta)
ax.plot(x, y, z, 'b', lw=2)
# An line through the centre of the helix
ax.plot((0,0), (0,0), (np.min(z), np.max(z)), color='k', lw=2)
# sin/cos components of the helix (e.g. electric and magnetic field
# components of a circularly-polarized electromagnetic wave
#ax.plot(x, y, 0, color='r', lw=1, alpha=0.5)
#ax.plot(x, [0]*n, z, color='m', lw=1, alpha=0.5)
plt.xlabel('mm')
plt.ylabel('mm')
# Remove axis planes, ticks and labels
#ax.set_axis_off()
plt.show()