Rotation of a pointcloud based on normal vector
I'm looking to rotate a 3-D point cloud based on the orientation of the floor. I have detected the floor and calculated its normal vector. I want to use this normal vector to ensure that all points on the floor have the same y-value.
Since the dot product of two normalized vectors is the cosine of the angle between them, I first normalize the current normal vector (0.856, 0.958, 2.58) as well as the desired normal vector (0.0, 0.958, 0.0). The dot product = 0.917 and therefore the angle = 70.586, but being in 3 dimensions this does not seem useful. Do I need to perform two rotations? If so, are there any suggest开发者_StackOverflowions as to the best approach?
If you want a rotation that will transform a normal vector A
into a desired normal vector A'
, there are an infinite number of them. (Given one such rotation, you can apply it and then compose it with spins around A'
to get lots of other rotations that do the same thing.)
One approach that works nicely in 3-D is to compute the cross-product vector V = A x A'
(which is normal to the plane containing A
and A'
) and then rotate around V
by the angle between A
and A'
. (It's important to first test that A
and A'
aren't already coincident.)
There's a description of how to do all this fairly efficiently here.
精彩评论