I want to check if a point is between two arcs.
Background: I get touch position with WatchFaceDelegate.
I tought to check the angle of the point and compare with my drawArc (starts at 220 and ends at 140 [degrees] clockwise direction).
The first one arc is an arc on watch perimeter, the second arc is not drowen, I only want to check if the touch point is between the perimeter of the watch and dc.getWidth()*0.85
So I do this:
// Touch coords var touchX = points[0], touchY = points[1]; // Tansform Radius to polar coords var distance1 = Math.sqrt(Math.pow(touchX - centerX, 2) + Math.pow(touchY - centerX, 2)); var distance2 = Math.sqrt(Math.pow(touchX - centerX, 2) + Math.pow(touchY - centerX, 2)); // Calculate the angle between the touch point and the centers of both arcs var angle1 = Math.atan2(touchY - centerX, touchX - centerX); var startAngleDeg = (220); var endAngleDeg = (220-80); // Convert degrees to radians var startAngle = Math.toRadians(startAngleDeg); var endAngle = Math.toRadians(endAngleDeg); var radius1 = (dimX/2); var radius2 = ((dimX/2)*0.9); // Check if the touch point is within the defined area between the two arcs if (distance1 <= radius1 && distance2 >= radius2 && angle1 >= startAngle && angle1 <= endAngle) { Log.debug("Touch event is within the defined area between two arcs. CIRCLE 1"); } else { Log.debug("Touch event is outside the defined area between two arcs.\n"); }
I checked with Log that the distance correctly works, but the angle is never triggered.
I really don't know what I'm missing