Remind me: How do we convert coordinates to space with different basis and origin? I'm stuck with the very beginning of my homework. I might've even misunderstood the task. I'll try to translate the assignment in case I fail to explain what I need later:

Task description:
Every student has his own task, described in external file. On the image for your task, you'll see two coordinate systems: $O$, $\beta$ and $O^\prime$, $\beta^\prime$ where bases are:

*

*$\beta\,=\,(\vec{b_1},\vec{b_2})$

*$\beta'\,=\,(\vec{b_1}',\vec{b_2}')$
Tasks

*

*Write coordinates of basis vectors $\beta$ in basis $\beta'$.

*Write coordinates of basis vectors $\beta$ in basis $\beta$.

*Write formula to convert coordinates of system $O^\prime$, $\beta^\prime$ to system $O$, $\beta$.

*Implement Matlab function that converts coordinates of system $O^\prime$, $\beta^\prime$ to coordinate system $O$, $\beta$.


Therefore this whole task is based upon converting between systems with different origin and base. This is one of basic things we were taught in Linear algebra year ago. Year is a long time and I have forgotten almost everything.
I could look up that for 2D systems, change for vector $v$ to basis $\beta^\prime$ can be done as:
$$v^\prime = {\beta^\prime}^{-1} v$$
But what about the beginning point $O'$? For illustration, here's my assigned image:

And I'll be given vector $v'$ in the $O^\prime$, $\beta^\prime$ coordinates. My task will be to convert it into $O$, $\beta$ coordinates. I'm sure this must be simple matrix equation.
 A: You're right, it's simple. You have to (left) multiply the $\beta'$-coordinates of $v'$  by the change of basis matrix (change from $\beta$  to $\beta'$), the column vectors of which are the $\beta$-coordinates of the vectors in $\beta'$.
To combine this with the change of origin, observe that for a point $M$, we can write $$\overrightarrow{OM}=\overrightarrow{OO'}+\overrightarrow{O'M}.$$
The coordinates of $M$ in the $(O,\beta)$ system are the coordinates of $\overrightarrow{OM}=\vec v$ in basis $\beta$. Its coordinates  in the $(O',\beta')$ system are the coordinates of $\overrightarrow{O'M}$ in basis $\beta'$.
Now the coordinates of $\overrightarrow{O'M}=\vec{v'}$ in basis $\beta$ are $P\vec{v'}$ and observe the coordinates of $\overrightarrow{OO'}$ are expressed in basis $\beta$. Thus:
$$\vec v=\overrightarrow{OO'}+P\vec{v'}.$$
A: The actual matlab command:
% Convert vectors in Xi from base B2 and origin O2 to B1 and O1
function Xo = mybasetrans(O1, O2, B1, B2, Xi) 
   % We'll need ones matrix which then expands into long matrix 
   % depending on how many vectors are in Xi
   n = size(Xi);
   n = n(2);
   % This is the shift of origin points, using the canonic coordinates
   zeropoint = (O2-O1)*ones(1, n);
   % This is the matrix multiplication
   % to convert vector to base use inv(BASE)*vector
   % so backwards, to convert it to canonic, use BASE*vector
   % In this case, we convert from B2 to B1
   Xo = B1\(B2*(Xi) + zeropoint);
end

The equations for one vector are:
$$v = {\beta}^{-1}({\beta^\prime} v^\prime + O^\prime - O)$$
The multiplication must be from the left!
