From 00bf6f18ff5a9ee7f8a44870c36edaf5070fe681 Mon Sep 17 00:00:00 2001 From: aferrick1 <72628586+aferrick1@users.noreply.github.com> Date: Fri, 9 Oct 2020 16:18:38 -0400 Subject: [PATCH 1/2] Rotor/Stator generator code simplification Automatically creates epi/hypo intervals based on number of lobes for the rotor stator. Just wanted to practice my maths and coding :^) --- Python/moineau_epihypocycloidal.py | 88 ++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Python/moineau_epihypocycloidal.py diff --git a/Python/moineau_epihypocycloidal.py b/Python/moineau_epihypocycloidal.py new file mode 100644 index 0000000..11bfcb6 --- /dev/null +++ b/Python/moineau_epihypocycloidal.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- +""" +Created on Wed Oct 7 16:53:38 2020 + +@author: AdamFerrick + +Requires ezdxf instead of sdxf. +""" + +import ezdxf +#import matplotlib.pyplot as plt +import math +import numpy as np + + +# Create a new DXF document. +doc = ezdxf.new(dxfversion='R2018') + + +# Create new table entries (layers, linetypes, text styles, ...). +doc.layers.new(name='TEXT', dxfattribs={'color': 2}) +doc.layers.new(name='ROTOR',dxfattribs={'color': 1}) +doc.layers.new(name='STATOR',dxfattribs={'color': 5}) + +msp = doc.modelspace() + +''' +Functions for epicycloid +''' + +def xepi(t,lobes): + r = 1 + R = lobes*2 + return (R+r)*math.cos(t)-r*math.cos((R+r)/r*t) + +def yepi(t,lobes): + r = 1 + R = lobes*2 + return (R+r)*math.sin(t)-r*math.sin((R+r)/r*t) + +''' +Functions hypocycloid +''' + +def xhypo(t,lobes): + r = 1 + R = lobes*2 + return (R-r)*math.cos(t)+r*math.cos((R-r)/r*t) + +def yhypo(t,lobes): + r = 1 + R = lobes*2 + return (R-r)*math.sin(t)-r*math.sin((R-r)/r*t) + +''' +Moineau curve generator function. Takes input of angle and number of lobes you want for your rotor/stator +''' + +def epihypo(t,lobes): + nums = np.arange(0,2*math.pi,2*math.pi/(2*lobes)) + #Numpy list of epi/hypo intervals i.e. 0 to pi/3, pi/3 to 2pi/3 etc, divided based on number of lobes + pos = list(t Date: Sat, 10 Oct 2020 14:41:01 -0400 Subject: [PATCH 2/2] Update moineau_epihypocycloidal.py --- Python/moineau_epihypocycloidal.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Python/moineau_epihypocycloidal.py b/Python/moineau_epihypocycloidal.py index 11bfcb6..ff0d3d5 100644 --- a/Python/moineau_epihypocycloidal.py +++ b/Python/moineau_epihypocycloidal.py @@ -85,4 +85,5 @@ def dxfgen(x,y,layer): #Run this in console to make a dxf of your generated roto for i in range(step+1): x.append(epihypo(q*i,lobes)[0]) y.append(epihypo(q*i,lobes)[1]) -#plt.scatter(x,y) \ No newline at end of file +#plt.scatter(x,y) +#plt.show()