#include <complex>
typedef std::complex<double> C;
C rotation_to_align_hex(C original, C target) {
C o6 = std::pow(original, 6);
C t6 = std::pow(target, 6);
C r6 = t6 / o6;
return std::pow(r6, 1.0/6.0);
}
Following the initial suggestion of using complex numbers, this works beautifully. You can plug in the orientation of any of the vertices of the two hexagons (as length-1 complex numbers) and it will return the smallest rotation needed to line up the hexagons.