Search code examples
rotationvector-graphicscgal

CGAL: How do I rotate one 3D vector onto another?


I'm attempting to rotate a 3D, non-unit vector (Vector_3) so that it is coincident with another 3D non-unit vector using the Exact_predicates_exact_constructions_kernel.

I'm creating the rotation matrix mostly refering to this. However creating unit vectors is non-trivial. What is the most appropriate method for performing such a rotation with this kernel?


Solution

  • As soon as you need sqrt, you will only be able to get an approximation. I suggest that you use CGAL::Cartesian_converter to do the operation in a Kernel that support sqrt (like CGAL::Simple_cartesian<double> if no exact predicate is needed) and then convert the result back to EPEC kernel.