Welcome! Log In Create A New Profile

Advanced

Multimatrix drives me crazy

Posted by m.bauer588 
Multimatrix drives me crazy
January 06, 2019 07:08PM
Hallo.. I create that OpenSCAD code:

multmatrix([ 
    [1, 0, 0, 0],
    [0, 1, 0.4, 0], 
    [0, 0, 1, 0],
    [0, 0, 0, 1] 
    ]) cube([100, 30, 48]);
    
translate([120,0,0])
multmatrix([ 
    [100, 0, 0, 0],
    [0, 30, 20, 0], 
    [0, 0, 48, 0],
    [0, 0, 0, 1] 
    ]) cube([1, 1, 1]);

Why on earth are the both cubes identical? Why i need in one case a Scale Y sheared along Z with 0.4 and in the other case with the small cube scaled up i need 20?!
Re: Multimatrix drives me crazy
January 06, 2019 09:54PM
they are not identical

see
difference() {

multmatrix([ 
    [1, 0, 0, 0],
    [0, 1, 0.4, 0], 
    [0, 0, 1, 0],
    [0, 0, 0, 1] 
    ]) cube([100, 30, 48]);
    
multmatrix([ 
    [100, 0, 0, 0],
    [0, 30, 20, 0], 
    [0, 0, 48, 0],
    [0, 0, 0, 1] 
    ]) cube([1, 1, 1]);
    
}

0.4 should be 20/48 ie 0.416666667

Edited 2 time(s). Last edit at 01/06/2019 10:10PM by Dust.
Re: Multimatrix drives me crazy
January 07, 2019 03:06AM
OK I see - but why 20 and 0.41666667 makes it identical?

Does that mean for each unit in original-size shift X units?
So 1 x 20 = 20 Units and 48 x 0.4166667 = 20?
Is that how it works?
Re: Multimatrix drives me crazy
January 07, 2019 03:32AM
The first example you have normalized all values in the array (ie they have values from 0-1)
And the second example you have normalized the values in the cube

In the first eg
X values in the array are divided by X in the cube to get 1
Y values are divided by the Y
And Z values divided by the Z

Now the value in question is "Scale Y sheared along Z"
So it needs to be divided by the Z value 48 to be normalized. and 20 comes from your second example.

the normalized array is really
multmatrix([
[100/100, 0/30, 0/48, 0],
[0/100, 30/30, 20/48, 0],
[0/100, 0/30, 48/48, 0],
[0, 0, 0, 1]
]) cube([100, 30, 48]);


This is feeling like i'm doing your CS homework...
Re: Multimatrix drives me crazy
January 07, 2019 04:38AM
Quote
Dust
This is feeling like i'm doing your CS homework...

I try to use some parameters in a model and each resize results in another angle... Math is really not my cup of tea!
I have no idea what you mean with normalized and why you need to do it but anyway it work for me to calculate "for each unit in original-size shift X units"

Thanks.

PS.: What is CS?

Edited 1 time(s). Last edit at 01/07/2019 04:39AM by m.bauer588.
Re: Multimatrix drives me crazy
January 07, 2019 05:01AM
CS - computer science.

ok...

This is a breakdown of what you can do with the independent elements in the matrix (for the first three rows):
[Scale X] [Scale X sheared along Y] [Scale X sheared along Z] [Translate X]
[Scale Y sheared along X] [Scale Y] [Scale Y sheared along Z] [Translate Y]
[Scale Z sheared along X] [Scale Z sheared along Y] [Scale Z] [Translate Z]

So if all you want to do is resize Y, you change the Scale Y value (other dimensions need to be multiplied by 1 so they stay the same.)

eg 2 * Y, 1 * X and 1 * Z

multmatrix([ 
[1, 0, 0, 0],
[0, 2, 0, 0], 
[0, 0, 1, 0],
[0, 0, 0, 1] 
]) cube([100, 30, 48]);


If you only modify the Scale, X or Scale Y or Scale Z values you won't get any shearing (weird angles)

Edited 1 time(s). Last edit at 01/07/2019 05:07AM by Dust.
Sorry, only registered users may post in this forum.

Click here to login