feat: Right-handed spring
This commit is contained in:
parent
58028579a9
commit
800b658410
|
@ -314,12 +314,12 @@ class TorsionJoint:
|
|||
l = self.spring_tail_length
|
||||
if self.right_handed:
|
||||
r2 = -r2
|
||||
# This is (0, r2) and (l, r2) transformed by rotation matrix
|
||||
# [[c, s], [-s, c]]
|
||||
return [
|
||||
(0, 0, height),
|
||||
(c, s, height)
|
||||
]
|
||||
# This is (0, r2) and (l, r2) transformed by rotation matrix
|
||||
# [[c, s], [-s, c]]
|
||||
return [
|
||||
(s * r2, -s * l + c * r2, height),
|
||||
(c * l + s * r2, -s * l + c * r2, height),
|
||||
|
@ -332,6 +332,7 @@ class TorsionJoint:
|
|||
height=self.spring_height,
|
||||
thickness=self.spring_thickness,
|
||||
tail_length=self.spring_tail_length,
|
||||
right_handed=self.right_handed,
|
||||
)
|
||||
|
||||
def track(self):
|
||||
|
|
|
@ -5,11 +5,14 @@ def torsion_spring(radius=12,
|
|||
height=20,
|
||||
thickness=2,
|
||||
omega=90,
|
||||
tail_length=25):
|
||||
tail_length=25,
|
||||
right_handed: bool = False):
|
||||
"""
|
||||
Produces a torsion spring with abridged geometry since sweep is very slow in
|
||||
cq-editor.
|
||||
"""
|
||||
if right_handed:
|
||||
omega = -omega
|
||||
base = (
|
||||
Cq.Workplane('XY')
|
||||
.cylinder(height=height, radius=radius,
|
||||
|
@ -17,12 +20,14 @@ def torsion_spring(radius=12,
|
|||
)
|
||||
base.faces(">Z").tag("top")
|
||||
base.faces("<Z").tag("bot")
|
||||
|
||||
box_shift = -radius if right_handed else radius-thickness
|
||||
result = (
|
||||
base
|
||||
.cylinder(height=height, radius=radius - thickness, combine='s',
|
||||
centered=(True, True, True))
|
||||
.transformed(
|
||||
offset=(0, radius-thickness),
|
||||
offset=(0, box_shift),
|
||||
rotate=(0, 0, 0))
|
||||
.box(
|
||||
length=tail_length,
|
||||
|
@ -33,18 +38,19 @@ def torsion_spring(radius=12,
|
|||
.transformed(
|
||||
offset=(0, 0, height - thickness),
|
||||
rotate=(0, 0, omega))
|
||||
.center(-tail_length, radius-thickness)
|
||||
.center(-tail_length, box_shift)
|
||||
.box(
|
||||
length=tail_length,
|
||||
width=thickness,
|
||||
height=thickness,
|
||||
centered=False)
|
||||
)
|
||||
result.polyline([(0, radius, 0), (tail_length, radius, 0)],
|
||||
r = -radius if right_handed else radius
|
||||
result.polyline([(0, r, 0), (tail_length, r, 0)],
|
||||
forConstruction=True).tag("directrix_bot")
|
||||
c, s = math.cos(omega * math.pi / 180), math.sin(omega * math.pi / 180)
|
||||
result.polyline([
|
||||
(s * tail_length, c * radius - s * tail_length, height),
|
||||
(c * tail_length + s * radius, c * radius - s * tail_length, height)],
|
||||
(s * tail_length, c * r - s * tail_length, height),
|
||||
(c * tail_length + s * r, c * r - s * tail_length, height)],
|
||||
forConstruction=True).tag("directrix_top")
|
||||
return result
|
||||
|
|
|
@ -40,6 +40,9 @@ class TestJoints(unittest.TestCase):
|
|||
for slot in range(j.rider_n_slots):
|
||||
with self.subTest(slot=slot):
|
||||
self.torsion_joint_collision_case(j, slot)
|
||||
def test_torsion_joint_collision_right_handed(self):
|
||||
j = joints.TorsionJoint(right_handed=True)
|
||||
self.torsion_joint_collision_case(j, 1)
|
||||
|
||||
|
||||
class TestHandle(unittest.TestCase):
|
||||
|
|
Loading…
Reference in New Issue