Motion sensor

2

How do I identify the rotation of the iPhone on its own axis (same rotation as a top)? I was able to identify practically all possible rotations and could not identify this, which is precisely what I need for a game I'm developing. The iPhone will be in portrait position.

More precisely, I need to get the Y rotation

    
asked by anonymous 04.03.2015 / 15:17

1 answer

1

To get the values, you can use 3 shapes, and here they are:

Declare

let motionKit = MotionKit()

And so get the data in the following ways:

Accelerometer data:

motionKit.getAccelerometerValues(interval: 1.0){
        (x, y, z) in
        //Do whatever you want with the x, y and z values
        println("X: \(x) Y: \(y) Z \(z)")
      }

Gyro data:

motionKit.getGyroValues(interval: 1.0){
        (x, y, z) in
        //Do whatever you want with the x, y and z values
        println("X: \(x) Y: \(y) Z \(z)")
     }

magnetic field around your device:

motionKit.getMagnetometerValues(interval: 1.0){
        (x, y, z) in
        //Do whatever you want with the x, y and z values
        println("X: \(x) Y: \(y) Z \(z)")
     }
    
28.09.2015 / 19:02