On the topic of matrix calculations, I believe it should be possible to split any given transformation matrix into two composing matrices where one would represent the rotation and the other would represent the scale. Essentially a matrix version of a "vector = unit_vector * scalar" equation, like a "matrix = rotation_matrix * scale_matrix" where rotation_matrix would contain the rotation of the matrix with no scaling and scale_matrix would be otherwise an identity matrix but with the scaling of the main matrix. Is this kind of split possible? If so, how to do it?
Matrix "split"
I decided to test my LDCad scripting api whith this as an exercise, it might hold some info for you.
Source:
Output:
Source:
Code:
src=ldc.matrix(
0, -4, 0,
4.243, 0, -4.243,
0, -8, 0,
-4.243, 0, -4.243
);
print('org: ', src);
a,b,c,d,e,f,g,h,i=src:getOri();
vx=ldc.vector(a, b, c);
vy=ldc.vector(d, e, f);
vz=ldc.vector(g, h, i);
lx=vx:length();
ly=vy:length();
lz=vz:length();
vx:normalize();
vy:normalize();
vz:normalize();
ori=ldc.matrix(vx, vy, vz);
print('ori: ', ori);
scale=ldc.matrix(
lx, 0, 0,
0, ly, 0,
0, 0, lz
);
print('scale: ', scale);
test=scale*ori;
print('scale*ori: ', test);
Output:
Code:
org: 0 -4 0 4.243 0 -4.243 0 -8 0 -4.243 0 -4.243
ori: 0 0 0 0.707 0 -0.707 0 -1 0 -0.707 0 -0.707
scale: 0 0 0 6.001 0 0 0 8 0 0 0 6.001
scale*ori: 0 0 0 4.243 0 -4.243 0 -8 0 -4.243 0 -4.243
It's unequivocally not possible in general. And 3x3 scaling matrix is defined by three values. Any 3x3 rotation matrix is defined by three values. Any 3x3 matrix is defined by nine values. Therefore you do not have enough information in the rotation and scaling to define any matrix.
As an example: consider a skewing matrx S=[1 0 1;0 1 0;1 0 1]. Unless I'm mistaken you absolutely cannot represent that by a rotation and scaling.
But... you can probably represent any matrix by a scaling, a normalised skewing and a rotation matrix. I'm not sure there's a simple rule for it though.
Tim
As an example: consider a skewing matrx S=[1 0 1;0 1 0;1 0 1]. Unless I'm mistaken you absolutely cannot represent that by a rotation and scaling.
But... you can probably represent any matrix by a scaling, a normalised skewing and a rotation matrix. I'm not sure there's a simple rule for it though.
Tim
« Next Oldest | Next Newest »
Users browsing this thread: 2 Guest(s)