-
Notifications
You must be signed in to change notification settings - Fork 49
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
Gimbal lock #3
Comments
Maybe a long shot, since it looks like this is not being maintained anymore, but I second this. You easily notice the flip of the image when approaching e.g. 90 deg. (hold the device upright tilting back and forth will rapidly flip the image). |
Also, your suggestion @DrAma999, may fix that the rotation axis is wrong when device is rotated into landscape. |
I ended up using the answer from this thread on SO instead, it works great in both landscape and portrait mode // Set vertical effect
UIInterpolatingMotionEffect *verticalMotionEffect =
[[UIInterpolatingMotionEffect alloc]
initWithKeyPath:@"center.y"
type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
verticalMotionEffect.minimumRelativeValue = @(-10);
verticalMotionEffect.maximumRelativeValue = @(10);
// Set horizontal effect
UIInterpolatingMotionEffect *horizontalMotionEffect =
[[UIInterpolatingMotionEffect alloc]
initWithKeyPath:@"center.x"
type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
horizontalMotionEffect.minimumRelativeValue = @(-10);
horizontalMotionEffect.maximumRelativeValue = @(10);
// Create group to combine both
UIMotionEffectGroup *group = [UIMotionEffectGroup new];
group.motionEffects = @[horizontalMotionEffect, verticalMotionEffect];
// Add both effects to your view
[myBackgroundView addMotionEffect:group]; |
The problem you are experiencing with pitch is called Gimbal lock, it happens every time a rotation plane is parallel to another one. To avoid that you should use the attitude transformation matrix, or (better) the quaternion property.
The text was updated successfully, but these errors were encountered: