# Transfer Scale from one Matrix to another

On 06/12/2013 at 02:03, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R13-R14
Platform:   Windows  ;
Language(s) :      XPRESSO  ;

---------
I am not sure how to do this.
For the position, is is easy:

Matrix matrix_A;
Matrix matrix_B;
matrix_B.off = matrix_A.off;

What is the corresponding way for the scaling?

On 06/12/2013 at 04:39, xxxxxxxx wrote:

In order to get the scales (vector) out of a matrix, you need to get the length of each axis basis:

Vector scale = Vector(Len(matrix_A.v1), Len(matrix_A.v2), Len(matrix_A.v3);
matrix_B.v1 = !matrix_B.v1 * scale.x;
matrix_B.v2 = !matrix_B.v2 * scale.y;
matrix_B.v3 = !matrix_B.v3 * scale.z;

This information is in the SDK documentation.

On 06/12/2013 at 05:11, xxxxxxxx wrote:

Ok, thanks, tat is indeed a lot, just to keep the scaling.
I often do some calculations on Quaternions, and the unwanted side effects is that scaling is influenced too, even if it is the rotation only, that I am interested in.

Quaternion q_A;
q_A.SetMatrix(inputMatrix);
Quaternion q_B = QMul(q_A, 1.5);
Matrix resultMatrix = q_B.GetMatrix();

I get the resulting rotation I am after,  but I get the scale multiplied by 1.5 too.
So I have to write the code you submitted, OK. No simpler way..

On 06/12/2013 at 06:14, xxxxxxxx wrote:

You could simply get the normalized matrix.  That is, it will only contain the rotations and turn any scaling into unity (1s).

Matrix resultMatrix = q_b.GetMatrix();
resultMatrix.Normalize();

On 06/12/2013 at 06:38, xxxxxxxx wrote:

I will have a look at Normalize(), maybe it will do what I want. But in case the original scale is _<__>_ 1, I will need to use the first code you provided.