Reputation: 69
Suppose we have a coordinate system that its z axis is perpendicular to the ground surface. Then a direction is specified by an unit vector of the system. My question is how to detect the direction pointed by iphone's camera (or something else) by using iPhone's sensor. Sorry for my bad english.
Upvotes: 1
Views: 457
Reputation: 31745
Core Motion's CMDeviceMotion property gravity
@property(readonly, nonatomic) CMAcceleration gravity
will give you the devices orientation with respect to your z perpendicular to ground.
( 0, 0,-1) - device horizontal face up
( 0,-1, 0) - device vertical portrait, home button at base
(-1, 0, 0) - device vertical landscape, home button on right
Then Core Locations' CLHeading property magneticHeading
@property(readonly, nonatomic) CLLocationDirection magneticHeading
will give you the rotation around z (i.e. orientation with respect to x and y).
Upvotes: 1