1 from . import MatrixLieGroup, np, R, tran, DifferentiableManifold, contract
2 from .. import (assert_allclose, pose_from_rotation_translation,
3 rotation_translation_from_pose, extract_pieces)
4
5
6 -class Tran(MatrixLieGroup):
7 '''
8 The translation subgroup of SE(n).
9 '''
10
11 @contract(n='1|2|3')
20
22
23 return 'Tr%s' % (self.n - 1)
24
26
27 R, t, zero, one = extract_pieces(x)
28 assert_allclose(R, np.eye(self.n - 1))
29 assert_allclose(zero, 0, err_msg='I expect the lower row to be 0.')
30 assert_allclose(one, 1, err_msg='Bottom-right must be 1.')
31
32 @contract(returns='belongs')
36
37 @contract(x='belongs')
41
42 @contract(base='belongs', target='belongs', returns='belongs_ts')
43 - def logmap(self, base, target):
44 return base, target - base
45
46 @contract(bv='belongs_ts', returns='belongs')
48 base, vel = bv
49 return base + vel
50
51 @contract(g='belongs', returns='belongs_algebra')
53 a = np.zeros((self.n, self.n))
54 a[:-1, -1] = g[:-1, -1]
55 return a
56
57 @contract(a='belongs_algebra', returns='belongs')
59 g = np.eye(self.n)
60 g[:-1, -1] = a[:-1, -1]
61 return g
62
63 @contract(returns='list(belongs)')
71