Change of coordinates (referential system) mistake? Doesn't seem to yield the proper coordinates. 
Let $\varepsilon$ be an affine space with referential system $R$
  characterized by $O=(1,1,1)$ as origin and $B=(c_1,c_2,c_3)$ as its
  basis, which is the canonical. 
Now, lets define a new referential system $R'$ characterized by
  $O'=(0,1,1)$ as its origin and
  $B'=\left\{(0,1,-2),(1,1,1),(1,0,1)\right\}$ as its basis.

I'd like to find the expression to go from one system to another, that is, to find the coordinates of a point in $R'$ by knowing the ones in $R$, and viceversa. As far as I know, that is achieved by the formula $X'=X_0+M\cdot X$, where $X,X'$ are the coordinates of a point in $R,R'$, respectively, and $X_0$ are the coordinates of $O$ in $R'$.
And $M$ is of course, the transformation matrix to go from $B$ to $B'$. Now, since we are going from the canonical to another basis, its easy to form $M$ since its just the matriz that contains the vectors of $B'$, that is:
$M = \begin{pmatrix} 0&1&1\\ 1&1&0\\ -2&1&1 \end{pmatrix}$
Now, to find the coordinates of $O$ in $R'$, I have to find the coordinates of $\vec{O'O}$ in $B'$. In $B$, they are $(1,1,1)-(0,1,1)=(1,0,0)$. Then I can use $M$ as follows:
$X_0=\begin{pmatrix} 0&1&1\\ 1&1&0\\ -2&1&1 \end{pmatrix}\cdot\begin{pmatrix} 1\\ 0\\ 0 \end{pmatrix}=\begin{pmatrix} 0\\ 1\\ -2 \end{pmatrix}$
Now, I have theoretically everything I need to be able to get points from one referential system to another. To make sure everything went properly, I checked whether the formula works for the origins themselves. So, to get $O$ in $R'$ I would do:
$O'=\begin{pmatrix} 0\\ 1\\ -2 \end{pmatrix}+\begin{pmatrix} 0&1&1\\ 1&1&0\\ -2&1&1 \end{pmatrix}\cdot\begin{pmatrix} 1\\ 1\\ 1 \end{pmatrix}=\begin{pmatrix} 0\\ 1\\ -2 \end{pmatrix}+\begin{pmatrix} 2\\ 2\\ 0 \end{pmatrix}=\begin{pmatrix} 2\\ 3\\ -2 \end{pmatrix}$
Which is wrong! As I defined $O'=\begin{pmatrix} 0\\ 1\\ 1 \end{pmatrix}$
So basically something went wrong, and I can't seem to find my mistake. Could anyone help me on this?
 A: I  think it should go like this. Take a point $P$, then
$$
P = a_1c_1+a_2c_2+a_3c_3+O = a'_1b'_1+a'_2b'_2+a'_3b'_3 + O'
$$
You want the $a'_i$, that is the quantities in the prime basis. Given your definitons we get
$$
\begin{pmatrix}
a_1\\a_2\\a_3  
\end{pmatrix}
+
\begin{pmatrix}
1 \\ 0 \\0  
\end{pmatrix} 
= 
\begin{pmatrix}
0& 1 &1 \\1& 1 & 0\\-2& 1 &1 
\end{pmatrix}
%
\begin{pmatrix}
a'_1\\a'_2\\a'_3  
\end{pmatrix}
$$
from which we deduce, with $A$  the inverse of the matrix above,
$$
\begin{pmatrix}
a'_1\\a'_2\\a'_3  
\end{pmatrix}
=
A\left(
\begin{pmatrix}
a_1\\a_2\\a_3  
\end{pmatrix}
+
\begin{pmatrix}
1 \\ 0 \\0  
\end{pmatrix} \right)
$$
That is if you want the primed coordinates knowing the unprimed ones. The opposite case is a simple rearrangement of the first equation.
To get better accustomed to these things, one can consider the simpler case of the real line. Take a point $P$ along it. It is necessary defined if some origin $O$  and a basic vector $v$ is defined. 
Example: $O=2$, $v=3$ Then if $P=O + pv = 2 + p3$. $p=1$ represents number $5$. 
Changing the origin to $O'$ and basic vector $v'$ leaves
$P=O' + p'v'=O+pv \Rightarrow p'=\dfrac {1}{ v'}(O-O'+pv)$
Example: Let us find number $5$ again, with $O'=0$ and $v'=1$
$p'= \frac{1}{ 1} (2+ 3)=5$, as expected given the choice of $O'$ and $v'$.
