iPhone Coding: Using the Accelerometer
2007-09-10 00:00:00 view : 2843
Filed under: iPhoneYou don't need to use a lot of fancy routines to subscribe to data generated by the iPhone's built in accelerometer. A single UIApplication delegate lets you know whenever the iPhone has updated its tilt data. When you add a method for (void)acceleratedInX:(float)xx Y:(float)yy Z:(float)zz to any UIApplication, the iPhone sends regular messages to your application giving you values for X, Y, and Z. These values are not exactly what I first expected: X = Roll X corresponds to roll, or rotation around the axis that runs from your home button to your earpiece. Values vary from 0.5 (rolled all the way to the left) to -0.5 (rolled all the way to the right). Y = Pitch. Place your iPhone on the table and mentally draw a horizontal line about half-way down the screen. That's the axis around which the Y value rotates. Values go from 0.5 (the headphone jack straight down) to -0.5 (the headphone jack straight up). Z = Face up/face down. I expected the Z value to correspond to yaw. And it does not. It refers to whether your iPhone is face up (-0.5) or face down (0.5). When placed on it side, either the side with the volume controls and ringer switch, or the side directly opposite, the Z value equates to 0.0.Continue reading iPhone Coding: Using the AccelerometerRead | Permalink | Email this | Comments
Read more..
Latest iPhone Articles
- 1. Apple iPhone 3G VS Samsung i900 Omnia view : 1540
- 2. How to customise your iPhone ringtones view : 1065
- 3. iPhone Unlocking Safe view : 697
- 4. Apple iPhone 3G - Unlocking view : 1179
- 5. Copy Movies To iPhone view : 1996
Apple iPhone News Update
- 1. iPhone 101: Headphone issues view : 118
- 2. Rolando: A different iPhone game view : 80
- 3. Text from your iPhone for free view : 248
- 4. Doin' the wacky AT&T math view : 71
- 5. AT&T posts iPhone 3G information view : 239
Apple iPhone Hot! News
- 1. Installer.app locks out PXL package view : 6941
- 2. Add ModMyiFone as an Installer.app source view : 6367
- 3. The State of the iTouch Jailbreak view : 4732
- 4. iPhone Hacking 101: Jailbreaking view : 3839
- 5. iPhone Coding: Using the Accelerometer view : 2844
Latest iPhone News
- 1. AT&T’s Rivals Are Happy to Attack Over iPhone’s Network Woes view : 9
- 2. Security Flaw in the iPhone Exposes Private Data view : 11
- 3. Apple Confirms September iPhone Update view : 18
- 4. 21 deals a winning hand view : 14
- 5. Passcode Vulnerability Returns in iPhone Updates (NewsFactor) view : 12
Most Popular iPhone News
- 1. iTunes 7.3 with Custom Ringtones? [Updated] view : 17258
- 2. First Looks: Apple iPhone TTY Adapter view : 7304
- 3. Apple cuts price on DRM-free music to 99 cents (Macworld.com) view : 7102
- 4. Installer.app locks out PXL package view : 6941
- 5. Add ModMyiFone as an Installer.app source view : 6367
