core motion begin

1)CMAccelerometerData

represents an accelerometer event. It is a measurement of acceleration along the three spatial axes at a moment of time.

An application accesses CMAccelerometerData objects through the block handler specified as the last parameter of thestartAccelerometerUpdatesToQueue:withHandler: method and through the accelerometerData property, both declared by the CMMotionManager class. The superclass of CMAccelerometerDataCMLogItem, defines a timestamp property that records when the acceleration measurement was taken.

  [cmmotionmanager startAccelerometerUpdatesToQueue:                     [NSOperationQueue currentQueuewithHandler:^(CMAccelerometerData*accelerometerData, NSError *error) {

        

        CMAccelerometerData *newestAccel = cmmotionmanager.accelerometerData;

        NSLog(@"the value is %f",newestAccel.acceleration.x);

        NSLog(@"the yvalue is %f",newestAccel.acceleration.y);

        NSLog(@"the zvalue is %f",newestAccel.acceleration.z);


    }];



2)CMAttitude

  The CMAttitude class offers three different mathematical representations of attitude: a rotation matrix, a quaternion, and Euler angles (roll, pitch, and yaw values). You access CMAttitude objects through the attitude property of each CMDeviceMotion objects passed to an application. An application starts receiving these device-motion objects as a result of calling the startDeviceMotionUpdatesUsingReferenceFrame:toQueue:withHandler: method, thestartDeviceMotionUpdatesToQueue:withHandler: method, the startDeviceMotionUpdatesUsingReferenceFrame: method or thestartDeviceMotionUpdates method of the CMMotionManager class.

cmmanager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue]

                                   withHandler:^(CMDeviceMotion *motion, NSError *error) {

                                       CMAttitude *s=motion.attitude;

                  

                                       NSLog(@"the value is######### %f",s.pitch);

                                       NSLog(@"the yvalue is###### %f",s.roll);

                                       NSLog(@"the zvalue is####### %f",s.yaw);


                                   }];




3)CMDeviceMotion

An instance of CMDeviceMotion encapsulates measurements of the attitude, rotation rate, and acceleration of a device.

An application receives or samples CMDeviceMotion objects at regular intervals after calling thestartDeviceMotionUpdatesUsingReferenceFrame:toQueue:withHandler: method, the startDeviceMotionUpdatesToQueue:withHandler: method, thestartDeviceMotionUpdatesUsingReferenceFrame: method, or the startDeviceMotionUpdates method of the CMMotionManager class.

The accelerometer measures the sum of two acceleration vectors:gravity and user acceleration. User acceleration is the acceleration that the user imparts to the device. Because Core Motion is able to track a device’s attitude using both thegyroscope and the accelerometer, it can differentiate between gravity and user acceleration. ACMDeviceMotion object provides both measurements in the gravity and userAcceleration properties.

     

attitude

The attitude of the device. (read-only)

@property(readonly, nonatomic)  CMAttitude *attitude
Discussion

CMAttitude object represents a measurement of attitude—that is, the orientation of a body relative to a given frame of reference.

Availability
  • Available in iOS 4.0 and later.
Declared In
CMDeviceMotion.h

gravity

The gravity acceleration vector expressed in the device's reference frame. (read-only)

@property(readonly, nonatomic) CMAcceleration gravity
Discussion

The total acceleration of the device is equal to gravity plus the acceleration the user imparts to the device (userAcceleration).

Availability
  • Available in iOS 4.0 and later.
Declared In
CMDeviceMotion.h

magneticField

Returns the magnetic field vector with respect to the device. (read-only)

@property(readonly, nonatomic) CMCalibratedMagneticField magneticField
Discussion

The CMCalibratedMagneticField returned by this property gives you the total magnetic field in the device’s vicinity without device bias. Unlike the magneticFieldproperty of the CMMagnetometer class, these values reflect the earth’s magnetic field plus surrounding fields, minus device bias.

If the device does not have a magnetometer, the accuracy field of the property’s value (a CMCalibratedMagneticField structure) isCMMagneticFieldCalibrationAccuracyUncalibrated.

Availability
  • Available in iOS 5.0 and later.
Declared In
CMDeviceMotion.h

rotationRate

The rotation rate of the device. (read-only)

@property(readonly, nonatomic) CMRotationRate rotationRate
Discussion

CMRotationRate structure contains data specifying the device’s rate of rotation around three axes. The value of this property contains a measurement of gyroscope data whose bias has been removed by Core Motion algorithms. The identically name property of CMGyroData, on the other hand, gives the raw data from the gyroscope. The structure type is declared in CMGyroData.h.

Availability
  • Available in iOS 4.0 and later.
Declared In
CMDeviceMotion.h

userAcceleration

The acceleration that the user is giving to the device. (read-only)

@property(readonly, nonatomic) CMAcceleration userAcceleration
Discussion

The total acceleration of the device is equal to gravity plus the acceleration the user imparts to the device.

Availability
  • Available in iOS 4.0 and later.
Declared In
CMDeviceMotion.h

4)CMGyroData

An instance of the CMGyroData class contains a single measurement of the device’s rotation rate.

An application receives or samples CMGyroData objects at regular intervals after calling the startGyroUpdatesToQueue:withHandler: method or thestartGyroUpdates method of the CMMotionManager class.

rotationRate

The rotation rate as measured by the device’s gyroscope. (read-only)

@property(readonly, nonatomic) CMRotationRate rotationRate


rotationRate

The rotation rate as measured by the device’s gyroscope. (read-only)

@property(readonly, nonatomic) CMRotationRate rotationRate

5)CMLogItem

The CMLogItem class is a base class for Core Motion classes that handle specific types of motion events. Objects of this class represent a piece of time-tagged data that can be logged to a file.

CMLogItem defines a read-only timestamp property that records the time a motion-event measurement was taken.

The time when the logged item is valid. (read-only)

@property(readonly, nonatomic) NSTimeInterval timestamp
Discussion

The time stamp is the amount of time in seconds since the phone booted.

Availability
  • Available in iOS 4.0 and later.
Declared In
CMLogItem.h


6)CMMagnetmeterData

Instances of the CMMagnetometerData class encapsulated measurements of the magnetic field made by the device’s magnetometer.

Your application can obtain samples of magnetometer measurements, as represented by instances of this class, from the block handler of thestartMagnetometerUpdatesToQueue:withHandler: method or from the magnetometerData property of the CMMotionManager class.

Note: The magnetometerData property of CMMotionManager provides a non-nil value only if you have called the startMagnetometerUpdates method or thestartMagnetometerUpdatesToQueue:withHandler: method to start magnetometer updates.


7)CMMotionManager

CMMotionManager object is the gateway to the motion services provided by iOS. These services provide an application with accelerometer data, rotation-rate data, magnetometer data, and other device-motion data such as attitude. These types of data originate with a device’s accelerometers and (on some models) its magnetometer and gyroscope.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值