Hi @scihant ,
To find a specific position on an image, in addition to the rotation angle I also need the pitch of the phone. So I calculated the pitch using quaternions:
let quaternion = motionData.attitude.quaternion
let pitch = CGFloat(atan2(2*(quaternion.x*quaternion.w + quaternion.y*quaternion.z), 1 - 2*pow(quaternion.x, 2) - 2*pow(quaternion.z, 2)))
And added a new parameter to report movement:
open func reportMovement(_ rotationAngle: CGFloat, _ fieldOfViewAngle: CGFloat, _ pitch: CGFloat, callHandler: Bool = true)
I have a custom class and delegate to report the movement to my view controller:
@objc public protocol CTPanoramaRotationDelegate {
func updatedRotation(rotationAngle: CGFloat, fieldOfViewAngle: CGFloat, pitch: CGFloat)
}
class CTCustomPanoramaView: CTPanoramaView {
var delegate: CTPanoramaRotationDelegate?
override func reportMovement(_ rotationAngle: CGFloat, _ fieldOfViewAngle: CGFloat, _ pitch: CGFloat, callHandler: Bool = true) {
compass?.updateUI(rotationAngle: rotationAngle, fieldOfViewAngle: fieldOfViewAngle)
delegate?.updatedRotation(rotationAngle: rotationAngle, fieldOfViewAngle: fieldOfViewAngle, pitch: pitch)
if callHandler {
movementHandler?(rotationAngle, fieldOfViewAngle)
}
}
}
Do you think it's useful to integrate pitch into the report movement function in the library? Or maybe there is some better approach that I'm missing? Thanks.
Hi @scihant ,
To find a specific position on an image, in addition to the rotation angle I also need the pitch of the phone. So I calculated the pitch using quaternions:
And added a new parameter to report movement:
I have a custom class and delegate to report the movement to my view controller:
Do you think it's useful to integrate pitch into the report movement function in the library? Or maybe there is some better approach that I'm missing? Thanks.