I have a point, say p (0.0, 0.0, 20.0), which I want to rotate around point a (0.0, 0.0, 10.0) in the XZ plane. What is the easiest way to do this? I use Qt with QVector3D and QMatrix4x4 to perform conversions. All I can think of is something like this:
QVector3D p(0.0, 0.0, 20.0); QVector3D a(0.0, 0.0, 10.0); QMatrix4x4 m; m.translate(-ax(), -ay(), -az()); p = m*p; m.setToIdentity(); m.rotate(180, 0.0, 1.0, 0.0); p = m*p; m.setToIdentity(); m.translate(ax(), ay(), az()); p = m*p;
But it seems to me that this is considered difficult, and I wonder if there are simpler or more elegant solutions?
source share