From 3adb887ef598d69583912584d14629a285f1a369 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Tue, 16 Jul 2024 23:32:23 -0700 Subject: [PATCH] fix: Incorrect staggering of left wings --- nhf/parts/box.py | 1 + nhf/touhou/houjuu_nue/__init__.py | 3 +-- nhf/touhou/houjuu_nue/joints.py | 6 +++++- nhf/touhou/houjuu_nue/wing.py | 18 ++++++++++-------- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/nhf/parts/box.py b/nhf/parts/box.py index 109c667..7d2cbff 100644 --- a/nhf/parts/box.py +++ b/nhf/parts/box.py @@ -54,6 +54,7 @@ class MountingBox(Model): generate_side_tags: bool = True + # Determines the position of side tags flip_y: bool = False @target(kind=TargetKind.DXF) diff --git a/nhf/touhou/houjuu_nue/__init__.py b/nhf/touhou/houjuu_nue/__init__.py index af76e05..6f8347c 100644 --- a/nhf/touhou/houjuu_nue/__init__.py +++ b/nhf/touhou/houjuu_nue/__init__.py @@ -62,16 +62,15 @@ class Parameters(Model): wing_l1: MW.WingL = field(default_factory=lambda: MW.WingL( name="l1", wrist_angle=-45.0, - shoulder_joint=MJ.ShoulderJoint(directrix_id=1), )) wing_l2: MW.WingL = field(default_factory=lambda: MW.WingL( name="l2", wrist_angle=-30.0, + shoulder_joint=MJ.ShoulderJoint(directrix_id=1), )) wing_l3: MW.WingL = field(default_factory=lambda: MW.WingL( name="l3", wrist_angle=0.0, - shoulder_joint=MJ.ShoulderJoint(directrix_id=1), )) trident: MT.Trident = field(default_factory=lambda: MT.Trident()) diff --git a/nhf/touhou/houjuu_nue/joints.py b/nhf/touhou/houjuu_nue/joints.py index 7840715..246dfa2 100644 --- a/nhf/touhou/houjuu_nue/joints.py +++ b/nhf/touhou/houjuu_nue/joints.py @@ -570,7 +570,7 @@ class DiskJoint(Model): @dataclass(kw_only=True) -class ElbowJoint: +class ElbowJoint(Model): """ Creates the elbow and wrist joints. @@ -629,6 +629,7 @@ class ElbowJoint: r = self.parent_arm_radius return [r - dx, r + dx] + @target(name="child") def child_joint(self) -> Cq.Assembly: angle = -self.disk_joint.tongue_span / 2 dz = self.disk_joint.disk_thickness / 2 @@ -646,9 +647,11 @@ class ElbowJoint: ) return result + @target(name="parent-lower") def parent_joint_lower(self) -> Cq.Workplane: return self.disk_joint.housing_lower() + @target(name="parent-upper") def parent_joint_upper(self): axial_offset = Cq.Location((self.parent_arm_radius, 0, 0)) housing_dz = self.disk_joint.housing_upper_dz @@ -683,6 +686,7 @@ class ElbowJoint: ) return result + @assembly() def assembly(self, angle: float = 0) -> Cq.Assembly: result = ( Cq.Assembly() diff --git a/nhf/touhou/houjuu_nue/wing.py b/nhf/touhou/houjuu_nue/wing.py index e7e352e..86ec226 100644 --- a/nhf/touhou/houjuu_nue/wing.py +++ b/nhf/touhou/houjuu_nue/wing.py @@ -635,6 +635,10 @@ class WingProfile(Model): result = ( Cq.Assembly() ) + tag_top, tag_bot = "top", "bot" + if self.flip: + tag_top, tag_bot = tag_bot, tag_top + if "s0" in parts: result.add(self.assembly_s0(), name="s0") if "shoulder" in parts: @@ -642,20 +646,18 @@ class WingProfile(Model): if "s0" in parts and "shoulder" in parts: ( result - .constrain("s0/shoulder?conn_top0", "shoulder/parent_top/lip?conn0", "Plane") - #.constrain("s0/shoulder?conn_top1", "shoulder/parent_top/lip?conn1", "Plane") - .constrain("s0/shoulder?conn_bot0", "shoulder/parent_bot/lip?conn0", "Plane") - #.constrain("s0/shoulder?conn_bot1", "shoulder/parent_bot/lip?conn1", "Plane") + .constrain(f"s0/shoulder?conn_top0", f"shoulder/parent_{tag_top}/lip?conn0", "Plane") + .constrain(f"s0/shoulder?conn_bot0", f"shoulder/parent_{tag_bot}/lip?conn0", "Plane") ) if "s1" in parts: result.add(self.assembly_s1(), name="s1") if "s1" in parts and "shoulder" in parts: ( result - .constrain("s1/shoulder_top?conn0", "shoulder/child/lip_top?conn0", "Plane") - .constrain("s1/shoulder_top?conn1", "shoulder/child/lip_top?conn1", "Plane") - .constrain("s1/shoulder_bot?conn0", "shoulder/child/lip_bot?conn0", "Plane") - .constrain("s1/shoulder_bot?conn1", "shoulder/child/lip_bot?conn1", "Plane") + .constrain("s1/shoulder_top?conn0", f"shoulder/child/lip_{tag_top}?conn0", "Plane") + .constrain("s1/shoulder_top?conn1", f"shoulder/child/lip_{tag_top}?conn1", "Plane") + .constrain("s1/shoulder_bot?conn0", f"shoulder/child/lip_{tag_bot}?conn0", "Plane") + .constrain("s1/shoulder_bot?conn1", f"shoulder/child/lip_{tag_bot}?conn1", "Plane") ) if "elbow" in parts: result.add(self.elbow_joint.assembly(angle=angle_elbow_wrist), name="elbow")