Calculate the difference in azimuth angles between 2 Poses

两盒软妹~` 提交于 2021-01-27 14:58:47

问题


I have 2 Pose representing 2 positions of the camera and I want to get the difference between their azimuth angles.
The older pose is retrieved from an anchor set with the older camera pose, so that I shouldn't get errors from updates of ARCore's world understanding.
The newer pose is retrieved from the current frame.

I tried to use this formula from wikipedia:

psi = atan2(
    2*(qw*qz + qx*qy),
    1-2*(qy*qy + qz*qz)
)

Then I substract the older angle from the newer, with no success: when I move the phone to modify the pitch angle only, the result I get also varies.

I think it didn't work because it assumes +Z to be the vertical axis, whereas +Y is the vertical axis in ARCore. So I rotated the axes in the formula so that the vertical axis is Y :

psi = atan2(
    2*(qw*qy + qz*qx),
    1-2*(qx*qx + qy*qy)
)

It still doesn't work, the result still varies when I change the pitch only. Apparently this is not the right transformation to do.

How can I calculate the difference in azimuth angle between the 2 poses of the camera ?

This might actually be a question for Mathematics Stack Exchange, but I'm not sure if I'm misunderstanding ARCore or the maths, so here it is.


回答1:


Use the following approach to calculate azimuth that always measured in two dimensions:

public float getAzimuth(PointF aim) {

    float angle = Math.toDegrees(Math.atan2(aim.x - x, aim.y - y));

    // the range of ± 90.0° must be corrected...

    if(angle < 0.0) {
        angle += 360.0;
    }
    return angle;
}

...the following approach to calculate a distance:

float distance = Math.sqrt((x2 – x1) / 2.0 + 
                           (y2 – y1) / 2.0 + 
                           (z2 – z1) / 2.0); 

...and the following approach to calculate a plunge:

float plunge = Math.asin((z2 – z1) / distance)


来源:https://stackoverflow.com/questions/58008566/calculate-the-difference-in-azimuth-angles-between-2-poses

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!