the result of the angle between my touch and the middle,bottom of the screen gives me 180 when the touch is on the right side of the screen, and 0 when it is on the left. I don't understand why...
override func touchesMoved(touches: NSSet, withEvent event: UIEvent) {
let refPoint = CGPointMake(self.frame.size.width/2, self.frame.size.height)
let anyTouch: UITouch = touches.anyObject() as UITouch
let touch = anyTouch.locationInView(self.view!)
//180 is inversed? 180 is when touch is on the right side...
let dy = (refPoint.y - touch.y) //opposite
let dx = (refPoint.x - touch.x) //adjacent
let rad = atan2(dy, dx)
let angle = rad * 180 / CGFloat(M_PI)
println("angle : \(angle) ")
}
Would someone know how to solve this?
Thanks