Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spatialmath/twist.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ def pitch(self):
>>> S.pitch

"""
return np.dot(self.w, self.v)
return np.dot(self.w, self.v) / np.dot(self.w, self.w)

def line(self):
"""
Expand Down
11 changes: 11 additions & 0 deletions tests/test_twist.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ def test_exp(self):
tw = Twist3.UnitRevolute([0, 0, 1], [0, 0, 0])
array_compare(tw.exp(pi / 2), SE3.Rz(pi / 2))

def test_pitch(self):
# pitch = (w . v) / (w . w), regression test for missing denominator

# non-unit w: exercises the normalization, would fail without it
tw = Twist3([0, 0, 4], [0, 0, 2])
self.assertAlmostEqual(tw.pitch, 2.0)

# unit w: denominator is 1, sanity check against UnitRevolute's pitch arg
tw = Twist3.UnitRevolute([0, 0, 1], [0, 0, 0], pitch=3)
self.assertAlmostEqual(tw.pitch, 3.0)

def test_arith(self):
# check overloaded *

Expand Down
Loading