# Transpose Matrix

On 02/07/2017 at 10:40, xxxxxxxx wrote:

Hello,

How can I transpose a matrix in C4D ? Is it possible ?

It seems that le C4D matrix are 4x4 but the first line can't be changed (always 0,0,0,1) ?

My goal is to get or calculate the normalMatrix, but not in a shader context.

Thanks

On 02/07/2017 at 12:04, xxxxxxxx wrote:

Ok, it seems that we don't care beause the first will line will be the offset matrix component :

``````
1     0     0     0
v0.x  v1.x  v2.x  v3.x
v0.y  v1.y  v2.y  v3.y
v0.z  v1.z  v2.z  v3.z

Transposed :

1    v0.x  v0.y  v0.z
0    v1.x  v1.y  v1.z
0    v2.x  v2.y  v2.z
0    v3.x  v3.y  v3.z

``````

So with an offset v0 of (0,0,0), we will still get the first line correct.

``````    def TransposeMatrix(m) :

v1 = Vector(m.v1.x, m.v2.x, m.v3.x)
v2 = Vector(m.v1.y, m.v2.y, m.v3.y)
v3 = Vector(m.v1.z, m.v2.z, m.v3.z)

m.v1 = v1
m.v2 = v2
m.v3 = v3
m.off = Vector()
``````

Can you confirm me ? :-)

On 03/07/2017 at 06:44, xxxxxxxx wrote:

Hi César,

unfortunately I can only confirm that there is no function to transpose a matrix in our Python SDK.
To me, your transposed matrix in the last post looks ok.

Maybe you can tell us a bit more detail about what you are trying to achieve in the end, so we could ask our development for ideas?

Or you use something like numpy, I think Niklas once posted, that he has prepared packages for use with C4D.

On 05/07/2017 at 14:44, xxxxxxxx wrote:

Thanks for the info.

Well, it's for create a Spherical Environment UV projection, for very specific baking process.