I'm trying to orient a camera located at (1, 0, 1) so that it points at a target. For simplification I'll assume the target is the origin, but it could be anywhere. Here's the code I'm using:
const GfVec3d from_vec{ 1.0, 0.0, 1.0 };
const GfVec3d to_vec{ 0.0, 0.0, 0.0 };
const GfVec3d up{ 0.0, 1.0, 0.0 };
GfMatrix4d m;
m.SetLookAt(from_vec, to_vec, up);
GfVec3d rotation = m.DecomposeRotation(GfVec3d::XAxis(), GfVec3d::YAxis(), GfVec3d::ZAxis());
std::cout << "rotation: " << rotation << std::endl;
The docs for SetLookUp() state that it "rigidly rotates the orientation from its canonical frame, which is defined to be looking along the -z axis with the +y axis as the up direction" and positive rotational values are defined to be counter-clockwise rotations about an axis, as viewed when looking down that axis toward the origin. So I'm expecting to see a positive rotation of 45 degrees about the Y-axis that I can apply to the camera to have it point at the origin: (0, 45, 0).
Instead, I get a negative rotation: (0, -45, 0).
What am I doing wrong here?