# How to rotate an object so that it aligns with a different axis on another object?

Please take a moment to consider if this thread is worth bumping.

## Recommended Posts

ETA: Never mind - I got it. Confucius say: make sure to get the operands the right way around the *. Well, he actually said, "Don't quote me".

This is boggling my head. After two hours I've hit the whisky and decided to ask for help...

I have a linkset , A, with which I need a script to align a second linkset, B, with, but not with the same axes. The two linksets' roots have different rotatons when in position and I can't change that easily.

With A aligned with the world, and B in position, B's rotation in the edit box is <0,90,0>. When switched to local, B's Z axis moves to where the world X axis was, and B's X axis points down, aligned with the world Z but downwards.

Why does something that looks so simple cause me so much of a headache?

My script needs to rotate B when A is rotated into any orientation (A sends a message telling its rotation when it changes - no problems there) so that it remains in the same orientation with respect to A, as if they are joined (which they cannot be).

At least their roots are centered together; I'm grateful for small mercies.

##### Share on other sites

unlees i see the script i have no idea what you are doing.

##### Share on other sites

I really don't see how the script would help... a diagram maybe, but not the script.

The script in A simply sends its root's rotation in a message to B, when the rotation has changed.

I need to know how to transform that rotation into a rotation that realigns B with A.

Really, there is nothing in the script that's anything to do with that part of things. That's what I need to know. Everything I have tried does not work, so what's the point of copying a dozen or so failed transformation formulae?

As an example of what I'm trying to do, imagine an aeroplane with a propeller which is not actually attached. The propeller has its Z axis aligned with the plane's X axis. Their Y axes coincide. I need to be able to rotate the propeller so that it stays in the correct rotation relative to the aeroplane when it rotates.*

No translation is needed; the roots are centered together.

*ETA: A better example, given that the roots coincide, would be a fan inside it's housing. Move the fan housing, and I need to move the fan blades to match.

##### Share on other sites

Never mind - I finally got it.

I realised I had my operands the wrong way around on either side ot the * in the very first way I tried two hours ago. Darn rotation maths!

##### Share on other sites

which why i wanted to see that part, any ho you sorted it.