cmmotionmanager - Measuring tilt with left, right, forward and backward in ios -


i want find tilt in side (left, right, forward, backward)

i have use below code find left , right

[motionmanager startdevicemotionupdatestoqueue:[nsoperationqueue mainqueue] withhandler:^(cmdevicemotion *devicemotion, nserror *error)         {             if (devicemotion.attitude.roll <= -1)             {                 [self tiltcontrol:@"left"];             }             else if(devicemotion.attitude.roll > 1)             {                 [self tiltcontrol:@"right"];             }         }]; 

now how can find forward , backward...

what best way find 4 tilt...

just use attitude.pitch property:

if(devicemotion.attitude.pitch > 0 ) {     nslog(@"forward"); } else if(devicemotion.attitude.pitch < 0) {     nslog(@"backward"); } 

there rotation around z axis, available attitude.yaw. credits nshipster.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -