import math as m

cam_mat4 = [[-0.991192, 0, 0, 0],
            [0, 0, -1, 0],
            [0, 0.991192, -0.13243, 0],
            [0, -155.109, 29.1869, 1]]

animationFrames = 30
result_mat4 = [[ 0,0,0,0],
		[0,0,0,0],
		[0,0,0,0],
		[0,0,0,0]]
orbDegrees = 90.0
currentFrame=15
print('orbd',orbDegrees, 'numframes',animationFrames,'current', currentFrame)
print(cam_mat4)
rot_mat4 = [[m.cos(m.radians((orbDegrees/animationFrames)*(currentFrame-1))), m.sin(m.radians((orbDegrees/animationFrames)*(currentFrame-1))), 0, 0],
	[-m.sin(m.radians((orbDegrees/animationFrames)*(currentFrame-1))), m.cos(m.radians((orbDegrees/animationFrames)*(currentFrame-1))), 0, 0],
	[0, 0, 1, 0],
	[0, 0, 0, 1]]
print('ROT MAT4',rot_mat4)

print("num rows in matrix assume 4,",len(cam_mat4))
print("num elements in row 0 fo rotation matrix,",len(rot_mat4[0]))

# loop each 4x4 element
for i in range(len(cam_mat4)):

	for j in range(len(rot_mat4[0])):
		for k in range(len(rot_mat4)):
			# multiply each orig matrix element with  each rotation matrix elements
			print("result_mat4[",i,"][",j,"] += cam_mat4[",i,"][",k,"] * rot_mat4[",k,"][",j,"]")
			result_mat4[i][j] += cam_mat4[i][k] * rot_mat4[k][j]

print('TRUEfinal transform',result_mat4)

result0 = [ 0.0,0.0,0.0,0.0 ]
result1 = [ 0,0,0,0 ]
result2 = [ 0,0,0,0 ]
result3 = [ 0,0,0,0 ]
cam0 = [-0.991192, 0, 0, 0]
cam1 = [0, 0, -1, 0]
cam2 = [0, 0.991192, -0.13243, 0]
cam3 = [0, -155.109, 29.1869, 1]
rot0 = [m.cos(m.radians((orbDegrees/animationFrames)*(currentFrame-1))), m.sin(m.radians((orbDegrees/animationFrames)*(currentFrame-1))), 0, 0]
rot1 = [-m.sin(m.radians((orbDegrees/animationFrames)*(currentFrame-1))), m.cos(m.radians((orbDegrees/animationFrames)*(currentFrame-1))), 0, 0]
rot2 =[0, 0, 1, 0]
rot3 = [0, 0, 0, 1]


print(cam0,cam1,cam2,cam3)
print("SMALL ROT MAT4",rot0,rot1,rot2,rot3)


result0_0 = cam0[ 0 ] * rot0[ 0 ]
result0_0+= cam0[ 1 ] * rot1[ 0 ]
result0_0+= cam0[ 2 ] * rot2[ 0 ]
result0_0+= cam0[ 3 ] * rot3[ 0 ]
result0_1 = cam0[ 0 ] * rot0[ 1 ]
result0_1+= cam0[ 1 ] * rot1[ 1 ]
result0_1+= cam0[ 2 ] * rot2[ 1 ]
result0_1+= cam0[ 3 ] * rot3[ 1 ]
result0_2 = cam0[ 0 ] * rot0[ 2 ]
result0_2+= cam0[ 1 ] * rot1[ 2 ]
result0_2+= cam0[ 2 ] * rot2[ 2 ]
result0_2+= cam0[ 3 ] * rot3[ 2 ]
result0_3 = cam0[ 0 ] * rot0[ 3 ]
result0_3+= cam0[ 1 ] * rot1[ 3 ]
result0_3+= cam0[ 2 ] * rot2[ 3 ]
result0_3+= cam0[ 3 ] * rot3[ 3 ]
result1_0 = cam1[ 0 ] * rot0[ 0 ]
result1_0+= cam1[ 1 ] * rot1[ 0 ]
result1_0+= cam1[ 2 ] * rot2[ 0 ]
result1_0+= cam1[ 3 ] * rot3[ 0 ]
result1_1 = cam1[ 0 ] * rot0[ 1 ]
result1_1+= cam1[ 1 ] * rot1[ 1 ]
result1_1+= cam1[ 2 ] * rot2[ 1 ]
result1_1+= cam1[ 3 ] * rot3[ 1 ]
result1_2 = cam1[ 0 ] * rot0[ 2 ]
result1_2+= cam1[ 1 ] * rot1[ 2 ]
result1_2+= cam1[ 2 ] * rot2[ 2 ]
result1_2+= cam1[ 3 ] * rot3[ 2 ]
result1_3 = cam1[ 0 ] * rot0[ 3 ]
result1_3+= cam1[ 1 ] * rot1[ 3 ]
result1_3+= cam1[ 2 ] * rot2[ 3 ]
result1_3+= cam1[ 3 ] * rot3[ 3 ]
result2_0 = cam2[ 0 ] * rot0[ 0 ]
result2_0+= cam2[ 1 ] * rot1[ 0 ]
result2_0+= cam2[ 2 ] * rot2[ 0 ]
result2_0+= cam2[ 3 ] * rot3[ 0 ]
result2_1 = cam2[ 0 ] * rot0[ 1 ]
result2_1+= cam2[ 1 ] * rot1[ 1 ]
result2_1+= cam2[ 2 ] * rot2[ 1 ]
result2_1+= cam2[ 3 ] * rot3[ 1 ]
result2_2 = cam2[ 0 ] * rot0[ 2 ]
result2_2+= cam2[ 1 ] * rot1[ 2 ]
result2_2+= cam2[ 2 ] * rot2[ 2 ]
result2_2+= cam2[ 3 ] * rot3[ 2 ]
result2_3 = cam2[ 0 ] * rot0[ 3 ]
result2_3+= cam2[ 1 ] * rot1[ 3 ]
result2_3+= cam2[ 2 ] * rot2[ 3 ]
result2_3+= cam2[ 3 ] * rot3[ 3 ]
result3_0 = cam3[ 0 ] * rot0[ 0 ]
result3_0+= cam3[ 1 ] * rot1[ 0 ]
result3_0+= cam3[ 2 ] * rot2[ 0 ]
result3_0+= cam3[ 3 ] * rot3[ 0 ]
result3_1 = cam3[ 0 ] * rot0[ 1 ]
result3_1+= cam3[ 1 ] * rot1[ 1 ]
result3_1+= cam3[ 2 ] * rot2[ 1 ]
result3_1+= cam3[ 3 ] * rot3[ 1 ]
result3_2 = cam3[ 0 ] * rot0[ 2 ]
result3_2+= cam3[ 1 ] * rot1[ 2 ]
result3_2+= cam3[ 2 ] * rot2[ 2 ]
result3_2+= cam3[ 3 ] * rot3[ 2 ]
result3_3 = cam3[ 0 ] * rot0[ 3 ]
result3_3+= cam3[ 1 ] * rot1[ 3 ]
result3_3+= cam3[ 2 ] * rot2[ 3 ]
result3_3+= cam3[ 3 ] * rot3[ 3 ]

result0=[ result0_0, result0_1, result0_2, result0_3 ]
result1=[ result1_0, result1_1, result1_2, result1_3 ]
result2=[ result2_0, result2_1, result2_2, result2_3 ]
result3=[ result3_0, result3_1, result3_2, result3_3 ]


#each element of result matrix is the dot product 
# each row element x each columnn element 

# member rows time member columnes


# loop each 4x4 element
#for i in range(4):
#	print("i",i)
#	for j in range(4):
#		print("\tj",i)
#		for k in range(4):
#			print("\t\tk",i)
#			# multiply each orig matrix element with  each rotation matrix elements
#			result_mat4[i][j] += cam_mat4[i][i] * rot_mat4[i][i]

print('final transform',result0)
print('final transform',result1)
print('final transform',result2)
print('final transform',result3)

