且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CGAL:给定两行/矢量/方向的旋转变换矩阵

更新时间:2022-10-19 14:01:26

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.