Please sign in to comment.
Fix rotation matrix decomposition.
Summary: This PR fixes an issue with rotation decomposition matrix on android. The issue can be illustrated with this sample code https://snack.expo.io/r1SHEJpVb It surfaces when we have non-zero rotation in Y or X axis and when rotation Z is greater than 90deg or less than -90deg. In that case the decomposition code doesn't give a valid output and as a result the view gets rotated by 180deg in Z axis. You may want to run the code linked above on android and iOS to see the difference. Basically the example app renders first image rotated only by 89deg and the next one by 91deg. As a result you should see the second view being pivoted just slightly more than the first image. Apparently on android the second image is completely flipped: iOS: ![screen shot 2017-07-07 at 12 40 30](https://user-images.githubusercontent.com/726445/27954719-7cf6d02c-6311-11e7-9104-5c3cc8e9b9c1.png) Android: ![screen shot 2017-07-07 at 12 41 21](https://user-images.githubusercontent.com/726445/27954737-981f57e8-6311-11e7-8c72-af1824426c30.png) The bug seemed to be caused by the code that decomposes the matrix into axis angles. It seems like that whole code has been overly complicated and we've been converting matrix first into quaternion just to extract angles. Whereas it is sufficient to extract angles directly from rotation matrix as described here: http://nghiaho.com/?page_id=846 This formula produces way simpler code and also gives correct result in the aforementioned case, so I decided not to debug quaternion code any further. sidenote: New formula's y angle output range is now -90 to 90deg hence changes in tests. Closes #14888 Reviewed By: astreet Differential Revision: D5414006 Pulled By: shergin fbshipit-source-id: 2e0a68cf4b2a9e32f10f6bfff2d484867a337fa3
- Loading branch information...
Showing with 31 additions and 80 deletions.