refactoring:

make rotation matrix rotating from x -> y (changing the sign of the rotation)
not sure why it was defined the other way ???
This commit is contained in:
looooo
2024-01-02 23:47:53 +01:00
parent fd73f5e3e1
commit 323c922778
11 changed files with 18 additions and 23 deletions

View File

@@ -119,7 +119,7 @@ class BevelGear(BaseGear):
fp.gear.clearance = fp.clearance / scale
fp.gear._update()
pts = list(fp.gear.points(num=fp.numpoints))
rot = rotation3D(2 * np.pi / fp.teeth)
rot = rotation3D(- 2 * np.pi / fp.teeth)
# if fp.beta.Value != 0:
# pts = [np.array([self.spherical_rot(j, fp.beta.Value * np.pi / 180.) for j in i]) for i in pts]
@@ -142,7 +142,7 @@ class BevelGear(BaseGear):
else:
for scale_i in np.linspace(scale_0, scale_1, 20):
# beta_i = (scale_i - scale_0) * fp.beta.Value * np.pi / 180
# rot = rotation3D(beta_i)
# rot = rotation3D(- beta_i)
# points = [rot(pt) * scale_i for pt in pts]
angle = (
fp.beta.Value
@@ -203,4 +203,4 @@ class BevelGear(BaseGear):
def spherical_rot(self, point, phi):
new_phi = np.sqrt(np.linalg.norm(point)) * phi
return rotation3D(new_phi)(point)
return rotation3D(- new_phi)(point)

View File

@@ -155,7 +155,7 @@ class CycloidGear(BaseGear):
fp.gear._update()
pts = fp.gear.points(num=fp.numpoints)
rot = rotation(-fp.gear.phipart)
rot = rotation(fp.gear.phipart)
rotated_pts = list(map(rot, pts))
pts.append([pts[-1][-1], rotated_pts[0][0]])
pts += rotated_pts

View File

@@ -196,7 +196,7 @@ class InternalInvoluteGear(BaseGear):
if not fp.simple:
# head-fillet:
pts = fp.gear.points(num=fp.numpoints)
rot = rotation(-fp.gear.phipart)
rot = rotation(fp.gear.phipart)
rotated_pts = list(map(rot, pts))
pts.append([pts[-1][-1], rotated_pts[0][0]])
pts += rotated_pts

View File

@@ -206,7 +206,7 @@ class InvoluteGear(BaseGear):
if not obj.simple:
pts = obj.gear.points(num=obj.numpoints)
rot = rotation(-obj.gear.phipart)
rot = rotation(obj.gear.phipart)
rotated_pts = list(map(rot, pts))
pts.append([pts[-1][-1], rotated_pts[0][0]])
pts += rotated_pts

View File

@@ -112,7 +112,7 @@ class LanternGear(BaseGear):
app.Vector(*p_1, 0.0), app.Vector(*p_12, 0.0), app.Vector(*p_2, 0.0)
).toShape()
rot = rotation(-np.pi * 2 / teeth)
rot = rotation(np.pi * 2 / teeth)
p_3 = rot(np.array([p_2_end]))[0]
# l = part.LineSegment(fcvec(p_1_end), fcvec(p_3)).toShape()
l = part_arc_from_points_and_center(

View File

@@ -93,7 +93,7 @@ class TimingGearT(BaseGear):
mirror = reflection(0.0) # reflect the points at the x-axis
p_3, p_4 = mirror(np.array([p_2, p_1]))
rot = rotation(-gamma_0) # why is the rotation in wrong direction ???
rot = rotation(gamma_0) # why is the rotation in wrong direction ???
p_5 = rot(np.array([p_1]))[0] # the rotation expects a list of points
l1 = part.LineSegment(fcvec(p_1), fcvec(p_2)).toShape()

View File

@@ -42,7 +42,6 @@ def reflection3D(angle):
)
def func(x):
# why not use mat @ x
return dot(x, mat)
return func
@@ -50,8 +49,8 @@ def reflection3D(angle):
def rotation(angle, midpoint=None):
midpoint = midpoint or [0.0, 0.0]
mat = array([[cos(angle), -sin(angle)],
[sin(angle), cos(angle)]])
mat = array([[cos(angle), sin(angle)],
[-sin(angle), cos(angle)]])
midpoint = array(midpoint)
vec = midpoint - dot(midpoint, mat)
trans = translation(vec)
@@ -64,8 +63,8 @@ def rotation(angle, midpoint=None):
def rotation3D(angle):
mat = array(
[[cos(angle), -sin(angle), 0.0],
[sin(angle), cos(angle), 0.0],
[[cos(angle), sin(angle), 0.0],
[-sin(angle), cos(angle), 0.0],
[0.0, 0.0, 1.0]]
)

View File

@@ -213,13 +213,13 @@ class BevelTooth(object):
intersection_point = intersection_line_circle(xy[i], point, r_cut)
xy = array([intersection_point] + list(xy[i + 1 :]))
xyz = [[p[0], p[1], 1] for p in xy]
backlash_rot = rotation3D(self.angular_backlash / 2)
backlash_rot = rotation3D(- self.angular_backlash / 2)
xyz = backlash_rot(xyz)
return xyz
def points(self, num=10):
pts = self.involute_points(num=num)
rot = rotation3D(-pi / self.z / 2)
rot = rotation3D(pi / self.z / 2)
pts = rot(pts)
ref = reflection3D(pi / 2)
pts1 = ref(pts)[::-1]

View File

@@ -110,7 +110,7 @@ class CycloidTooth:
pts_outer = transpose([pts_outer_x, pts_outer_y])
pts_inner = transpose([pts_inner_x, pts_inner_y])
pts1 = vstack([pts_inner[:-2], pts_outer])
rot = rotation(self.phipart / 4 - self.angular_backlash / 2)
rot = rotation(- self.phipart / 4 + self.angular_backlash / 2)
pts1 = rot(pts1)
ref = reflection(0.0)
pts2 = ref(pts1)[::-1]

View File

@@ -125,7 +125,7 @@ class InvoluteTooth:
y = array(list(map(fy, pts)))
xy = transpose([x, y])
rotate = rotation(
self.undercut_rot + self.phipart / 2 - self.angular_backlash / 2
- self.undercut_rot - self.phipart / 2 + self.angular_backlash / 2
)
xy = rotate(xy)
return array(xy)
@@ -136,7 +136,7 @@ class InvoluteTooth:
x = array(list(map(fx, pts)))
fy = self.involute_function_y()
y = array(list(map(fy, pts)))
rot = rotation(self.involute_rot - self.angular_backlash / 2)
rot = rotation(- self.involute_rot + self.angular_backlash / 2)
xy = rot(transpose(array([x, y])))
return xy
@@ -168,10 +168,6 @@ class InvoluteTooth:
one_tooth = [u1, e1, [e1[-1], e2[0]], e2, u2]
return one_tooth
def gearfunc(self, x):
rot = rotation(2 * x / self.dw, self.midpoint)
return rot
def undercut_function_x(self):
def func(psi):
return cos(psi - (self.df * tan(psi)) / self.dw) * sqrt(

View File

@@ -33,7 +33,7 @@ class _GearProfile(object):
if self.rot3D:
rot = rotation3D(np.pi * 2 / self.z)
else:
rot = rotation(-np.pi * 2 / self.z)
rot = rotation(np.pi * 2 / self.z)
profile = tooth
for i in range(self.z - 1):
tooth = rot(tooth).tolist()