views:

494

answers:

1

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.

A: 

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.

MarkusQ