# Estimating 3d transformation of two triangles

1. Jun 15, 2012

### nimmie

I have two triangles in 3d. I need to calculate transformation matrix(3X3) between two triangles in 3D.

1)How can I calculate the transformation matrix(rigid) while fixing one of the points to the origin(to get rid of the translation part)?

2)How does it affect if the deformation is non rigid?

2. Jun 15, 2012

### chiro

1) You can, in the general case solve a chunk of linear systems where the determinant of the matrix is 1, given the constraints of initial and final points that satisfy the transformation. If you can calculate something that makes sense, that is your answer (you may also have free parameters depending on your initial/final points as well the dimension of your space).

2) If the deformation is non-rigid then you won't have a pure-rotation, but some thing a lot more general and you will have to provide the relaxed constraints (i.e. det <> 1).

For finding the matrix given two points I recommend you find two orthogonal rotations in the way that one rotation transforms triangle so one point is positioned and then the next rotation axis is aligned with the vertex that has the proper position and the angle corresponds to rotating the other vertex into position.

The idea of this is that if you try and rotate a vertex around an axis that is parallel to the vertex itself, it won't change. Because you have two vertices, I think this idea is optimal for your situation.

If you need to know how to create axis-angle rotation matrices look here:

http://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle

3. Jun 15, 2012

### haruspex

I assume you mean you've normalised each triangle to have a vertex at the origin.
If it's rigid there are only 3 degrees of freedom, and only the direction vectors are needed as inputs.
If it's non-rigid then there will be a subspace of possibilities. There will be 9 unknowns but only 6 equations. And that's assuming the association of the vertices of one to those of the other is given.

4. Jun 15, 2012

### haruspex

Suppose you want to rotate vector u1 to u2 and v1 to v2.
The axis of rotation is given by w where w.u1 = w.u2 and w.v1 = w.v2. w might as well be a unit vector, so that's two equations, two unknowns.
If w = (x, y, z), the matrix which rotates space an angle theta around w is (from http://www.fastgraph.com/makegames/3drotation/) R =
tx2+c txy-sz txz+sy
txy+sz ty2+c tyz-sx
txz-sy tyz+sx tz2+c
where c = cos(theta), s = sin(theta), t = 1-c.
It remains to determine theta from R u1 = u2.