Coordinate transformation (global to local)

Hi all! :slight_smile:

I just would like to make a coordinate transformation from points given in the global coordinate system to a local coordinate system (also defined in global CS by r and axes). Mathematically I would say:

Pglob = R * Ploc + t

with the rotation matrix R and the translation t.
R = {axes1, axes2, axes3};
t = r;

This will lead to:
Ploc = inv® * (Pglob - t)

How do I translate this into AnyScript or is there even a defined class? The formulation:

AnyVec3 Ploc = R’ * (Pglob - t)’;

Did not work for me.

Thanks a lot and I appreciate any help!

Dear Malte,

It will be easier for you if you can see the explanation of the ‘AnyRefFrame’ class in the AnyBody reference manual.

[i]Notice that AnyBodyâ„¢ stores all vectors in row format, so they must be transposed before the transformation and the expression must be turned around. In AnyScriptâ„¢ syntax this looks like

GlobalVector = (Axes * LocalVector’)’;


GlobalVector = LocalVector * Axes’; [/i]

I hope this may help you.

Best regards,

Dear Moonki,

thanks for your response! However, the described transformation is forward and does not take the translation into account. I discovered some bugs in my code (column format in the matrix). Finally the following equation worked:

AnyVec3 LocalVector = (Shank.Axes’*(GlobalVector-Shank.r)’)’;

Best wishes,
Malte :slight_smile: