Is there a way to obtain the matrix which rotates a plane to a new orientation, given its new normal vector
The following image depicts what is described

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Given the old normal
Nand the new normalN'you can obtain the rotation by:Where
cross(x, y)is the cross product of the vectorsxandydot(x, y)is the dot product of the vectorsxandy|x|is the length of the vectorxThis will rotate the old normal onto the new one by the shortest way possible.
Notes
RotationAnglewill be in radians (if arccos returns radians as it does in most implementations)arccosis the inverse of the cosine function. It is necessary becausedot(N, N') = |N| * |N'| * cos(RotationAngle)whereRotationAngleis the angle between the vectors.RotationAxisis not normalized(|N| * |N'|)becomes unnecessary (in fact ifNis normalized you can leave out|N|of the product and ifN'is normalized then leave out|N'|)N' = -N(as there are infinite many shortest ways)How does it work?
The first observation is that the two normals will always define (at least) one plane in which both are lying. The smallest angle that parts them will be measured inside this plane too.
So the
RotationAxisvector will be the normal of the plane that encloses bothNandN'and theRotationAngleis the smallest angle between the two mentioned earlier.So by rotating around
RotationAxisby theRotationAnglethe old normalNis rotated inside the plane, on the shortest path towardsN'.