Game Development Community

Accelerometer Z-Axis?

by Dave Young · in iTorque 2D · 01/19/2009 (11:59 am) · 6 replies

I'm trying to grasp what exactly the Z-Axis means.

X and Y are pretty easy to figure out. Side to Side and pitch up/down respectively.

But what is Z axis represent? The iPhone dev video https://deimos.apple.com/WebObjects/Core.woa/BrowsePrivately/adc.apple.com.1479953497.01479953503.1521820376?i=1450247784

shows a different schema than what I already described but it shows the use of Z also. Is this available to us?

#1
01/19/2009 (12:54 pm)
Remember they are accelerometers. They measure acceleration, not position, not angle, not velocity (it's a bit odd to think about at first).

If you're not moving you device around, then the only acceleration being measured is gravity no matter what orientation your device is in.

For example, if you lean you iPhone against a wall at a 45 degree angle, gravity will cause a change in the value of your Y and Z axises.

If you "flip" you iPhone over sideways until it's facing downward, you'll do a half revolution on the X axis.

When you pick your iPhone straight up (or if you drop it), you are applying force to the Z axis.

Think if Z as the amount of acceleration "pushing" your iPhone down or up. So when it's sitting on a desk, it's Z acceleration is (-gravity) and when you are lifting it up, it's a positive value equal to it's upward acceleration.


I think of it this way:
Y = tilt (lean back or forward)
X = twist(like turning a doorknob)
Z = lift (picking up or dropping the device)


Of course, if you move the device, you'll have different forces acting in all directions, but this should help explain which is which.
#2
01/19/2009 (3:39 pm)
How do you access the Accelerometer in iTGB? Is there an example or doc for this? Thanks.
#3
01/19/2009 (4:12 pm)
It's set to jopystick0, check BehaviorShooter for an example.
#4
01/19/2009 (4:23 pm)
what about rumble? vibrate?
Is there any plan to support it in the future?

#5
01/19/2009 (5:38 pm)
I don't know of any plan for vibrate.
#6
01/19/2009 (6:14 pm)
@ Mat - found it, cool, thanks. If I wanted to do one of those things where you shake the phone, I suppose I would need to analyze how many times it changes directions in a period to detect a shake.