-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMRotationMatrix (Attitude) is broken #2
Comments
Temporary workaround is to flip the matrix: extension CMRotationMatrix {
var flipped: Self {
var flipped = CMRotationMatrix()
flipped.m11 = self.m11
flipped.m12 = self.m21
flipped.m13 = self.m31
flipped.m21 = self.m12
flipped.m22 = self.m22
flipped.m23 = self.m32
flipped.m31 = self.m13
flipped.m32 = self.m23
flipped.m33 = self.m33
return flipped
}
} |
Good find! Some of the math here file must be wrong or CoreMotion has a different basis than what we assume :/ Will look into it soon, but if the fix really is to transpose the matrix we'd be happy to except a PR to update that computed property. |
I'll give it a try later today. The hardest part is to write tests since the (core motion) framework types don't have any useful public constructors (I guess that's why you wrote your own implementations in the first place...) |
Sorry, I have not worked on this in a while... Anyway, today I have some new findings: I put a breakpoint inside
So far, so good.. if we continue:
My conclusion is that the bases on CoreMotion is different than your assumptions and it's not just the rotation matrix that is broken. For reference I'll prepare a PR later tonight. |
I've created a new PR with just the rotation matrix fix. The pitch/roll is still an issue. I've searched around the we in my quest to understand the quirks of CMQuaternion and have found this old SO post (unexpected results from glkquaternion conversion from cmquaternion) |
When replacing vanilla CMMotionManager I get some flipped axes of the rotation matrix
I've stopped at a breakpoint in
Attitude.init(_ attitude: CMAttitude)
and let it assignself.quaternion
Comparing the rotation matrices yields the following results:
Expected behavior
To have the same axes would be nice..
Environment
The text was updated successfully, but these errors were encountered: