-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
c678f9c
commit b60a8dc
Showing
3 changed files
with
31 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ rn_robolectric_test( | |
name = "uimanager", | ||
# TODO Disabled temporarily until Yoga linking is fixed t14964130 | ||
# srcs = glob(['**/*.java']), | ||
srcs = ["SimpleViewPropertyTest.java"], | ||
srcs = ["SimpleViewPropertyTest.java", "MatrixMathHelperTest.java"], | ||
# Please change the contact to the oncall of your team | ||
contacts = ["[email protected]"], | ||
visibility = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters