Sign in to follow this  
derek7

column vector and row vector

Recommended Posts

derek7    100
I think it is two different thing that column vector mutily matrix and row vector multiply matrix . So why some book imply the two thing is almost the same. it is just a preferring that use column vector or row vector. it come from a book : "n this book, we will use column vectors only when the distinction between row and column vectors is not important. If the distinction is at all relevant (for example, if vectors are used in conjunction with matrices), then we will use row vectors." what make the two different is not important? the other one: How Does a Matrix Transform Vectors? It must use row vector?

Share this post


Link to post
Share on other sites
Illco    928
The difference is important but they are indeed almost the same:

Row vector:
[x y z]

Column vector:
[x
y
z]


They are related by the transpose function, denoted by an apostrophe:

[x y z]' = [x
y
z]
[x
y ' = [x y z]
z]


Perhaps you recall from linear algebra that for matrix multiplication the number of columns of the first matrix must equal the number of rows of the second matrix. A 3D row vector is essentially a matrix with one row and three columns. So if we want to multiply a vector with a matrix, the number of columns of the vector must equal the number of rows of the matrix.

Now you can see that only the row vector satisfies that property and hence row vectors must be used. Because of the transpose the distinction is not that important because at anytime a column vector can be transposed to a row vector and used for multiplication.

Greetz,

Illco

Share this post


Link to post
Share on other sites
meeshoo    512
The difference is that matrix multiplication is order dependent (A * B != B * A). Take a look at matrix multiplication, and you'll see that you multiply the rows from A with columns from B. Also says that if A has m rows and n columns, then B must have n rows and p columns. So it depends if A is the vector (in which case is a row) or B is the vector(in which case is a column). A vector is a matrix with one of the dimensions set to 1.

Share this post


Link to post
Share on other sites
haegarr    7372
Vector-vector operations are almost computationally the same regardless whether you use column or else row vectors. However, multiplying by a matrix is not commutative, so it plays a role whether to multiply from the right or else from the left. You know it from concatenating transformations:
M1 * M2 != M2 * M1

If using column vectors
v' := M * v
could also be written using row vectors
v'^T := v^T * M^T
what may be written due to _substitution_ (please notice the inherent difference):
v' := v * M

So it is just a mathematical thing to consider. In the end it makes no difference: Your 3D world would be the same either.

EDIT: Please notice that transposition as is mentionend by Illco above is herein denoted by the exponent T, and that the apostroph herein denotes the resulting vector!

[Edited by - haegarr on November 25, 2005 4:32:13 AM]

Share this post


Link to post
Share on other sites
derek7    100
Quote:

So it is just a mathematical thing to consider. In the end it makes no difference: Your 3D world would be the same either.

EDIT: Please notice that transposition as is mentionend by Illco above is herein denoted by the exponent T, and that the apostroph herein denotes the resulting vector!


you mean transposition of matrix and origin matirx is total the same in 3d world?
also: M1 * M2 = (M1 * M2)^T ??

Share this post


Link to post
Share on other sites
haegarr    7372
Quote:
Original post by derek7
you mean transposition of matrix and origin matirx is total the same in 3d world?
also: M1 * M2 = (M1 * M2)^T ??

Definitely _not_!!

I gave an alternative kind of writing! Please notice my comment "(please notice the inherent difference)" in the previous post! See the full formula with the transposes in it: There you see that the both matrices are _not_ the same.

What I meant was, that regardless whether you use column or else row vectors, your world would become the same _if you are using it consistently correct_.


EDIT: For some class of matrices M == M^T, e.g. for diagonal matrices (the identity matrix as the best known, but also pure scale matrices). But that were special cases.


EDIT2: If you're interested in: ( M1 * M2 )^T = M2^T * M1^T <=> M1 * M2 = ( M2^T * M1^T )^T [notice the reversed order].

[Edited by - haegarr on November 25, 2005 5:17:38 AM]

Share this post


Link to post
Share on other sites
derek7    100
I see!!

If transform vector V by matrix M, I could do:

V` = VM or V`T = M^T * V^T

V` = V`T in single vector


so if you use row vector (D3D) just do VM for transform V by M.
if you use column vector (OPENGL) first you need transpose M , then multiply V that is : M^T * V(alread is column) M3^T * (M2^T * (M1^T * V))

[Edited by - derek7 on November 25, 2005 9:27:00 AM]

Share this post


Link to post
Share on other sites
haegarr    7372
Yes, you're right if M is always the same. The whole stuff depends in what kind of representation your stuff is given. E.g. my own engine is written using column vectors. So I could use my matrices everywhere where column vectors are expected as are. However, as soon as I have to provide my matrices to an API that expects row vectors, I have to transpose it before passing.

(Notice that APIs have another issue named "row/column major order", what is also to be considered but is something different from what we discuss here.)

Quote:
Original post by derek7
V` = V`T in single vector

I haven't understood what you've meant here, sorry.

Quote:
Original post by derek7
M3^T * (M2^T * (M1^T * V))

Just for clarity: This is correct if you have a trafo
M := M1 * M2 * M3
given in row vector format, and you wish it to be in the column vector format. (But look at V which mathematically correct should be V^T).
However, the brackets are not needed since (M1 * M2) * M3 = M1 * (M2 * M3).


BTW: The transpose of a vector is normally not explicitely programmed. So one has to have the format always in mind, or else confusion will come up ;-)

Share this post


Link to post
Share on other sites
LilBudyWizer    491
Well, in some cases there is a direct correspondance. Particularly ABC...Z=(ZT...CTBTAT)T. Both are equally valid ways to do it though the ordering is differant and the actual matrices/vectors used are transposes of one another. It would be rather tedious to keep explaining both ways when there is such a simple relationship between the two. They aren't really discussing multiplying matrices, but rather transforming vectors and concatenating transforms. You have two sets of rules as to how those operations are performed which are equally valid as long as you stick with one set of definitions. You also have definitions as to how a transform is represented as a matrix and those definitions when using one set is the transform of the definition using the other set of rules.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this