How do i scale 2D vector using matrix

4.3k Views Asked by At

I know that scale matrix is 2x2 { x, 0, 0, y } basis.

My vector { 100, 2 } and i want to scale it using custom 2x2 matrix. I've read that if left operand is 2D row vector, then multiplying it on a 2x2 matrix should result in 1x2 matrix (row vector). Is it true statement?

If so, i must get 1x2 matrix { 1000, 20 } as product of my vector and basis. But i cannot write a program for this because i do not understand how do i represent my vector as matrix (because i cannot calculate 1x2 * 2x2)

Should my vector be matrix 1x2, or 2x1 or 2x2? If 2x2, how do i place the vector components in cells?

1

There are 1 best solutions below

1
On BEST ANSWER

What you read is correct: We can multiply a $1\times 2$ matrix and a $2\times 2$ matrix in that order and the end result is another $1\times 2$ matrix. For your problem, it seems you want to find a $2\times 2$ matrix to multiply your vector by and get $10$ times the original vector. The simplest way to do it of course is just to directly multiply your vector by the constant $10$, but if we want a $2\times 2$ matrix anyway, $10I_2$ will do:

$$[\begin{matrix}100&2\end{matrix}]\left[\begin{matrix}10&0\\0&10\end{matrix}\right]=[\begin{matrix}1000&20\end{matrix}]$$

If you wanted, we could instead use a column vector representation of your matrix, but in that case we would need to switch the order of multiplication: $$\left[\begin{matrix}10&0\\0&10\end{matrix}\right]\left[\begin{matrix}100\\2\end{matrix}\right]=\left[\begin{matrix}1000\\20\end{matrix}\right]$$

In general, if we have a vector $[\begin{matrix}a&b\end{matrix}]$ and a scale matrix $\left[\begin{matrix}x&0\\0&y\end{matrix}\right]$, we have $$[\begin{matrix}a&b\end{matrix}]\left[\begin{matrix}x&0\\0&y\end{matrix}\right]=[\begin{matrix}ax&by\end{matrix}]$$ Hence if you know your starting vector (in your case $a=100$, $b=2$) and the desired final vector (in your case $ax=1000$ and $by=20$), we can calculate what the scale matrix should be since $x=\frac{ax}{a}$ and $y=\frac{by}{b}$ (in your case we get $x=\frac{1000}{100}=10$ and $y=\frac{20}{2}=10$).