IPhone orientation trigonometry

I am trying to write an augmented reality application. I use the coordinates of the compass, gyroscope and GPS to create overlays. Everything works fine, except when the user leaves portrait mode. There should just be a simple trigger problem that I cannot understand.

To determine if the coordinate is in sight, I use the azimuth and slope of the center point of the iPhone, which is calculated at the beginning of the program. The azimuth is defined as moving left and right when the phone is pointing up, and the direction of moving up and down when the phone is pointing up. Then I update this value with the gyro and compass data as it is updated. Therefore, if I correctly update the slope and azimuth of the center point, everything should work.

The problem is that when the iPhone rotates, its definition of azimuth and tilt remains unchanged with respect to the phone. Thus, the tilt is still defined as to the top of the phone, even if the phone is sideways.

I tried to do something like this:

self.centerPoint.azimuth = (degToRad(angleX)*cosZ) + (degToRad(angleY)*sinZ);
self.centerPoint.inclination = (degToRad(angleY)*cosZ) + (degToRad(angleX)*sinZ);

degToRad (x) , cosZ sinZ - cos sin z- , angleX angleY ​​- x y . X- , Y- -, Z- .

, . , . - , ?

, , , : azimuth = degToRad (angleX) = degToRad ( Y). . , .

+3
1

, , , ?

, , . , angle1 angle2, .


Update:

, , , . / , .

, , , CMAttitude. CMAttitude , , . multiplyByInverseOfAttitude: , .

0

Source: https://habr.com/ru/post/1777754/


All Articles