指定されたワールド座標を中心にカメラの位置を回転させる opengl カメラを実装しようとしています。glm 数学ライブラリを使用してこれを実行しようとしています。私のコードは次のとおりです
void Camera::dolly(double angle_x, double angle_y, const double& loc_x, const double& loc_y, const double& loc_z, const double& dt) {
glm::vec3 target = glm::vec3(loc_x,loc_y,loc_z);
glm::quat Q;glm::vec3 axis0(0.0f,1.0f,0.0f);
glm::quat R;glm::vec3 axis1(1.0f,0.0f,0.0f);
position = position - target;
//glm::normalize(axis0);
glm::normalize(axis1);
Q = glm::gtx::quaternion::angleAxis( float(angle_x ), axis0 );;
R = glm::gtx::quaternion::angleAxis( float(andl_y ), axis1 );;
glm::quat final = R*Q;
position = final * position;
position = position + target;
cout << "\tPosition: " << position.x << " " << position.y << " " << position.z <<endl;
}
コードをテストすると、quat Q を使用した回転は正常に機能しますが、quat R は「ぎこちない」回転を引き起こします。私は何を間違っていますか?