问题
I have seen many questions and articles mentioning that Quaternions can be used to derive better,accurate and stable yaw, pitch and roll readings from the iPhone rather than reading it's direct yaw, pitch and roll readings. But at the same time, I haven't seen any proper methods of implementing Quaternions in iPhone platform. As a beginner, It's really hard to know, How these Quaternions works and implementing them in a piece of code? (Sorry for not providing any code as i have no idea of how it works in xcode platform of apple)
So please be kind enough to provide an answer to my question that most of the users will benefit from it!
Thanks in advance!
回答1:
You don't have to implement anything, the API provides the quaternion for you:
CMAttitude Class Reference, quaternion propery
I personally like rotation matrices better because I find them easier to understand and to work with.
As I am reading your question, I still have the impression that you somehow want yaw, pitch and roll. You have to use quaternions everywhere in your code to get rid of the problems yaw, pitch and roll cause.
来源:https://stackoverflow.com/questions/12322797/use-quaternions-to-compute-yaw-pitch-and-roll-from-iphone