Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

matrix manipulation

Started by jcrennes2 Aug 8, 2007 at 10:25 AM 10 replies 1.2k views
Original Post
jcrennes2
jcrennes2
hi everyone, I have a vector u=(x y z) and I would like to transform it (by some linear manipulations) into the following matrix: (x 0 0) (0 y 0) (0 0 z) in matlab notation: [x 0 0; 0 y 0; 0 0 z] Concretely I would like to find some matrices A and B, for example, such that: [x 0 0; 0 y 0; 0 z 0]=A*[x y z]*B I know that there exists the function diag() in matlab but I would like to use some linear relations to build such a matrix. Is there somebody that could help me? Thank you very much JC
Alrecenk
Alrecenk
I don't see how this relates to game programming (or programming at all), and I have no way of knowing that it isn't homework...
jcrennes2
jcrennes2
well, as you know, using some loops "for" is time consuming. At the contrary, if you use some dedicated optimized matrix manipulation algorithms, you can manipulate and create your matrices much more quickly (in execution time point of view). I am trying to develop such libraries to deal with my complex physic model more simply!
Driv3MeFar
Driv3MeFar
Edit: Nothing to see here.
Zakwayda
Zakwayda
Quote:
Original post by Driv3MeFar
[ 1 0 0 ]   [ x ]   [ x 0 0 ][ 0 1 0 ] x [ y ] = [ 0 y 0 ][ 0 0 1 ]   [ z ]   [ 0 0 z ]
I don't think this is what the OP is looking for (the product of a 3x3 matrix and a 3x1 matrix is a 3x1 matrix, not a 3x3 matrix).
Driv3MeFar
Driv3MeFar
Quote:
Original post by jyk
Quote:
Original post by Driv3MeFar
[ 1 0 0 ]   [ x ]   [ x 0 0 ][ 0 1 0 ] x [ y ] = [ 0 y 0 ][ 0 0 1 ]   [ z ]   [ 0 0 z ]
I don't think this is what the OP is looking for (the product of a 3x3 matrix and a 3x1 matrix is a 3x1 matrix, not a 3x3 matrix).


Haha, oops. You're right, of course.
Alrecenk
Alrecenk
I fiddled around with this for a little bit and I'm starting to think it might not be possible. If you have a 3x1 or a 1x3 then you'll need a 1x3 or 3x1 respectively so you can get it to be a 3x3. assuming you'll use [1 1 1] you'll end up with something like:
[x x x]    [x y z][y y y] or [x y z] depending on whether you use row or column vectors[z z z]    [x y z]

From there I'm stumped. It appears that you'd need to be able to do the same multiplication and get different answers. Perhaps I am missing something though....This would be trivial if you used a third rank tensor...
Anthony Serrano
Anthony Serrano
Quote:
Original post by Alrecenk
Perhaps I am missing something though....This would be trivial if you used a third rank tensor...


Or just copy Vectori to Matrixi, i, and fill the rest with zeros.

Why try for something complicated when there's a simple, well-known, O(n2) algorithm.
Jerax
Jerax
Quote:
Original post by Anthony Serrano
Quote:
Original post by Alrecenk
Perhaps I am missing something though....This would be trivial if you used a third rank tensor...


Or just copy Vectori to Matrixi, i, and fill the rest with zeros.

Why try for something complicated when there's a simple, well-known, O(n2) algorithm.


That's also going to be a lot faster than any series of linear transforms due to lack of multiplications.
Alrecenk
Alrecenk
I concur, but getting on people about trying completely impractical solutions for solved problems would make me a hypocrite...
jcrennes2
jcrennes2
Quote:
Original post by Alrecenk
I fiddled around with this for a little bit and I'm starting to think it might not be possible. If you have a 3x1 or a 1x3 then you'll need a 1x3 or 3x1 respectively so you can get it to be a 3x3. assuming you'll use [1 1 1] you'll end up with something like:
*** Source Snippet Removed ***
From there I'm stumped. It appears that you'd need to be able to do the same multiplication and get different answers. Perhaps I am missing something though....This would be trivial if you used a third rank tensor...


what would be the advantage of a third rank tensor? I habe no idea what it is^^

I hope you can help me
Alrecenk
Alrecenk
A 3x3x3 tensor would contain enough values to define every element of the matrix as a linear combination of every element of the vector. However, I really meant that as a joke as it would require 27 multiplications and 18 additions, and you could do what your doing without any multiplications or additions.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.