lgtm cleaning
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
# script for bevel-gear animation
|
||||
|
||||
from PySide import QtGui, QtCore
|
||||
from PySide import QtCore
|
||||
import FreeCAD as app
|
||||
import FreeCADGui as gui
|
||||
import numpy as np
|
||||
import imageio
|
||||
|
||||
doc = app.ActiveDocument
|
||||
g2 = doc.Common
|
||||
|
||||
@@ -32,8 +32,8 @@ from pygears._functions import rotation3D, rotation
|
||||
import FreeCAD as App
|
||||
import Part
|
||||
from Part import BSplineCurve, Shape, Wire, Face, makePolygon, \
|
||||
BRepOffsetAPI, Shell, makeLoft, Solid, Line, BSplineSurface, makeCompound,\
|
||||
show, makePolygon, makeHelix, makeShell, makeSolid
|
||||
makeLoft, Line, BSplineSurface, \
|
||||
makePolygon, makeHelix, makeShell, makeSolid
|
||||
|
||||
|
||||
__all__ = ["InvoluteGear",
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
|
||||
from __future__ import division
|
||||
from numpy import sin, cos, dot, array, ndarray, vstack, transpose, sqrt
|
||||
from numpy.linalg import solve
|
||||
import numpy as np
|
||||
from numpy.linalg import solve, norm
|
||||
|
||||
|
||||
def reflection(pressure_angle):
|
||||
@@ -109,7 +108,6 @@ def trim(p1, p2, p3, p4):
|
||||
return(a1 + g * (a2 - a1))
|
||||
else:
|
||||
return(False)
|
||||
return(False)
|
||||
|
||||
|
||||
def trimfunc(l1, l2):
|
||||
@@ -137,9 +135,9 @@ def trimfunc(l1, l2):
|
||||
return(False)
|
||||
|
||||
|
||||
def norm(vec1, vec2):
|
||||
def diff_norm(vec1, vec2):
|
||||
vec = array(vec2) - array(vec1)
|
||||
return np.linalg.norm(vec)
|
||||
return norm(vec)
|
||||
|
||||
|
||||
def nearestpts(evolv, underc):
|
||||
@@ -166,7 +164,7 @@ def intersection_line_circle(p1, p2, r):
|
||||
"""return the intersection point of a line from p1 to p2 and a sphere of radius 1 and
|
||||
midpoint 0,0,0"""
|
||||
d = p2 - p1
|
||||
d /= np.linalg.norm(d)
|
||||
d /= norm(d)
|
||||
p_half = d.dot(p1)
|
||||
q = p1.dot(p1) - r ** 2
|
||||
t = -p_half + sqrt(p_half ** 2 - q)
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
from __future__ import division
|
||||
from __future__ import division
|
||||
from numpy import cos, sin, tan, arccos, arctan, pi, array, linspace, transpose, vstack, sqrt
|
||||
import numpy as np
|
||||
from ._functions import rotation3D, reflection3D, intersection_line_circle
|
||||
|
||||
|
||||
@@ -61,27 +60,6 @@ class BevelTooth(object):
|
||||
self.z_f = cos(self.pitch_angle - sin(pitch_angle) * 2 / self.z)
|
||||
self.add_foot = True
|
||||
|
||||
# if self.involute_start_radius < self.r_f:
|
||||
# self.add_foot = False
|
||||
# self.involute_start = -arccos(
|
||||
# sqrt((42 + 16*cos(2*self.pressure_angle) + 6*cos(4*self.pressure_angle) -
|
||||
# 4*cos(4*self.pressure_angle - 2*self.pitch_angle) - 8*cos(2*(self.pressure_angle - self.pitch_angle)) +
|
||||
# cos(4*(self.pressure_angle - self.pitch_angle)) + 24*cos(2*self.pitch_angle) - 2*cos(4*self.pitch_angle) -
|
||||
# 8*cos(2*(self.pressure_angle + self.pitch_angle)) + cos(4*(self.pressure_angle + self.pitch_angle)) -
|
||||
# 4*cos(2*(2*self.pressure_angle + self.pitch_angle)) + 24*cos((4*sin(self.pitch_angle))/self.z) +
|
||||
# 4*cos(2*self.pressure_angle - (4*sin(self.pitch_angle))/self.z) + 16*cos(2*self.pitch_angle -
|
||||
# (4*sin(self.pitch_angle))/self.z) + 24*cos(4*self.pitch_angle - (4*sin(self.pitch_angle))/self.z) +
|
||||
# 4*cos(2*self.pressure_angle + 4*self.pitch_angle - (4*sin(self.pitch_angle))/self.z) -
|
||||
# 8*cos(2*(self.pressure_angle + self.pitch_angle - (2*sin(self.pitch_angle))/self.z)) +
|
||||
# 4*cos(2*self.pressure_angle + (4*sin(self.pitch_angle))/self.z) + 4*cos(2*self.pressure_angle -
|
||||
# 4*self.pitch_angle + (4*sin(self.pitch_angle))/self.z) - 8*cos(2*self.pressure_angle - 2*self.pitch_angle +
|
||||
# (4*sin(self.pitch_angle))/self.z) + 32*sqrt(2)*sqrt(-(cos(self.pressure_angle)**2*
|
||||
# (-2 - 2*cos(2*self.pressure_angle) + cos(2*(self.pressure_angle - self.pitch_angle)) -
|
||||
# 2*cos(2*self.pitch_angle) + cos(2*(self.pressure_angle + self.pitch_angle)) +
|
||||
# 4*cos(2*self.pitch_angle - (4*sin(self.pitch_angle))/self.z))*cos(self.pitch_angle - (2*sin(self.pitch_angle))/self.z)**2*
|
||||
# sin(2*self.pitch_angle)**2)))/(-6 - 2*cos(2*self.pressure_angle) + cos(2*(self.pressure_angle - self.pitch_angle)) -
|
||||
# 2*cos(2*self.pitch_angle) + cos(2*(self.pressure_angle + self.pitch_angle)))**2)/sqrt(2))
|
||||
|
||||
def involute_function_x(self):
|
||||
def func(s):
|
||||
return((
|
||||
@@ -143,7 +121,6 @@ class BevelTooth(object):
|
||||
pts = rot(pts)
|
||||
ref = reflection3D(pi/2)
|
||||
pts1 = ref(pts)[::-1]
|
||||
rot = rotation3D(2*pi/self.z)
|
||||
if self.add_foot:
|
||||
return(array([
|
||||
array([pts[0], pts[1]]),
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
|
||||
from __future__ import division
|
||||
from numpy import tan, cos, sin, sqrt, arctan, pi, array, linspace, transpose, vstack, ndarray
|
||||
from ._functions import nearestpts, rotation, reflection, trimfunc, norm, translation
|
||||
import numpy as np
|
||||
from ._functions import nearestpts, rotation, reflection, trimfunc, diff_norm, translation
|
||||
|
||||
|
||||
class InvoluteTooth():
|
||||
@@ -49,7 +48,7 @@ class InvoluteTooth():
|
||||
self.pressure_angle_t = self.pressure_angle
|
||||
self.m = self.m_n
|
||||
|
||||
self.pitch = self.m * np.pi
|
||||
self.pitch = self.m * pi
|
||||
self.c = self.clearance * self.m_n
|
||||
self.midpoint = [0., 0.]
|
||||
self.d = self.z * self.m
|
||||
@@ -112,7 +111,7 @@ class InvoluteTooth():
|
||||
u1 = False
|
||||
if self.dg > self.df:
|
||||
u1 = vstack(
|
||||
[[l2[0] * self.df / (norm(l2[0], [0, 0]) * 2)], [l2[0]]])
|
||||
[[l2[0] * self.df / (diff_norm(l2[0], [0, 0]) * 2)], [l2[0]]])
|
||||
e1 = l2
|
||||
else:
|
||||
e1 = l2
|
||||
@@ -120,7 +119,6 @@ class InvoluteTooth():
|
||||
reflect = reflection(0)
|
||||
e2 = reflect(e1)[::-1]
|
||||
if isinstance(u1, bool):
|
||||
u2 = False
|
||||
one_tooth = [e1, [e1[-1], e2[0]], e2]
|
||||
else:
|
||||
u2 = reflect(u1)[::-1]
|
||||
@@ -214,10 +212,10 @@ class InvoluteRack(object):
|
||||
teeth[-1][0][0] = 0
|
||||
teeth[-1][0][1] += a / 2
|
||||
|
||||
teeth = np.array([v for t in teeth for v in t]) # flattening
|
||||
teeth = 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])
|
||||
ext1 = teeth[0] + array([0., a + b - pitch / 2])
|
||||
ext2 = teeth[-1] - array([0., a + b - pitch / 2])
|
||||
teeth = [ext1.tolist(), ext1.tolist()] + teeth.tolist() + [ext2.tolist(), ext2.tolist()]
|
||||
else:
|
||||
teeth = [teeth[0].tolist()] + teeth.tolist() + [teeth[-1].tolist()]
|
||||
@@ -226,7 +224,7 @@ class InvoluteRack(object):
|
||||
#teeth.append(list(teeth[0]))
|
||||
teeth[-1][0] -= self.thickness
|
||||
teeth.append(teeth[0])
|
||||
return np.array(teeth)
|
||||
return array(teeth)
|
||||
|
||||
def compute_properties(self):
|
||||
if self.properties_from_tool:
|
||||
@@ -238,5 +236,5 @@ class InvoluteRack(object):
|
||||
m = self.m
|
||||
m_n = self.m
|
||||
|
||||
pitch = m * np.pi
|
||||
pitch = m * pi
|
||||
return m, m_n, pitch, pressure_angle_t
|
||||
|
||||
@@ -28,7 +28,6 @@ class CycloideProfile(CycloideTooth, _GearProfile):
|
||||
|
||||
class BevelProfile(BevelTooth, _GearProfile):
|
||||
rot3D = True
|
||||
pass
|
||||
|
||||
class InvoluteRackProfile(InvoluteRack):
|
||||
def profile(self):
|
||||
|
||||
Reference in New Issue
Block a user