rotation relative to a transform

Hi,

I am lost with how to calculate the rotation relative to a transform.

While InverseTransformPoint works well to calculate a position relative to a transform, how do achieve the same process but for rotation?

in short:

I would like to know modelB rotation relative to modelA transform.

I tried InverseTransformDirection but it doesn't seem to work for me. How could I then express a rotation as a direction and vice-versa?

EDIT: let me rephrase: how do I compute manually the localRotation value when the model is actually not parented? That is, what is the localrotation of modelB as if it was parented to modelA? I am not trying to modify the actual localrotation of modelB, I just need to know it to inject it in the rotationTarget of a joint.

thanks for your help,

Jean

To construct a Quaternion rotation from one orientation to another, you could try:

Quaternion rotationDelta = Quaternion.FromToRotation(modelA.transform.forward, modelB.transform.forward);

This means that if you multiplied modelA.transform.rotation by rotationDelta, you'd end up "turning" modelA's orientation to face the same direction as modelB's orientation. Hope that makes sense (and I hope I didn't get it wrong).

Basically, once you get that quaternion rotation is all about relativism, it kind of starts to make sense.