I am looking for a better way to find the orientation of an object or camera.

SetErrorMode(2)
SetWindowSize(1024,768,0)
SetWindowAllowResize(1)
SetVirtualResolution(1024,768)
SetScissor(0,0,0,0)
SetSyncRate(60,0)
SetPrintSize(16)
Local xt As Float
Local yt As Float
Local zt As Float
Local matrix As Float[8]
cube=CreateObjectBox(4,4,8)
While GetRawKeyPressed(27)=0
RotateObjectGlobalX(cube,0.3)
RotateObjectGlobalY(cube,0.4)
RotateObjectLocalZ(cube,2.0)
// bad way to get the matrix --->
xt=GetObjectWorldX(cube)
yt=GetObjectWorldY(cube)
zt=GetObjectWorldZ(cube)
MoveObjectLocalX(cube,1)
matrix[0]=(GetObjectWorldX(cube)-xt)
matrix[1]=(GetObjectWorldY(cube)-yt)
matrix[2]=(GetObjectWorldZ(cube)-zt)
SetObjectPosition(cube,xt,yt,zt)
MoveObjectLocalY(cube,1)
matrix[3]=(GetObjectWorldX(cube)-xt)
matrix[4]=(GetObjectWorldY(cube)-yt)
matrix[5]=(GetObjectWorldZ(cube)-zt)
SetObjectPosition(cube,xt,yt,zt)
MoveObjectLocalZ(cube,1)
matrix[6]=(GetObjectWorldX(cube)-xt)
matrix[7]=(GetObjectWorldY(cube)-yt)
matrix[8]=(GetObjectWorldZ(cube)-zt)
SetObjectPosition(cube,xt,yt,zt)
// <--- bad way to get the matrix
Print("[Escape] for Exit")
Print("")
Print("xx "+Str(matrix[0],2)+" | xy "+Str(matrix[1],2)+" | xz "+Str(matrix[2],2))
Print("yx "+Str(matrix[3],2)+" | yy "+Str(matrix[4],2)+" | yz "+Str(matrix[5],2))
Print("zx "+Str(matrix[6],2)+" | zy "+Str(matrix[7],2)+" | zz "+Str(matrix[8],2))
Sync()
EndWhile