Skip to content
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

Open
DrAma999 opened this issue Jul 16, 2013 · 3 comments
Open

Gimbal lock #3

DrAma999 opened this issue Jul 16, 2013 · 3 comments

Comments

@DrAma999
Copy link

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.

@tropicdome
Copy link

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).

@tropicdome
Copy link

Also, your suggestion @DrAma999, may fix that the rotation axis is wrong when device is rotated into landscape.

@tropicdome
Copy link

I ended up using the answer from this thread on SO instead, it works great in both landscape and portrait mode
http://stackoverflow.com/questions/18972994/ios-7-parallax-effect-in-my-view-controller

// 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];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants