# How do I calculate a change of coordinates given two lines as new axis?

Suppose we have an old coordinate system using the variables $x$ and $y$. We are given two equations for lines to form the axis for new coordinates. e.g. The line $z=0$ is given by the equation $y = m_1 x + b_1$, and the line $w=0$ is given by the equation $y = m_2 x + b_2$. Now suppose we are given a point $(x_3, y_3)$. What are the $w$ and $z$ coordinates of this point?

-
I think that I was making this out to be harder than it is. I only have to calculate the distance from one line, i.e. $z=0$, to get the $w$ coordinate, and vice versa. I guess that's as easy as it will get. – Matt Groff Jul 6 '12 at 11:51
Re: your comment, Are the two axes necessarily perpendicular? – anon Jul 6 '12 at 11:52
@anon: No. I guess that distance won't work. I'm hoping for the simplest possible method. – Matt Groff Jul 6 '12 at 11:53
Note that there is actually more than one such coordinate transformation: for any such transformation, we can rescale the two coordinates afterwards, and composing the two procedures together is a different coordinate transformation. There is an obvious geometric case though: projecting points directly onto the lines, and then measuring the distance from the intersection along each line and making those two quantities the new coordinates. – anon Jul 6 '12 at 11:58
@MattGroff I don't think it should be CW; the possibilities are easy to describe (in fact my comment provides the way to obtain all possibilities from just one possibility (assuming of course you want rectilinear coordinates)). – anon Jul 6 '12 at 12:10

Let $\bf p$ be the intersection point of the lines, and let $\bf u$ and $\bf v$ be unit direction vectors associated to the two lines. The first part of the transformation should translate $\bf p$ to $\bf 0$; so wlog assume $\bf p=0$.

We want to write $\mathbf{x}=a\mathbf{u}+b\mathbf{v}$; to do this, form the matrix $\mathrm{U}=[\bf u~v]$ (we assume vectors are column vectors), so we can write $\mathbf{x}=\mathrm{U}[a~b]^T$ and hence we solve for $a,b$ via $[a~b]^T=\mathrm{U}^{-1}\bf x$. Then $\bf x$ in the old coordinates corresponds to $[a~b]^T$ in the new coordinates.

Two changes-of-coordinates of the sort we want are related by a third coordinate change taking place in the second coordinates. This new coordinate change preserves the origin and two axes, and therefore is precisely a rescaling of the $a$- and $b$-axes individually.

-

Let $P$ be the point $(x_3,y_3)$. Draw lines parallel to both $y=m_1x+b_1$ and $y=m_2x+b_2$ through $P$ and suppose those parallel lines meets $y=m_1x+b_1$ and $y=m_2x+b_2$ at $A$ and $B$ respectively. If $O$ is the intersection point of $y=m_1x+b_1$ and $y=m_2x+b_2$ then $(w,z)=(|OB|,|OA|)$

-

There is not enough information to convert coordinates. We are given the location of the axes, but not the coordinate scale on those axes. The $z$ and $w$ coordinates can be given by \begin{align} z&=c_1(\color{#C00000}{m_1x+b_1-y})\\ w&=c_2(\color{#C00000}{m_2x+b_2-y}) \end{align}\tag{1} for any $c_1,c_2\not=0$. Given the $(x,y)$ and $(z,w)$ for some point not on the $z$ or $w$ axes (so that we can divide by the red terms in $(1)$), we can compute $c_1$ and $c_2$, which determines the conversion $(1)$.

-