untested cleanup
This commit is contained in:
40
generators/refac/K18650.py
Executable file
40
generators/refac/K18650.py
Executable file
@@ -0,0 +1,40 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), '..'))
|
||||
from Command import *
|
||||
from Program import *
|
||||
import math
|
||||
|
||||
class K18650:
|
||||
|
||||
def __init__(self):
|
||||
self.out='IN;SP1;'
|
||||
def hpgl(self,n,di):
|
||||
|
||||
h=40*65
|
||||
da=40*9
|
||||
zbreite=2*math.pi*da/n
|
||||
self.out+=('PU0,'+str(da)+';')
|
||||
for i in range(n):
|
||||
self.out+=('PD'+str(i*zbreite+zbreite/2)+',0;')
|
||||
self.out+=('PD'+str(i*zbreite+zbreite)+','+str(da)+';')
|
||||
|
||||
self.out+=('PU0,'+str(h+da)+';')
|
||||
for i in range(n):
|
||||
self.out+=('PD'+str(i*zbreite+zbreite/2)+','+str(h+2*da)+';')
|
||||
self.out+=('PD'+str(i*zbreite+zbreite)+','+str(h+da)+';')
|
||||
|
||||
self.out+=('PU0,'+str(di)+';')
|
||||
self.out+=('PD'+str(n*zbreite)+','+str(di)+';')
|
||||
self.out+=('PD'+str(n*zbreite)+','+str(2*da+h-di)+';')
|
||||
self.out+=('PD0,'+str(2*da+h-di)+';')
|
||||
self.out+=('PD0,'+str(di)+';')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
16
generators/refac/Kleber.py
Executable file
16
generators/refac/Kleber.py
Executable file
@@ -0,0 +1,16 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), '..'))
|
||||
from Command import *
|
||||
from Program import *
|
||||
|
||||
class Kleber:
|
||||
|
||||
def __init__(self):
|
||||
self.out='IN;SP1;'
|
||||
def hpgl(self,w,h,d):
|
||||
dist=1.05
|
||||
for i in range(w):
|
||||
for j in range(h):
|
||||
self.out+=('PU'+str(dist*(i*2*d+d))+','+str(dist*(j*2*d+d))+';CI'+str(d)+';')
|
||||
|
||||
23
generators/refac/hilbert.py
Executable file
23
generators/refac/hilbert.py
Executable file
@@ -0,0 +1,23 @@
|
||||
import math
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), '..'))
|
||||
from Program import Program
|
||||
from Command import Command
|
||||
|
||||
from hilbertcurve.hilbertcurve import HilbertCurve
|
||||
penthickness=28
|
||||
|
||||
def hilbert( laenge, dicke):
|
||||
tiefe=math.floor(math.log(laenge/dicke,2)+3)
|
||||
print("Tiefe",tiefe)
|
||||
hilbert_curve = HilbertCurve(tiefe , 2)
|
||||
pts = [hilbert_curve.coordinates_from_distance(i) for i in range(4*(2**tiefe))]
|
||||
return pts
|
||||
|
||||
def hilbert_curve(plt):
|
||||
|
||||
list=hilbert(min(plt.winsize[0],plt.winsize[1]),penthickness)
|
||||
return Program([Command('IN'),Command('SP1'),Command('PU',*list[0])]\
|
||||
+[Command('PD',*p) for p in list[1:]]\
|
||||
+[Command('PU')])
|
||||
59
generators/refac/lorenz.py
Normal file
59
generators/refac/lorenz.py
Normal file
@@ -0,0 +1,59 @@
|
||||
import numpy as np
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), '..'))
|
||||
from scipy.integrate import odeint
|
||||
import matplotlib.pyplot as plt
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
from Program import Program
|
||||
from Command import Command
|
||||
|
||||
|
||||
# Lorenz paramters and initial conditions
|
||||
sigma, beta, rho = 10, 2.667, 28
|
||||
u0, v0, w0 = 0, 1, 1.05
|
||||
|
||||
# Maximum time point and total number of time points
|
||||
tmax, n = 100, 10000
|
||||
|
||||
def lorenz(X, t, sigma, beta, rho):
|
||||
"""The Lorenz equations."""
|
||||
u, v, w = X
|
||||
up = -sigma*(u - v)
|
||||
vp = rho*u - v - u*w
|
||||
wp = -beta*w + u*v
|
||||
return up, vp, wp
|
||||
|
||||
# Integrate the Lorenz equations on the time grid t
|
||||
t = np.linspace(0, tmax, n)
|
||||
f = odeint(lorenz, (u0, v0, w0), t, args=(sigma, beta, rho))
|
||||
x, y, z = f.T
|
||||
|
||||
pts=[]
|
||||
|
||||
|
||||
_x = x+y
|
||||
_y=z
|
||||
|
||||
pts=(_x,_y)
|
||||
|
||||
print(pts)
|
||||
plt.plot(_x,_y)
|
||||
# Plot the Lorenz attractor using a Matplotlib 3D projection
|
||||
fig = plt.figure()
|
||||
ax = fig.gca(projection='3d')
|
||||
plt.show()
|
||||
|
||||
|
||||
def lorenz(plt):
|
||||
|
||||
list=hilbert(min(plt.winsize[0],plt.winsize[1]),penthickness)
|
||||
return Program([Command('IN'),Command('SP1'),Command('PU',*list[0])]\
|
||||
+[Command('PD',*p) for p in plt]\
|
||||
+[Command('PU')])
|
||||
|
||||
|
||||
# Remove all the axis clutter, leaving just the curve.
|
||||
#ax.set_axis_off()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user