 # Getting rotation from Matrix

Hello, I’m trying to create a camera that is assigned its position and orientation from 3 point (eye, lookAt, and up). I found a cool script that creates a matrix and will assign a camera, but not in my up vector, only if I use the “X,Y,Z” designation). How can I set the camera rotation using the matrix or the up vector?

``````eye = Vector([0.3588833808898926, -0.4295555949211121, -0.1704823225736618])
target =  Vector([0.3996028304100037, -0.3898821771144867, -0.0804903954267502])
up =  Vector([0.4101610779762268, -0.4956580698490143, -0.1406284272670746])

def matrixLookat(eye, target, up):
z = eye - target
x = up.cross(z)
y = z.cross(x)

x.normalize()
y.normalize()
z.normalize()

rot = Matrix()
rot = x
rot = y
rot = z
rot = 0
rot = x
rot = y
rot = z
rot = 0
rot = x
rot = y
rot = z
rot = 0

rot = 0
rot = 0
rot = 0
rot = 1

# eye not need to be minus cmp to opentk
# perhaps opentk has z inverse axis
tran = Matrix.Translation(eye)
return tran * rot

mat = matrixLookat(eye, target, up)