How to use CoreMotion to get device orientation in space

I have a problem of thinking and searching here, and I can’t find a good direction to look ... I am looking to develop an algorithm for moving in the form of 360 images (sphere) using the movement of the device.

So, if the user points the device in front of him, he gets a certain reference point of the image. When he moves the device around him, the panoramic image moves in accordance with him.

Any idea or source I can look at?

Thanks and good luck to everyone with Swift :)

+4
source share
2 answers

:

, . , . (, iOS), .

, nomal.

+1

Kay .

, , .

CMMotionManager.

startDeviceMotionUpdatesToQueue .

[self.motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue] withHandler:^(CMDeviceMotion *motion, NSError *error) {
    [self processMotion];
}];

Motion , :

// Get attitude difference with previous one
CMAttitude *currentAttitude = self.motionManager.deviceMotion.attitude;
[currentAttitude multiplyByInverseOfAttitude:self.referenceAttitude];

, . , , , . , -180 180 Apple. :

#define RADIANS_TO_DEGREES(radians) ((radians) * (180.0 / M_PI))

, x, x.

, .

+1

Source: https://habr.com/ru/post/1543081/


All Articles