Matrix Multiplication to translate object with given vertices

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 6K views
Phys121VIU
Messages
17
Reaction score
0
This was a question for a test of mine. I am unsure how to translate the object from the left image(Fig.1) to the right (Fig.2). I am to use matrix multiplication..

Do i start with the vertices in Fig.1 as a matrix, as in |0 -1 -2 0 -2 -1 |
...............|0 0 0 2 2 3 |

(I apologize, i don't know how to make large square brackets..)
 

Attachments

  • Midterm4,Q6.jpg
    Midterm4,Q6.jpg
    33.6 KB · Views: 727
Physics news on Phys.org
Phys121VIU said:
This was a question for a test of mine. I am unsure how to translate the object from the left image(Fig.1) to the right (Fig.2). I am to use matrix multiplication..

Do i start with the vertices in Fig.1 as a matrix, as in |0 -1 -2 0 -2 -1 |
...............|0 0 0 2 2 3 |

(I apologize, i don't know how to make large square brackets..)

Hey Phys121VIU.

In terms of translation matrices used in computer graphics, it's easier to use a 4x4 matrix with a 'w' co-ordinate to perform the transformation and then basically project a 4-vector to a 3-vector.

In other words your matrix will look like this:

[a b c d]
[e f g h]
[i j k l]
[m n o p]

where [d h l p]^T is going to be the translation co-effecients corresponding to the vector <x,y,z,w> for translation. If you make the upper LHS 3x3 matrix an identity and your [d h l p] matrix corresond to <Tx,Ty,Tz,0> then when you apply this matrix to a point X you will get Mx = x + T where T is the translation vector above.

Although the output vector is four-dimensional, your w component will be 0 and will reduce to a normal 3d vector if you project it onto the 3-D space where w = 0.

In terms of having a general matrix to do this for all the points, you can not have a 3D matrix that can be applied to all points to give you that result if you want the matrix itself to be a constant as opposed to something that varies with points.

If you want to do it with 3D matrices, then you will have to create a matrix that is a function of the points themselves and this will require extra work.

My guess is that they probably don't want something complicated, so a 4x4 matrix will do the trick along with a projection to the constraint w = 0.
 
Phys121VIU said:
This was a question for a test of mine. I am unsure how to translate the object from the left image(Fig.1) to the right (Fig.2). I am to use matrix multiplication..

Do i start with the vertices in Fig.1 as a matrix, as in |0 -1 -2 0 -2 -1 |
...............|0 0 0 2 2 3 |

(I apologize, i don't know how to make large square brackets..)

[tex]\begin{bmatrix}0 & -1 & -2 & 0 & -2 & -1 \\ 0 & 0 & 0 & 2 & 2 & 3\end{bmatrix}[/tex]
(Click on that to see the code.)

Those are the coordinates of 6 points in two-dimensions. A 2 by 2 matrix, of the form
[tex]\begin{bmatrix}cos(\theta) & -sin(\theta) \\ sin(\theta) & cos(\theta)\end{bmatrix}[/tex]
gives a rotation around the origin through angle [itex]\theta[/itex]. A translation would, normally, be a vector to be added.

But you can, as chiro says, use "projective" coordinates, with point (x, y) represented by (x, y, 1) with the understanding that if some operation causes the third coordinate to change, we divide each coordinate by that to get back to 1- the point (ax, ay, a) is the same point as (x, y, 1). However, I think chiro is giving the case of projective coordinates in 3 dimensions so the matrix has 3+ 1= 4 rows and columns. If you are working in two dimensions so your matrix should have 2+ 1= 3 rows and columns.

Doing that, a translation, adding a to the x-coordinate and b to the y coordinate, is given by
[tex]\begin{bmatrix}1 & 0 & a \\ 0 & 1 & b \\ 0 & 0 & 1\end{bmatrix}\begin{bmatrix}x \\ y \\ 1\end{bmatrix}= \begin{bmatrix}x+ a\\ y+ b\\ 1\end{bmatrix}[/tex]
 
Last edited by a moderator:
\begin{bmatrix}0 & -1 & -2 & 0 & -2 & -1 \\ 0 & 0 & 0 & 2 & 2 & 3\end{bmatrix}

(Click on that to see the code.)

Thanks for this!


Ok i am beginning to understand this question..To translate, say the top point of the object,
\begin{bmatrix}-1 \\ 3\end{bmatrix} to the new coordinate \begin{bmatrix}2 \\ 5\end{bmatrix} i would use
\begin{bmatrix}1 & 0 & 3 \\ 0 & 1 & 2 \\ 0 & 0 & 1\end{bmatrix}\begin{bmatrix}-1 \\ 3 \\ 1\end{bmatrix}= \begin{bmatrix}(-1)+3\\ 3+2\\ 1\end{bmatrix}

That is awesome! Thanks so much

Is there a quicker way to translate all of the coordinates? like in the 2x6 matrix shown above?

It seems if I go about the same method, I would need a 6x6 matrix..?
 
No, you can use the same "translation" matrix, just do it as a single matrix multiplication using all of the points as a single matrix:
[tex]\begin{bmatrix}1 & 0 & 3 \\ 0 & 1 & 2 \\ 0 & 0 & 1\end{bmatrix}\begin{bmatrix}0 & -1 & -2 & 0 & -2 & -1 \\ 0 & 0 & 0 & 2 & 2 & 3 \\ 1 & 1 & 1 & 1 & 1 & 1\end{bmatrix}=\begin{bmatrix}3 & 2 & 1 & 3 & 1 & 2 \\ 2 & 2 & 2 & 4 & 4 & 5 \\ 1 & 1 & 1 & 1 & 1 & 1 \end{bmatrix}[/tex]
 
Last edited by a moderator: