Hello All,

I have 2 identical triangles in different places and need to know the rotation and movement to get from triangle #1 to triangle #2. There is no perpendicular angle in that triangle(s).

the rotation has to be in quaternions. The movement in x=x+/-n y=y+/-n z=z+/-n

I am coding in Java3d but any other language would work for me to understand how to do that.

Any help is much appreciated!

Thanks, Dusentrieb

Given a triangle consisting of 3 vertices p1, p2 and p3, construct a fourth vertex p4 = p1+(p2-p1)×(p3-p1). Convert from Euclidean (3D) to homogeneous (4D) coordinates, setting w=1. Construct a 4x4 matrix whose columns are the 4 vertices.

Do this for both triangles to obtain matrices A and B. M=A-1·B is the transformation from A to B, M-1=B-1·A is the inverse (from B to A). The rotation and translation components can be extracted as a quaternion and vector via e.g. Matrix4d.get().

Note that you need to specify the vertices in the same order for both triangles. Otherwise you’ll get a matrix which includes scale/shear transformations. If the order is correct and the two triangles are the same except for translation and rotation, the bottom row of M (and M-1) will be [0,0,0,1] (give or take rounding errors), and the upper 3x3 submatrix will be orthonormal (multiplying it with its transpose will yield the identity matrix, again give or take rounding errors).

Hello GClements,

thanks you for your answer!

It will take me some time to implement your answer into my program. Is there any chance you could write me this function and I’ll pay you ? If so, could you please send me a pm with the cost?

Cheers, Duesentrieb