# How to change XYZ axes system into another 'xy' system

I have $3D$ point set lying on a vertical plane. This plane is not parallel to either $X$ or $Y$ axis but makes an angle (say, $\theta$) to $X$ axis. And also it has some ($+$ or $-$) intercept to the $X$ axis.

Now, I want to update my $X$ axis parallel to the azimuthal direction of my plane. And then I want to lie down the vertical plane to $XY$ plane. So, I think I could use my original $Z$ coordinates as the new $Y$ coordinates. As the plane lie on $XY$ plane, there should not be $Z$ coordinates any more. So, I want to know how to get my new $X$ coordinates from the original $XYZ$ and $\theta$.

Actually, I want to implement this modification in $c++$. But I am really poor in mathematics and struggling to figure out what should be the formula.

After doing this, I want to do some process with the new $XY$ point coordinates. And at the end, I want to bring back all my coordinates to original system. That is finally I want to go back to my original $XYZ$ axes. So I am also looking your assistant to get this case too.

Use $\sqrt{(X - X_i)^2 + Y^2}$ as your new $X$ coordinates, where $X_i$ is the intercept along the $X$ axis. As you'll be using the original $Z$ as one new coordinate, the Euclidean length in the other two original coordinates will correspond to the part orthogonal to that. And subtracting the intercept will bring you back to a situation where the plane directly passes through the origin.