如何计算从相机到锚点的矢量之间以及世界坐标中 x 轴之间的准确角度?

How to calculate accurate angle between a vector from camera to anchor , and between x axes in world coordinates?

渲染器的 ondrawFrame() 方法内部:

session.update();
    Pose camera = frame.getCamera().getPose();
    Pose anchor= anchor.getPose();
     float x =  anchor.tx() - camera.tx();
        float y =  anchor.ty() - camera.ty();
        double theta_g= Math.atan2(y,x);

theta_g返回的值不正确,卡在这里好久了

我通过大量的反复试验解决了它,一旦我专注于逻辑和坐标变化就很容易了:

float[] zcam = camera.getZAxis();
    float g_x =  (anchor.tx() - camera.tx());
    //float g_y = ( 0 - camera.ty());
    float g_z= (anchor.tz() - camera.tz());
    double distance_left= Math.sqrt((g_z*g_z)+(g_x*g_x));
    double theta_g=Math.atan2(g_z,g_x);
    double theta_c= Math.atan2(-zcam[2],-zcam[0]);
    double w = (theta_g-theta_c)*180/3.14;