'''
A set of classes to represent projective transformations
'''
import numpy as np
[docs]class Identity:
'''
An identity transform definition
'''
def __init__(self):
pass
[docs] def matrix(self):
'''
Returns the transformation matrix for identity transformation
'''
return np.eye(3)
[docs]class Translation(Transform):
'''
Translation
'''
def __init__(self, previous, t_x, t_y):
super().__init__(previous)
self.t_x = t_x
self.t_y = t_y
[docs] def matrix(self):
result = self.previous.matrix()
result[0, 2] += self.t_x
result[1, 2] += self.t_y
return result