Example #1
0
    def test_inverse(self):
        # Inverse of identity is itself
        s = Similarity()
        nose.tools.assert_equal(s, s.inverse())

        s = Similarity(self.s, self.r, self.t)
        s_i = s.inverse()
        i = s * s_i
        # Similarity composed with inverse should be identity
        nose.tools.assert_almost_equal(i.scale, 1., 14)
        nose.tools.assert_almost_equal(i.rotation.angle(), 0., 14)
        nose.tools.assert_almost_equal(numpy.linalg.norm(i.translation, 2), 0.,
                                       14)
Example #2
0
    def test_inverse(self):
        # Inverse of identity is itself
        s = Similarity()
        nose.tools.assert_equal(s, s.inverse())

        s = Similarity(self.s, self.r, self.t)
        s_i = s.inverse()
        i = s * s_i
        # Similarity composed with inverse should be identity
        nose.tools.assert_almost_equal(i.scale, 1., 14)
        nose.tools.assert_almost_equal(i.rotation.angle(), 0., 14)
        nose.tools.assert_almost_equal(numpy.linalg.norm(i.translation, 2),
                                       0., 12)
Example #3
0
    def test_transform_vector(self):
        s = Similarity(self.s, self.r, self.t)

        v1 = EigenArray.from_iterable([4, 2.1, 9.125])
        v2 = s.transform_vector(v1)
        v3 = s.inverse().transform_vector(v2)
        nose.tools.assert_false(numpy.allclose(v1, v2))
        nose.tools.assert_true(numpy.allclose(v1, v3))

        # This should also work with mult syntax
        v4 = s * v1
        v5 = s.inverse() * v4
        nose.tools.assert_false(numpy.allclose(v1, v4))
        nose.tools.assert_true(numpy.allclose(v1, v5))
Example #4
0
    def test_transform_vector(self):
        s = Similarity(self.s, self.r, self.t)

        v1 = [4, 2.1, 9.125]
        v2 = s.transform_vector(v1)
        v3 = s.inverse().transform_vector(v2)
        nose.tools.assert_false(numpy.allclose(v1, v2))
        nose.tools.assert_true(numpy.allclose(v1, v3))

        # This should also work with mult syntax
        v4 = s * v1
        v5 = s.inverse() * v4
        nose.tools.assert_false(numpy.allclose(v1, v4))
        nose.tools.assert_true(numpy.allclose(v1, v5))