IOS 4 core motion ratio in landscape orientation

I am trying to rotate my view based on the CMAttitude returned from the CMMotionManager, specifically pitch = x and roll = y. I use a referential relationship to set my horizon. This works great for portrait mode, but the moment I try to do it for landscape view, it will go wrong. As the phone now rotates 90 cc, I was hoping the koremosia would know that the landscape was in place and keep the pitch and throw useful. Instead, I still have an axis indicating their original path. To try to compensate, I simply changed the sign to roll = x and switched pitch = y. This seemed to work until I held the device in front of me and turned 180 degrees. The view turned upside down and rolled over.

My keen sense tells me that I need to apply the correct transformation in the roll and yaw in order to reorient the attitude.

I hope some geniuses or geniuses can help me. Math is obviously not my forte.

+4
source share
1 answer

You are right, changing the pitch and roll will lead to serious trouble. The simplest way seems to work with a new reference relation, as in the CoreMotionTeapot example. Only when a change in orientation is detected, you must capture the current relation before multiplying with the previous reference position and set it as a new reference relation.

+3
source

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


All Articles