Skip to content

Instantly share code, notes, and snippets.

View SreenivasVRao's full-sized avatar

Sreenivas Venkobarao SreenivasVRao

View GitHub Profile
@SreenivasVRao
SreenivasVRao / translation.py
Created November 6, 2018 04:18
Affine Transforms
import numpy as np
def apply_transformations(transformations, data):
# data = T x K x 3 co-ordinates (2 for each point), or K x 3 points in case generate = True
# transformations = T affine matrices 2 x 3 each (T x 2 x 3)
K, _ = data.shape
T, _, _ = transformations.shape # T x 2 x 3 matrices
data = np.broadcast_to(data, (T, K, 3))
data = np.swapaxes(data, 1, 2) # makes it T x 3 x K