From 7429c61a79b267b1fb97f9fc80140253eb8a1759 Mon Sep 17 00:00:00 2001 From: looooo Date: Tue, 7 Apr 2020 15:03:46 +0200 Subject: [PATCH] add pygears/profile --- pygears/involute_tooth.py | 2 +- pygears/profile.py | 39 +++++++++++++++++++++++++++++++++++++++ setup.py | 3 ++- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 pygears/profile.py diff --git a/pygears/involute_tooth.py b/pygears/involute_tooth.py index 96cc735..0351274 100644 --- a/pygears/involute_tooth.py +++ b/pygears/involute_tooth.py @@ -212,7 +212,7 @@ class InvoluteRack(object): teeth[-1][0][0] = 0 teeth[-1][0][1] += a / 2 - teeth = [v for t in teeth for v in t] # flattening + teeth = np.array([v for t in teeth for v in t]) # flattening if self.add_endings: ext1 = teeth[0] + np.array([0., a + b - pitch / 2]) ext2 = teeth[-1] - np.array([0., a + b - pitch / 2]) diff --git a/pygears/profile.py b/pygears/profile.py new file mode 100644 index 0000000..d110e06 --- /dev/null +++ b/pygears/profile.py @@ -0,0 +1,39 @@ +import numpy as np +from .involute_tooth import InvoluteTooth, InvoluteRack +from .bevel_tooth import BevelTooth +from .cycloide_tooth import CycloideTooth +from ._functions import rotation, rotation3D + + +class _GearProfile(object): + rot3D = False + def profile(self, num=10): + tooth = self.points(num=num) + tooth = [list(point) for wire in tooth for point in wire] + if self.rot3D: + rot = rotation3D( np.pi * 2 / self.z) + else: + rot = rotation(- np.pi * 2 / self.z) + profile = tooth + for i in range(self.z): + tooth = rot(tooth).tolist() + profile = profile + tooth + return np.array(profile) + +class InvoluteProfile(InvoluteTooth, _GearProfile): + pass + +class CycloideProfile(CycloideTooth, _GearProfile): + pass + +class BevelProfile(BevelTooth, _GearProfile): + rot3D = True + pass + +class InvoluteRackProfile(InvoluteRack): + def profile(self): + return self.points() + + + + diff --git a/setup.py b/setup.py index 18d6ef3..b106108 100644 --- a/setup.py +++ b/setup.py @@ -11,4 +11,5 @@ setup(name='freecad.gears', url="https://github.com/looooo/FCGear", description="gears for FreeCAD", install_requires=['numpy'], -include_package_data=True) + include_package_data=True +)