Files
@ 5fb721461494
Branch filter:
Location: OneEye/exp/kerokero/transformation_matrices.py - annotation
5fb721461494
733 B
text/x-python
minor fixes
655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 655956f6ba89 | 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]
])
|