CGAL: Transformation Matrix for Rotation given two lines/vectors/directions

╄→гoц情女王★ 提交于 2019-12-24 00:39:42

问题


How do I generate a transformation matrix for rotating points/others by the angle between two lines/vectors/directions in CGAL?

2D is what I need. 3D is what I love.


回答1:


According to the manual you have these tools to work with:

Aff_transformation_2<Kernel> t ( const Rotation, Direction_2<Kernel> d, Kernel::RT num, Kernel::RT den = RT(1))

approximates the rotation over the angle indicated by direction d, such that the differences between the sines and cosines of the rotation given by d and the approximating rotation are at most num/den each. Precondition: num/den>0 and d != 0.

Aff_transformation_2<Kernel> t.operator* ( s) composes two affine transformations.

Aff_transformation_2<Kernel> t.inverse () gives the inverse transformation.

With them you should be able to compute the matrices corresponding to the two directions and use an identity along the lines of:

Mat(d1-d2) === Mat(d1)*Inv(Mat(d2))

to get what you want.



来源:https://stackoverflow.com/questions/765453/cgal-transformation-matrix-for-rotation-given-two-lines-vectors-directions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!