# Chained Transformation Matrices not producing predicted result

I have a problem for a few days and I can't solve it =[[ I have a composite object of 4 parts and I'm trying to do the translation and rotation operations on it. Each part of the object has a rotation and translation matrix (so I have 4 different rotations and translations).

The steps are:

1. Calculates the transpose of the rotation matrix;
2. Place all the objects in the origin (0,0,0);
3. Define "Origin to Geometry" for all objects;
4. Conversion of the transposed rotation matrix to Euler Angles;
5. Modify the position and rotation of objects with their translations and rotations;

Here is a part of my code:

for i in range (1, 5):
print ("done " + str(i))
bpy.context.scene.objects.active = bpy.data.objects["obj"+str(i)]
obj = bpy.context.scene.objects.active

with open('info/info_' + a + '_00' + str(i-1) + '.txt', newline='') as inputfile:

r1 = results[4]
r2 = results[5]
r3 = results[6]
t = results[8]

r1 = [num.strip().split(" ") for num in r1]
r2 = [num.strip().split(" ") for num in r2]
r3 = [num.strip().split(" ") for num in r3]
t = [num.strip().split(" ") for num in t]

#with transposed matrix
a11 = float(r1[0][0])
a12 = float(r2[0][0])
a13 = float(r3[0][0])
a21 = float(r1[0][1])
a22 = float(r2[0][2])
a23 = float(r3[0][3])
a31 = float(r1[0][4])
a32 = float(r2[0][5])
a33 = float(r3[0][6])
t1 = float(t[0][0]) # value of x
t2 = float(t[0][7]) # value of y
t3 = float(t[0][8]) # value of z

#http://nghiaho.com/?page_id=846
rot_x = atan2(a32,a33) # result in rad
rot_y = atan2(-a31,sqrt(pow(a32,2)+pow(a33,2)))
rot_z = atan2(a21,a11) # to degrees -> degrees(rot_z)

bpy.data.objects["obj" + str(i)].location = [0, 0, 0]
bpy.data.objects["obj" + str(i)].rotation_euler = [0, 0, 0]
bpy.data.objects["obj" + str(i)].rotation_euler = [-rot_x, rot_z, -rot_y]
bpy.data.objects["obj" + str(i)].location = [t1, -t3, t2]


PS: I change the sequence of rotation angles because blenders coordinate system is different

The result is is below. The strange is that the object are disconnected, which can not happen. Does anyone have any suggestions?

I also have attached the camera image that I have and that I wish

I know that the difference is small but it can not continue my work with this.

• you just find the transform matrix and assign it to obj.matrix_world , BTW are there any parenting relations between this objects (their transformation will be relative to the parent ) – Chebhou Apr 29 '15 at 23:17