# Conversion between 2 different coordinate systems

I am using the math from this artice: https://msdn.microsoft.com/en-us/library/jj635757(v=vs.85).aspx to create a generic conversions matrix I can use to convert between 2 coordinate systems.

If I apply it to the examples the math works perfectly, but if I try to use it between 2 coordinate systems defined by these points

$$(x1, y1) = (1, 1)$$ $$(x'1, y'1) = (1, 1)$$ $$(x2, y2) = (2, 2)$$ $$(x'2, y'2) = (2, 2)$$

Basically, this is the same coordinate system so I would expect a transformation on a point to result in the same point.

Using the math from the article I get this

$$\mathbf{M} = \begin{bmatrix} 1 & 1 & 1 & 0 \\ -1 & 1 & 0 & 1 \\ 2 & 2 & 1 & 0 \\ -2 & 2 & 0 & 1 \\ \end{bmatrix}$$

and

$$\mathbf{u} = \begin{bmatrix} 1 \\ 1 \\ 2 \\ 2 \\ \end{bmatrix}$$

And the result is that

$$a=0$$$$b=1$$$$c=0$$$$d=0$$

So when I use these numbers to convert (2, 1) I would like to get (2, 1) but I get (1, 2)

$$x = ax + by + c = 0*2 + 1*1 + 0 = 1$$ $$y = bx - ay + d = 1*2 + 0*1 + 0 = 2$$

• Welcome to MSE. Please use MathJax to format your question. – user507623 Jan 8 '18 at 13:59

What you have gotten is a transformation which reflects your coordinate system across the $y=x$ line; in other words, it switches the $x$-axis and the $y$-axis. So $(1,1)$ is still $(1,1)$ and $(2,2)$ is still $(2,2)$, but $(2,1)$ becomes $(1,2)$, as you noted.
For whatever reason, the math in that article doesn't allow a transformation which keeps the coordinate system the same. Getting $x' = x$ which require $a = 1$, but getting $y' = y$ would require $a = -1$.