Rotating x,y points 45 degrees I have a two dimensional data set that I would like to rotate 45 degrees such that a 45 degree line from the points (0,0 and 10,10) becomes the x-axis. For example, the x,y points (1,1), (2,2), and (3,3) would be transformed to the points (0,1), (0,2), and (0,3), respectively, such that they now lie on the x-axis. The points (1,0), (2,0), and (3,0) would be rotated to the points  (1,1), (2,2), and (3,3). How can I calculate how to rotate a series of x,y point 45 degrees?
 A: There are a few ways to work this out, but my favorite is with complex numbers.
If we represent the point $(x,y)$ by the complex number $x+iy$, then we can rotate it 45 degrees clockwise simply by multiplying by the complex number $(1-i)/\sqrt{2}$ and then reading off their $x$ and $y$ coordinates.
$$(x+iy)(1-i)/\sqrt{2} = ((x+y) +i(y-x))/\sqrt{2} = \tfrac{x+y}{\sqrt{2}} + i\tfrac{y-x}{\sqrt{2}}.$$
Therefore, the rotated coordinates of $(x,y)$ are $\big(\tfrac{x+y}{\sqrt{2}},\tfrac{y-x}{\sqrt{2}}\big)$.
If your data consists of rational numbers, scaling by $\sqrt{2}$ may be undesirable. In that case, you can leave the $\sqrt{2}$ out of the denominator, but then note that the points have been both rotated and scaled.
Finally, if $(u,v)$ is a point in your rotated coordinates and you want to get back to the original data, you just multiply $u+iv$ by $(1+i)/\sqrt{2}$, the inverse of $(1-i)/\sqrt{2}$.
A: Here is some good background about this topic in wikipedia:
Rotation Matrix
A: The transformation you describe by examples is not a rotation, in fact it does not preserve norms, it is the projection on the real axis. If instead you want a $45°$-counterclockwise rotation, apply the rotation matrix
$$\left(
\begin{array}{cc}
\cos\theta&-\sin\theta\\
\sin\theta&\cos\theta
\end{array}
\right)$$
with $\theta=\frac{\pi}{4}$
A: I don't think you have defined things properly, at least not with the usual mathematical definition of the $x$ axis going positive left and the $y$ axis going positive up.  If you rotate the $x$ axis as you say, $(1,1)$ should go to $(1,0)$, not to $(0,1)$.  Also note that your vectors change in length, which may or may not be a problem.
You seem to be trying to rotate the plane of lattice points by $45^\circ$.  The problem is that many lattice points are no longer lattice points after the rotation.  Your definition is not linear:  given $(1,1) \to (1,0), (0,1) \to (1,1)$ we should have $(1,0) \to (0,-1)$ which is clearly not what you want.
