Files @ f1f8a2421f92
Branch filter:

Location: OneEye/exp/kerokero/transformation_matrices.py - annotation

Laman
updated readme
import math
import random

import numpy as np


def getIdentity():
	return np.float32([
		[1,0,0],
		[0,1,0],
		[0,0,1]
	])


def getRotation():
	alpha=random.random()*2*math.pi
	return np.float32([
		[math.cos(alpha),math.sin(alpha),0],
		[-math.sin(alpha),math.cos(alpha),0],
		[0,0,1]
	])


def getTranslation(dx,dy):
	return np.float32([
		[1,0,dx],
		[0,1,dy],
		[0,0,1]
	])


def getScale(kx,ky=0):
	if not ky: ky=kx
	return np.float32([
		[kx,0,0],
		[0,ky,0],
		[0,0,1]
	])


def getMirroring():
	return np.float32([
		[random.choice((1,-1)),0,0],
		[0,1,0],
		[0,0,1]
	])


def getProjection():
	dx=random.uniform(-0.0005,0.0005)
	dy=random.uniform(-0.0005,0.0005)
	return np.float32([
		[1,0,0],
		[0,1,0],
		[dx,dy,1]
	])