cosplay: Touhou/Houjuu Nue #4
|
@ -15,3 +15,10 @@ and this should succeed
|
|||
python3 -c "import nhf"
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
Run all tests with
|
||||
``` sh
|
||||
python3 -m unittest
|
||||
```
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import cadquery as Cq
|
||||
import math
|
||||
import unittest
|
||||
|
||||
def hirth_joint(radius=60,
|
||||
radius_inner=40,
|
||||
radius_centre=30,
|
||||
base_height=20,
|
||||
n_tooth=16,
|
||||
tooth_height=16,
|
||||
|
@ -226,12 +224,3 @@ def comma_assembly():
|
|||
)
|
||||
return result
|
||||
|
||||
class TestJoints(unittest.TestCase):
|
||||
|
||||
def test_hirth_assembly(self):
|
||||
hirth_assembly()
|
||||
def test_comma_assembly(self):
|
||||
comma_assembly()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
import unittest
|
||||
import nhf.joints
|
||||
|
||||
class TestJoints(unittest.TestCase):
|
||||
|
||||
def test_joints_hirth_assembly(self):
|
||||
nhf.joints.hirth_assembly()
|
||||
def test_joints_comma_assembly(self):
|
||||
nhf.joints.comma_assembly()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -1,5 +1,6 @@
|
|||
import cadquery as Cq
|
||||
from dataclasses import dataclass
|
||||
import unittest
|
||||
import cadquery as Cq
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Parameters:
|
||||
|
@ -16,9 +17,46 @@ class Parameters:
|
|||
"""
|
||||
root_radius: float = 60
|
||||
|
||||
"""
|
||||
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
|
||||
|
||||
def wing_root(self,
|
||||
side_width=30,
|
||||
side_height=100):
|
||||
side_height=100) -> Cq.Shape:
|
||||
"""
|
||||
Generate the wing root which contains a Hirth joint at its base and a
|
||||
rectangular opening on its side, with the necessary interfaces.
|
||||
|
@ -30,5 +68,7 @@ class Parameters:
|
|||
rotate=Cq.Vector(0, 45, 0))
|
||||
.rect(side_width, side_height)
|
||||
.loft()
|
||||
.val()
|
||||
)
|
||||
return result
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import unittest
|
||||
import nhf.touhou.houjuu_nue as M
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
|
||||
def test_wing_root(self):
|
||||
p = M.Parameters()
|
||||
p.wing_root()
|
||||
def test_wing_profiles(self):
|
||||
p = M.Parameters()
|
||||
p.wing_r1_profile()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
Reference in New Issue