Cosplay/nhf/touhou/houjuu_nue/__init__.py

75 lines
2.1 KiB
Python
Raw Normal View History

2024-06-19 21:23:41 -07:00
from dataclasses import dataclass
2024-06-20 23:29:18 -07:00
import unittest
import cadquery as Cq
2024-06-19 15:54:09 -07:00
2024-06-19 21:23:41 -07:00
@dataclass(frozen=True)
class Parameters:
"""
Thickness of the exoskeleton panel in millimetres
"""
panel_thickness: float = 25.4 / 16
# Wing root properties
"""
Radius of the mounting mechanism of the wing root. This is constrained by
the size of the harness.
"""
root_radius: float = 60
2024-06-20 23:29:18 -07:00
"""
Heights for various wing joints, where the numbers start from the first joint.
"""
wing_r1_height = 100
wing_r1_width = 400
wing_r2_height = 100
wing_r3_height = 100
def wing_r1_profile(self) -> Cq.Sketch:
"""
Generates the first wing segment profile, with the wing root pointing in
the positive x axis.
"""
# Depression of the wing middle
bend = 200
factor = 0.7
result = (
Cq.Sketch()
.segment((0, 0), (0, self.wing_r1_height))
.spline([
(0, self.wing_r1_height),
(0.5 * self.wing_r1_width, self.wing_r1_height - factor * bend),
(self.wing_r1_width, self.wing_r1_height - bend),
])
.segment(
(self.wing_r1_width, self.wing_r1_height - bend),
(self.wing_r1_width, -bend),
)
.spline([
(self.wing_r1_width, - bend),
(0.5 * self.wing_r1_width, - factor * bend),
(0, 0),
])
.assemble()
)
return result
2024-06-19 21:23:41 -07:00
def wing_root(self,
side_width=30,
2024-06-20 23:29:18 -07:00
side_height=100) -> Cq.Shape:
2024-06-19 21:23:41 -07:00
"""
Generate the wing root which contains a Hirth joint at its base and a
rectangular opening on its side, with the necessary interfaces.
"""
result = (
Cq.Workplane("XY")
.circle(self.root_radius)
.transformed(offset=Cq.Vector(80, 0, 80),
rotate=Cq.Vector(0, 45, 0))
.rect(side_width, side_height)
.loft()
2024-06-20 23:29:18 -07:00
.val()
2024-06-19 21:23:41 -07:00
)
return result
2024-06-20 23:29:18 -07:00