[Math] How to find rotation angles along X,Y,Z axes with a known vector to bring the axes to correct situation

computational geometrygeometryrotationsvector-spaces

I am working with 3d point data. When I checked the data I realized
that there is some error on my data and need to do some kind of
rotational rectification because the points which should be lie on a
vertical line don’t lie but lie on a oblique line and also points
which should lie on a vertical plane do lie on a bit oblique plane to
the vertical.

So, what I did was, I have fitted the two planes by carefully
selecting points lie on two nearby vertical planes (also by avoiding
outliers). Then, I got an intersection line, in 3D, (the red line in figure)
made by two vertical planes which I have fitted. If I get the
directional vector of that line 3d, then it was (-0.04, -0.01, 0.9).
As this line should be truly vertical I think these values should be
equal to (0, 0, 1). Now, I want to apply rotational corrections along
each axis to be come to this line parallel to (0, 0, 1).

enter image description here

I am bit confused how can I compute my rotational angles with these information. (I think I have enough information to compute correction angles.)

As I am thinking that my question is not clear, so that I am explaining the question again here under updates.-

Updates:

I have a point data set; Pi(xi, yi, zi). I want to find coordinate errors of this data set. However, I don’t have reference data for that, so that I found two vertical planes, perpendicular to each other, (for example building walls) by fitting planar fitting algorithm. Though these two planes must be truly vertical, it appears like it has small deviation from vertically. Then, I intersect these two planes and get a 3D line. In reality, this line should be truly vertical so vector of the line should be (0, 0, 1), however the detected line vector is (-0.04, -0.01, 0.99). I guess this is because of axis rotation error occurred at the time of data capturing. So what I really want to find rotation matrix (rotation angles of X,Y, Z axes i.e alpha, beta, gama) to be applied on to my points. I think I should use the following equation for this;
enter image description here

So, please help me to find my rotational correction angles along X, Y and Z axes.
Thank you.

Best Answer

If I understood your question correctly, the differences $\Delta x$, $\Delta y$, $\Delta z$ for correction are likely equivalent to the round up of your coordinates namely: $$\Delta x=+0.04$$ $$\Delta y=+0.01$$ $$\Delta z=+0.1$$ If you must have the correction in spherical coordinates, further you may take the general transformation rules for line element (approximating small differences $\Delta$) you have the Jacobi matrix: $$\frac{\Delta(x,y,z)}{\Delta(r,\theta,\varphi)}\simeq J=\begin{pmatrix} \sin\theta\cos\varphi &r\cos\theta\cos\varphi&-r\sin\theta\sin\varphi\\ \sin\theta \sin\varphi&r\cos\theta\sin\varphi&r\sin\theta\cos\varphi\\ \cos\theta&-r\sin\theta&0 \end{pmatrix}$$ and: $$(\Delta x,\Delta y,\Delta z)^T=J\cdot(\Delta r,\Delta \theta,\Delta \varphi)^T$$

See also here>>>; The system of equation must be solved. You may also need to take into consideration:

$$r=\sqrt{x^2+y^2+z^2}$$