def transform_points(points, matrix, translate=True):
'''
Returns points, rotated by transformation matrix
If points is (n,2), matrix must be (3,3)
if points is (n,3), matrix must be (4,4)
Arguments
----------
points: (n, 2|3) set of points
matrix: (3|4, 3|4) rotation matrix
translate: boolean, apply translation from matrix or not
'''
points = np.asanyarray(points)
dimension = points.shape[1]
column = np.zeros(len(points)) + int(bool(translate))
stacked = np.column_stack((points, column))
transformed = np.dot(matrix, stacked.T).T[:,0:dimension]
return transformed
评论列表
文章目录