diff --git a/README.md b/README.md index 282f834..ae83ed0 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,10 @@ and this should succeed python3 -c "import nhf" ``` +## Testing + +Run all tests with +``` sh +python3 -m unittest +``` + diff --git a/nhf/joints.py b/nhf/joints.py index 02c7527..f809989 100644 --- a/nhf/joints.py +++ b/nhf/joints.py @@ -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() diff --git a/nhf/test.py b/nhf/test.py new file mode 100644 index 0000000..03015ad --- /dev/null +++ b/nhf/test.py @@ -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() diff --git a/nhf/touhou/houjuu_nue/__init__.py b/nhf/touhou/houjuu_nue/__init__.py index 8eac42c..f9ee0ee 100644 --- a/nhf/touhou/houjuu_nue/__init__.py +++ b/nhf/touhou/houjuu_nue/__init__.py @@ -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 + diff --git a/nhf/touhou/houjuu_nue/test.py b/nhf/touhou/houjuu_nue/test.py new file mode 100644 index 0000000..0a9f148 --- /dev/null +++ b/nhf/touhou/houjuu_nue/test.py @@ -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()