Skip to content

Commit 3b97759

Browse files
committed
test(twist): add regression test for pitch denominator fix
Twist3.pitch previously omitted the |w|^2 denominator; this only happened to work when w was a unit vector, which UnitRevolute always produces. Add a case with non-unit w to catch that regression.
1 parent beef079 commit 3b97759

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/test_twist.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,17 @@ def test_exp(self):
179179
tw = Twist3.UnitRevolute([0, 0, 1], [0, 0, 0])
180180
array_compare(tw.exp(pi / 2), SE3.Rz(pi / 2))
181181

182+
def test_pitch(self):
183+
# pitch = (w . v) / (w . w), regression test for missing denominator
184+
185+
# non-unit w: exercises the normalization, would fail without it
186+
tw = Twist3([0, 0, 4], [0, 0, 2])
187+
self.assertAlmostEqual(tw.pitch, 2.0)
188+
189+
# unit w: denominator is 1, sanity check against UnitRevolute's pitch arg
190+
tw = Twist3.UnitRevolute([0, 0, 1], [0, 0, 0], pitch=3)
191+
self.assertAlmostEqual(tw.pitch, 3.0)
192+
182193
def test_arith(self):
183194
# check overloaded *
184195

0 commit comments

Comments
 (0)