iPhone Coding: Using the Accelerometer
10 Sep 2007 view : 7,886
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. How to Unlock iPhone 3G view : 194
- 2. iPhone 3GS/Mac Games Development - An Extra Mile for the Gaming Industry view : 61
- 3. iPhone 3G Jaibreaking Software Works for Both 2.1 and 2.2 Firmware view : 49
- 4. Download an Unlock iPhone 3GS Review view : 335
- 5. Blackberry Storm Vs iPhone 3G Comparison view : 233
- 6. What Accessories to Buy for Your Apple iPhone 3GS view : 210
- 7. Easy Tips to View YouTube on Apple iPhone 3G view : 127
- 8. iPhone 3GS Review view : 276
- 9. Google Earth for the iPhone and iPod touch view : 2,319
- 10. iPhone 3G Screen Protector view : 3,338
Apple iPhone News Update
- 1. iPhone 101: Headphone issues view : 776
- 2. Rolando: A different iPhone game view : 445
- 3. Text from your iPhone for free view : 778
- 4. Doin' the wacky AT&T math view : 333
- 5. AT&T posts iPhone 3G information view : 1,131
- 6. Apple posts iPhone 3G Guided Tour view : 167
- 7. PocketMac Ringtone Studio for iPhone view : 178
- 8. Poachers Pilfer Pwnage view : 177
- 9. Bioware, EA's Neil Young eyeing the iPhone game market view : 153
- 10. Polarbit makes Crash Bandicoot Nitro Kart 3D for the iPhone view : 501
Apple iPhone Hot! News
- 1. Add ModMyiFone as an Installer.app source view : 15,188
- 2. Installer.app locks out PXL package view : 10,905
- 3. iPhone MMS Application released view : 9,259
- 4. Use your iPhone as a webcam view : 8,707
- 5. iPhone Coding: Using the Accelerometer view : 7,887
- 6. The State of the iTouch Jailbreak view : 7,241
- 7. iPhone Hacking 101: Jailbreaking view : 5,054
- 8. iPhone update to add TV out? view : 2,987
- 9. iLiberty frees my iPhone view : 2,330
- 10. A fix for those "Pairing Record Missing" errors view : 2,287
Latest iPhone News
- 1. Opinion: Why the iPhone can't be killed view : 67
- 2. Users complain about poor Pre hardware view : 38
- 3. Review: HP 12C Financial Calculator for iPhone view : 43
- 4. Apple to Rate Your Karaoke Singing on Your iPhone? view : 54
- 5. To Pre 0r to iPhone? view : 66
- 6. Smartphone Palooza: 10 Hot Touchscreens Compared (PC World) view : 51
- 7. Apple Dropping NVIDIA for Future Macs? view : 37
- 8. Mac News Briefs: Omni Group releases OmniGraphSketcher (Macworld.com) view : 30
- 9. Review: PhotoMarkr for iPhone view : 42
- 10. Apple iPhones Could Shut Down in Summer Heat (PC Magazine) view : 36
Most Popular iPhone News
- 1. iTunes 7.3 with Custom Ringtones? [Updated] view : 19,760
- 2. Add ModMyiFone as an Installer.app source view : 15,188
- 3. First Looks: Apple iPhone TTY Adapter view : 11,275
- 4. Installer.app locks out PXL package view : 10,905
- 5. iPhone lacking Unicode support for Arabic, Hebrew view : 10,039
- 6. iPhone MMS Application released view : 9,259
- 7. Use your iPhone as a webcam view : 8,707
- 8. iPhone Coding: Using the Accelerometer view : 7,887
- 9. Apple cuts price on DRM-free music to 99 cents (Macworld.com) view : 7,811
- 10. The State of the iTouch Jailbreak view : 7,241
