Merge branch 'main' into touhou/houjuu-nue

This commit is contained in:
Leni Aniva 2024-11-13 22:24:42 -08:00
commit 851907aa7b
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
1 changed files with 36 additions and 35 deletions

View File

@ -131,25 +131,25 @@ class TestGeometry(unittest.TestCase):
y = r * math.sin(phi - theta) y = r * math.sin(phi - theta)
d = math.sqrt((x - rp) ** 2 + y ** 2) d = math.sqrt((x - rp) ** 2 + y ** 2)
self.assertAlmostEqual(d, dc) self.assertAlmostEqual(d, dc)
def test_contraction_span_pos_from_radius_2(self): #def test_contraction_span_pos_from_radius_2(self):
sl = 40.0 # sl = 40.0
dc = 170.0 # dc = 170.0
do = dc + sl # do = dc + sl
r = 50.0 # r = 50.0
theta = math.radians(120.0) # theta = math.radians(120.0)
for smaller in [False, True]: # for smaller in [False, True]:
with self.subTest(smaller=smaller): # with self.subTest(smaller=smaller):
r, phi, rp = nhf.geometry.contraction_span_pos_from_radius(do, dc, r=r, theta=theta, smaller=smaller) # r, phi, rp = nhf.geometry.contraction_span_pos_from_radius(do, dc, r=r, theta=theta, smaller=smaller)
with self.subTest(state='open'): # with self.subTest(state='open'):
x = r * math.cos(phi) # x = r * math.cos(phi)
y = r * math.sin(phi) # y = r * math.sin(phi)
d = math.sqrt((x - rp) ** 2 + y ** 2) # d = math.sqrt((x - rp) ** 2 + y ** 2)
self.assertAlmostEqual(d, do) # self.assertAlmostEqual(d, do)
with self.subTest(state='closed'): # with self.subTest(state='closed'):
x = r * math.cos(phi - theta) # x = r * math.cos(phi - theta)
y = r * math.sin(phi - theta) # y = r * math.sin(phi - theta)
d = math.sqrt((x - rp) ** 2 + y ** 2) # d = math.sqrt((x - rp) ** 2 + y ** 2)
self.assertAlmostEqual(d, dc) # self.assertAlmostEqual(d, dc)
class TestUtils(unittest.TestCase): class TestUtils(unittest.TestCase):
@ -255,22 +255,23 @@ class TestUtils(unittest.TestCase):
self.assertAlmostEqual(bbox.ylen, 15) self.assertAlmostEqual(bbox.ylen, 15)
self.assertAlmostEqual(bbox.zlen, 5) self.assertAlmostEqual(bbox.zlen, 5)
def test_abs_location(self): # FIXME: Absolute location
box = Cq.Solid.makeBox(1, 1, 1) #def test_abs_location(self):
assembly = ( # box = Cq.Solid.makeBox(1, 1, 1)
Cq.Assembly() # assembly = (
.add(box, name="b1") # Cq.Assembly()
.add(box, name="b2", loc=Cq.Location((0,0,1))) # .add(box, name="b1")
.add(box, name="b3", loc=Cq.Location((0,0,2))) # .add(box, name="b2", loc=Cq.Location((0,0,1)))
) # .add(box, name="b3", loc=Cq.Location((0,0,2)))
(x, y, z), _ = assembly.get_abs_location("b2@faces@>Y").toTuple() # )
self.assertAlmostEqual(x, 0.5) # (x, y, z), _ = assembly.get_abs_location("b2@faces@>Y").toTuple()
self.assertAlmostEqual(y, 1) # self.assertAlmostEqual(x, 0.5)
self.assertAlmostEqual(z, 1.5) # self.assertAlmostEqual(y, 1)
(rx, ry, rz), _ = assembly.get_abs_direction("b2@faces@>Y").toTuple() # self.assertAlmostEqual(z, 1.5)
self.assertAlmostEqual(rx, 0) # (rx, ry, rz), _ = assembly.get_abs_direction("b2@faces@>Y").toTuple()
self.assertAlmostEqual(ry, 1) # self.assertAlmostEqual(rx, 0)
self.assertAlmostEqual(rz, 0) # self.assertAlmostEqual(ry, 1)
# self.assertAlmostEqual(rz, 0)
def test_centre_of_mass(self): def test_centre_of_mass(self):
assembly = ( assembly = (