Triangle rotation/movement

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

I have 5 marbles in one hand and 8 in the other. If I subtract 5 from 8 I will know the difference. Now if I add that number I will be in same rotation as the second one.

Take a step back and explain what you are actually trying to do that painted you into this particular corner.

I got this answer from an other forum:

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).

Can someone help me to get this done with pure Java3d classes? I would pay for.


There is no context so while I’m sure that paragraph makes sense, it also makes no sense because we have no idea what you are attempting to achieve. Explain to us what it is you want to do, and we may be able to get you to understand. We will not do it for you, however.

It’s starting to feel like this is for a school assignment… in which case they won’t be able to explain why they want to do this. It’s an arbitrary school assignment.

I guess if it’s not then OP will have no problem explaining what they are really trying to do.

Else, I suggest everyone just skip this thread until then.

I have 2 identical 3d objects in a scene on different places and need the transform/rotation between them

I really don’t know how I can explain this more clear. Sorry.

for the rotation and translation you can probably interpolate.
see and more specific:

public Quaternion(Quaternion q1,
                  Quaternion q2,
                  float interp)

this creates a new quaternion from the interpolation.
where interp = 0 will return q1; while interp = 1 will return q2

That blurb of text sounds like the beginnings of creating a circle using triangles. I mean… if you understand, you will “see”.

But WHY do you need this? As in “why do you want to do that?” As in, there is a reason you need to do this transform, what is it?

What is the end result you are trying to achieve?

Like, I need to this because… (insert your answer here)

Else, “Quaternion slerp” is your answer.

Probably because his teacher asked him :wink:

teach someone to fish and all that …

Thank you, pspeed.

The rotation between two quaterion is actually pretty easy to find. It is quat1.inverse and then mult with quat2

The problem I face is that my triangle has no 90 degrees in it. So I can not jut take the cross of the points and build one easy. If so, Ineasy could create the quaterion out of those 3 points.

Writing this I realize what the answer I got is doing. With the first function he is going to make this new vertices which I need to declare on which side is up.

I need this to rotate the workobject x/y/z plane of a ABB 7-axis robot to match the plane I have in my cad/cam software I wrote.

Thanks for help and take care.

Sure you can.

Two edges give you the normal. The normal and any other edge gives you the other axis. Now you have three orthogonal axis vectors.

do the identical 3d objects explode? or do they just bump into each other? :sunglasses: