2
$\begingroup$

I have 2 matrices and have been trying to multiply them but to no avail. Then I found this online site and trying feeding it the values but yet no success.

- R' . T

is what i would like to do but R is a 3x3 (3 rows, 3 cols) matrix and T is a 1 x 3 matrix (1 row, 3 cols).

Any idea how to go ahead with this?

4 Answers 4

4

You can only multiply an $n\times m$ matrix by a $p\times q$ matrix, in that order, if $m=p$. That is, only if the number of columns of the first factor is equal to the number of rows of the second factor. So you cannot multiply a $3\times 3$ matrix by a $1\times 3$ matrix; on the other hand, you can multiply a $1\times 3$ matrix by a $3\times 3$ matrix (so you can do $TR$); or you can multiply the $3\times 3$ matrix by the transpose of $T$, which would be $3\times 1$.

You can try extending $T$ into a $3\times 3$ by adding two rows of zeros (that is what the site you linked to does), but then you are not really multiplying $R$ by $T$. All you are doing is multiplying the first column of $R$ by the first entry of $T$, the second column of $R$ by the second entry of $T$, and the third column of $R$ by the third entry of $T$.

So the real question is: where did the matrices come from and why are you trying to multiply them in that order? Perhaps it turns out you shouldn't be doing that product at all...

  • 0
    The original formula is Xc = R . Xw + T and now I am trying to solve for Xw with Xc = (0, 0, 0)2010-11-23
  • 2
    @Kevin Boyd: Sigh: What is $X$? What is $c$? What is $R$? What is $T$? Where *do they come from*? What do they represent? Is $w$ a vector? If so, it must be a *column* vector, not a row vector (or the transpose of a row vector).2010-11-23
  • 0
    This is the formula for camera calibration Xc co-ordinates(x, y, z) in the camera reference plane and Xw co-ordinates (x, y, z) in the world reference. R is the Rotation matrix and T is the translation matrix.2010-11-23
  • 2
    @Kevin Boyd: Then your $Xc$ and $Xw$ must be column vectors, not row vectors: that is, they are $3\times 1$ vectors, not $1\times 3$. Just identify the vector $(x,y,z)$ with the corresponding column vector $(x,y,z)^t$. They amount to the same thing, but now you can do the product.2010-11-23
  • 0
    @ Arturo Magidin: This might work out, do you mean to say that T is a 3x1 matrix. Also what is (x,y,z) raised to t2010-11-24
  • 0
    @Kevin Boyd: $(x,y,z)^t$ is the transpose of $(x,y,z)$. The transpose of a matrix is the matrix you get by making the rows into columns and the columns into rows. So $(x,y,z)^t$ is a $3\times 1$ matrix, with $(1,1)$ entry equal to $x$, $(2,1)$ entry equal to $y$, and $(3,1)$ entry equal to $z$. And yes, pressumably $T$ is also a $3\times 1$ matrix. Basically, you are using **column** vectors, not row vectors. See http://en.wikipedia.org/wiki/Column_vector2010-11-24
  • 0
    @ Arturo Magidin: Here's another link to the formula http://opencv.willowgarage.com/documentation/camera_calibration_and_3d_reconstruction.html. I think you are possibly right the multiplication works for now and they seem to be column vectors.2010-11-24
  • 0
    @Kevin Boyd: Sigh; the very first display *clearly* has column vectors. In fact, every vector I can spot is a column vector. What led you to think they were row vectors?2010-11-24
  • 0
    @Arturo magidin: I don't know, actually I didn't assume it, its just that I didn't know the deal between column and row vectors.2010-11-24
2

The usual matrix multiplication is only defined for multiplying an $m\times n$ matrix with an $n\times R$ matrix. So the number of columns of the first matrix must be equal to the number of rows of the second for matrix multiplication to be defined. This is not satisfied by the matrices you have. So you cannot multiply them in that order. You can, however, multiply $T$ with $R$ i.e. the product $TR$ is defined but not $RT$.

  • 0
    is there way to convert the 1x3 matrix to 3x3?2010-11-23
  • 1
    @Kevin Boyd: You can pre-multiply it by its transpose, or by any $3\times 1$ matrix. But really: the best solution is for you to say *where* these matrices come from and what you are trying to achieve. Perhaps you are just trying to do the wrong operation (or the right operation in the wrong order).2010-11-23
2

Suppose you have two matrices A and B. Let A be a 3x3 matrix and B be a 1x3 matrix.

As stated above, you can only multiply matrix C (mxn) by matrix D (pxq) if n=p. That is, the number of columns in C = the number of rows in D.

We see that for your problem, we have the following information, $m=n=q=3$ and $p=1$.

Thus we have that $ n \neq p$.

If you insist on multiplying these two matrices together, you could always take the transpose of matrix B, denoted $B^{T}$. (For information about transposed matrices, see [1].)

$B^{T}$ would be a 3x1 matrix. So you could in fact do $AB^{T}$.

For more on matrix multiplication in general, see [2]. I hope this is helpful!

[1] Weisstein, Eric W. "Transpose." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/Transpose.html

[2] Weisstein, Eric W. "Matrix Multiplication." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/MatrixMultiplication.html

0

From what I can see, perhaps you have the R and Xw matrix switched around. If you had Xw*R, then I think it would be okay. Did you derive this formula or did you find it somewhere?

  • 0
    I got the formula from several places. One of them is from http://en.wikipedia.org/wiki/Camera_resectioning2010-11-24