开发者

Core Motion - Convert local euler angles to another reference system

开发者 https://www.devze.com 2023-02-06 03:50 出处:网络
I got a problem with the maths involved in converting local Euler angles into the angles of another reference system. Lets say we have an iPhone aligned with the axis of an vehicle and I want to measu

I got a problem with the maths involved in converting local Euler angles into the angles of another reference system. Lets say we have an iPhone aligned with the axis of an vehicle and I want to measure the roll angle, then the roll angle of the iPhone equals the roll angle of the device. But what if the iPhone is mounted tilt. In this开发者_如何学Python case I would have to convert the local Euler angles to another reference frame (e.g. the cars). Could someone please point me in the right direction?


I assume you want to know the roll of the car, rather than the phone. The phone needs to known the initial reference frame. So, suppose you line up the phone with the car at the start. Then press a button on the phone. At that button press, in your code store the attitude that you get from CMDeviceMotion.

If you want to know the roll of the car at any point after that, take the current attitude from CMDeviceMotion. Then call multiplyByInverseOfAttitude: on it, supplying the initial reference frame as parameter. That will give you the difference between the initial reference frame and the current one.

If you take the roll property from that, it should be the roll angle of the car.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号