Examples - craigstar/SophusPy GitHub Wiki

1. create SO2, SE2, SO3 and SE3

import numpy as np
import sophuspy as sp

# 1. constructor of SO2
sp.SO2()                    # default
sp.SO2([[1, 0],
        [0, 1]])            # list
sp.SO2(np.eye(2))           # numpy
'''
SO2([[1, 0],
     [0, 1]])
'''

# 2. constructor of SO3
sp.SO3()                    # default
sp.SO3([[1, 0, 0],
        [0, 1, 0],
        [0, 0, 1]])         # list
sp.SO3(np.eye(3))           # numpy
'''
SO3([[1, 0, 0],
     [0, 1, 0],
     [0, 0, 1]])
'''

# 3. constructor of SE2
sp.SE2()                    # default
sp.SE2([[1, 0, 0],
        [0, 1, 0],
        [0, 0, 1]])         # list
sp.SE2(np.eye(3))           # numpy
'''
SE2([[1, 0, 0],
     [0, 1, 0],
     [0, 0, 1]])
'''

# 4. constructor of SE3
sp.SE3()                    # default
sp.SE3([[1, 0, 0, 0],
        [0, 1, 0, 0],
        [0, 0, 1, 0],
        [0, 0, 0, 1]])      # list
sp.SE3(np.eye(4))           # numpy
'''
SE3([[1, 0, 0, 0],
     [0, 1, 0, 0],
     [0, 0, 1, 0],
     [0, 0, 0, 1]])
'''

# 5. R, t constructor of SE2
sp.SE2(np.eye(2), np.ones(2)) # R, t
'''
SE2([[1, 0, 1],
     [0, 1, 1],
     [0, 0, 1]])
'''

# 6. R, t constructor of SE3
sp.SE3(np.eye(3), np.ones(3)) # R, t
'''
SE3([[1, 0, 0, 1],
     [0, 1, 0, 1],
     [0, 0, 1, 1],
     [0, 0, 0, 1]])
'''