iPhone Coding: Using the Accelerometer
10 Sep 2007 view : 11,228
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 : 4,996
- 2. iPhone 3GS/Mac Games Development - An Extra Mile for the Gaming Industry view : 1,714
- 3. iPhone 3G Jaibreaking Software Works for Both 2.1 and 2.2 Firmware view : 1,782
- 4. Download an Unlock iPhone 3GS Review view : 2,836
- 5. Blackberry Storm Vs iPhone 3G Comparison view : 3,618
- 6. What Accessories to Buy for Your Apple iPhone 3GS view : 2,814
- 7. Easy Tips to View YouTube on Apple iPhone 3G view : 1,831
- 8. iPhone 3GS Review view : 2,645
- 9. Google Earth for the iPhone and iPod touch view : 4,203
- 10. iPhone 3G Screen Protector view : 6,012
Apple iPhone News Update
- 1. iPhone 101: Headphone issues view : 1,341
- 2. Rolando: A different iPhone game view : 788
- 3. Text from your iPhone for free view : 1,200
- 4. Doin' the wacky AT&T math view : 654
- 5. AT&T posts iPhone 3G information view : 1,678
- 6. Apple posts iPhone 3G Guided Tour view : 657
- 7. PocketMac Ringtone Studio for iPhone view : 551
- 8. Poachers Pilfer Pwnage view : 467
- 9. Bioware, EA's Neil Young eyeing the iPhone game market view : 472
- 10. Polarbit makes Crash Bandicoot Nitro Kart 3D for the iPhone view : 886
Apple iPhone Hot! News
- 1. Add ModMyiFone as an Installer.app source view : 18,631
- 2. Use your iPhone as a webcam view : 16,767
- 3. Installer.app locks out PXL package view : 13,194
- 4. iPhone MMS Application released view : 11,590
- 5. iPhone Coding: Using the Accelerometer view : 11,229
- 6. The State of the iTouch Jailbreak view : 8,117
- 7. iPhone Hacking 101: Jailbreaking view : 5,617
- 8. iPhone Coding: Working with the Navigation Bar view : 4,741
- 9. iPhone update to add TV out? view : 4,514
- 10. iPhone case mod with LED logo view : 3,616
Latest iPhone News
- 1. 2010: Finally the year of the Mac? (InfoWorld) view : 48
- 2. Rumor: Core i7 Coming Soon to MacBook Pro? (PC World) view : 51
- 3. Neo Nectaris strategy game arrives on the iPhone view : 53
- 4. Apple iPad Price Cut: Blunder or Brilliance? (PC World) view : 38
- 5. iHound aims to help you find your missing iPhone view : 38
- 6. iPad's Best Innovation? No-Contract Wireless (PC World) view : 62
- 7. Apple to Remain 'Nimble' on iPad Pricing (PC World) view : 34
- 8. Analysts See iPad Price Drop, with Some Cannibalization (NewsFactor) view : 34
- 9. Review: McSweeney's for iPhone view : 34
- 10. Control Your Nokia N900 With Sony's Sixaxis Controller (PC World) view : 36
Most Popular iPhone News
- 1. iTunes 7.3 with Custom Ringtones? [Updated] view : 21,826
- 2. Add ModMyiFone as an Installer.app source view : 18,631
- 3. Use your iPhone as a webcam view : 16,767
- 4. First Looks: Apple iPhone TTY Adapter view : 13,601
- 5. Installer.app locks out PXL package view : 13,194
- 6. iPhone lacking Unicode support for Arabic, Hebrew view : 12,005
- 7. iPhone MMS Application released view : 11,590
- 8. iPhone Coding: Using the Accelerometer view : 11,229
- 9. Bento “an astounding little database application” view : 10,935
- 10. Magic: The Gathering game coming to Mac (Macworld.com) view : 9,094
