iPhone Coding: Using the Accelerometer
10 Sep 2007 view : 11,649
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 : 5,573
- 2. iPhone 3GS/Mac Games Development - An Extra Mile for the Gaming Industry view : 1,908
- 3. iPhone 3G Jaibreaking Software Works for Both 2.1 and 2.2 Firmware view : 2,001
- 4. Download an Unlock iPhone 3GS Review view : 3,145
- 5. Blackberry Storm Vs iPhone 3G Comparison view : 4,044
- 6. What Accessories to Buy for Your Apple iPhone 3GS view : 3,119
- 7. Easy Tips to View YouTube on Apple iPhone 3G view : 2,021
- 8. iPhone 3GS Review view : 2,953
- 9. Google Earth for the iPhone and iPod touch view : 4,453
- 10. iPhone 3G Screen Protector view : 6,436
Apple iPhone News Update
- 1. iPhone 101: Headphone issues view : 1,419
- 2. Rolando: A different iPhone game view : 846
- 3. Text from your iPhone for free view : 1,265
- 4. Doin' the wacky AT&T math view : 717
- 5. AT&T posts iPhone 3G information view : 1,755
- 6. Apple posts iPhone 3G Guided Tour view : 726
- 7. PocketMac Ringtone Studio for iPhone view : 609
- 8. Poachers Pilfer Pwnage view : 529
- 9. Bioware, EA's Neil Young eyeing the iPhone game market view : 529
- 10. Polarbit makes Crash Bandicoot Nitro Kart 3D for the iPhone view : 950
Apple iPhone Hot! News
- 1. Add ModMyiFone as an Installer.app source view : 19,062
- 2. Use your iPhone as a webcam view : 18,011
- 3. Installer.app locks out PXL package view : 13,486
- 4. iPhone MMS Application released view : 11,825
- 5. iPhone Coding: Using the Accelerometer view : 11,650
- 6. The State of the iTouch Jailbreak view : 8,207
- 7. iPhone Hacking 101: Jailbreaking view : 5,724
- 8. iPhone Coding: Working with the Navigation Bar view : 5,082
- 9. iPhone update to add TV out? view : 4,675
- 10. iPhone case mod with LED logo view : 3,942
Latest iPhone News
- 1. Firemint wins four Pocket Gamer Awards (Macworld.com) view : 21
- 2. New iPhone OS Rumored To Finally Allow Multitasking (NewsFactor) view : 33
- 3. Safari 4.0.5 offers improvements to Top Sites, third-party plug-ins (Macworld.com) view : 21
- 4. Razer, GPG pledge Mac support; DICE investigating (Macworld.com) view : 19
- 5. Apple Releases Safari 4.0.5 view : 36
- 6. OnLive Plans On-Demand Streaming of Video Games (NewsFactor) view : 27
- 7. Text message erasing application goes international (AFP) view : 30
- 8. Rumor: iPhone OS 4.0 Update Adds Multitasking (PC World) view : 32
- 9. Opera's Mini 5 browser comes to Android view : 29
- 10. Apple Dominates Consumer Reports' Tech Support Ratings view : 26
Most Popular iPhone News
- 1. iTunes 7.3 with Custom Ringtones? [Updated] view : 22,136
- 2. Add ModMyiFone as an Installer.app source view : 19,062
- 3. Use your iPhone as a webcam view : 18,011
- 4. First Looks: Apple iPhone TTY Adapter view : 13,920
- 5. Installer.app locks out PXL package view : 13,486
- 6. iPhone lacking Unicode support for Arabic, Hebrew view : 12,310
- 7. iPhone MMS Application released view : 11,825
- 8. iPhone Coding: Using the Accelerometer view : 11,650
- 9. Bento “an astounding little database application” view : 11,478
- 10. Magic: The Gathering game coming to Mac (Macworld.com) view : 9,710
