I want to measure the surface contour of a cylinder. I am using a laser line scanner to measure it. I am currently facing a problem with x-tilt - a misalignment caused when the measurement laser line is not parallel to the plane of rotation.
For instance, say the two points of laser line on the cylinder surface are $(x_{1},\theta_1)$ and $(x_2,\theta_2)$. If $\theta_1 = \theta_2$ then the alignment is correct. If I measure a perfectly smooth cylinder with a properly aligned sensor, z (the distance between the sensor and the cylindrical surface) as a function of x (axial length of the cylinder) would be flat line. However, if $\theta_1 \neq \theta_2$, then z vs x would be a concave curve with peak value equal to the z_correct_aligned.
The question: How can we extract the angle by which the sensor should be rotated to ensure proper alignment when we have the curve measurement and know the radius of the cylinder?
The laser beam when moved defines a plane. If the laser is properly aligned, the plane contains the axis of the cylinder. If it is misaligned in a way that it creates an angle with the axis, the plane it defines interescts this axis at some angle $\alpha$. Note that it is also possible to have the laser misaligned in such a way, that it defines a plane parall to the axis, but not containing it; this isn't the case you're asking about, so I won't be talking about it.
If a plane intersects the axis of a cylinder, then the crossection of the plane with the cylinder is an ellipse. It's projection on $(x,z)$ plane (which is measured) will also be an ellipse. It can be easily checked that the short axis (iun the direction $z$) of this ellipse is $R$ and the long axis (in the direction $x$) is $\frac{R}{\tan\alpha}$.
The profile you measure will be an arc of this ellipse. In a perfect situation, assuming that the maximum of the profile is at the point $(x_0,z_0)$, the profile should be given by the formula $$ \frac{(x-x_0)^2}{R^2/\tan^2\alpha} + \frac{\big(z-(z_0-R)\big)^2}{R^2} = 1$$ that is $$ z = z_0 + \sqrt{R^2-(x-x_0)^2\tan^2\alpha} - R$$ In a realistic situations with all possible measurement errors in the way, you don't expect full agreement with the formula, and you just need to find the value of $\alpha$ that gives the best fit. Or you can just look at $z$ around the maximum; we expect $$ z \approx z_0 -\frac{\tan^2\alpha}{2R} (x-x_0)^2 $$ Which means that $$ -\frac{\tan^2\alpha}{R} = z''(x_0)$$ $$ \tan^2\alpha = -R\, z''(x_0)$$ $$ \alpha = \arctan \sqrt{R\, |z''(x_0)|}$$ Fitting an ellipse to a measured profile will probably give you a better approximation for $\alpha$ than just looking at the neighbourhood of the maximum.