def test_smoothed_pins_endpoints(self): points = ((50,50,50),) + ((20,20,20),) * 7 + ((80,80,80),) stroke = Stroke(*points) smoothed = stroke.smoothed() self.assertEqual( smoothed.points[0], (50,50,50) ) self.assertEqual( smoothed.points[-1], (80,80,80) )
def test_smoothed_equal_points(self): points = [ (1,1,1) ] * 7 stroke = Stroke(*points) smoothed = stroke.smoothed() self.assertEqual(smoothed.points, points)
def test_smoothed_with_blending(self): points = [ (1,1,1), (0,0,0) ] * 4 stroke = Stroke(*points) smoothed = stroke.smoothed() self.assertTrue( smoothed.points[1][0] > 0 ) self.assertTrue( smoothed.points[2][0] < 1 )
def test_square_total_joint_angle(self): stroke = Stroke((0,0,0),(0,1,0),(1,1,0),(1,0,0)) self.assertEqualRounded( stroke.total_joint_angle, math.pi )
def test_smoothed_too_few_points(self): stroke = Stroke((4,4,4),(1,1,1),(4,4,4)) smoothed = stroke.smoothed() self.assertEqual(smoothed.points, [(4,4,4),(1,1,1),(4,4,4)])
def test_two_points_total_joint_angle(self): stroke = Stroke((0,0,0),(1,1,1)) self.assertEqual( stroke.total_joint_angle, 0 )
def test_single_point_total_absolute_joint_angle(self): stroke = Stroke((0,0,0)) self.assertEqual( stroke.total_joint_angle, 0 )
def test_zigzag_total_joint_angle(self): stroke = Stroke((0,0,0),(0,1,0),(1,1,0),(1,2,0)) self.assertEqualRounded( stroke.total_joint_angle, 0 )
def setUp(self): self.empty_stroke = Stroke()
def test_zigzag_mean_absolute_joint_angle(self): stroke = Stroke((0,0,0),(0,1,0),(1,1,0),(1,2,0)) self.assertEqualRounded( stroke.mean_absolute_joint_angle, math.pi/2 )