I am working on an iOS camera based app, in which I have to capture a first point and then I need to draw the line to the current focus point to the first captured point. MagicPlan works this way.
Here is an image:

I have tried to fix a point for first point using accelerometer values and the tilted angle of the device. But, no luck so far. And how would i draw the line to the second point from the first point?
This is the code that i have tried so far:
    if (self.motionManager.deviceMotionAvailable)
    {
        [self.motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue]
         withHandler: ^(CMDeviceMotion *motion, NSError *error) {
             
             CATransform3D transform;
             
             transform = CATransform3DMakeRotation(motion.attitude.pitch, 1, 0, 0);
             
             transform = CATransform3DRotate(transform,motion.attitude.roll, 0, 1, 0);
             
             transform = CATransform3DRotate(transform,motion.attitude.yaw, 0, 0, 1);
             
             self.viewObject.layer.transform = transform;
             
         }];
    }
    
    
    if (self.motionManager.deviceMotionActive)
    {
        /**
         *  Pulling gravity values from deviceMotion sensor
         */
        CGFloat x = [self convertRadianToDegree:self.motionManager.deviceMotion.gravity.x];
        CGFloat y = [self convertRadianToDegree:self.motionManager.deviceMotion.gravity.y];
        CGFloat z = [self convertRadianToDegree:self.motionManager.deviceMotion.gravity.z];
        
        CGFloat r = sqrtf(x*x + y*y + z*z);
        
        /**
         *  Calculating device forward/backward title angle in degrees
         */
        CGFloat tiltForwardBackward = acosf(z/r) * 180.0f / M_PI - 90.0f;
        
        [self.lblTilForwardBackward setText:[@(tiltForwardBackward) stringValue]];
    }