I have two transformers, a translation and a rotation as follows:
namespace bg = boost::geometry;
namespace trans = bg::strategy::transform;
trans::translate_transformer<point, point> translate(px, py);
trans::rotate_transformer<point, point, bg::radian> rotate(rz);
How do I combine them into one, so that I don’t have to call bg::transform twice each time and use an intermediate variable?
Both translate and rotate are affine transformations, i.e., they can be represented using a matrix. Therefore, all you have to do is to create a new transformer whose matrix is equal to the product of the matrices of the two transforms.
Here is a full working example:
Be very careful regarding the order of the matrices in the multiplication. The example above first translates, then rotates.