From d2b0267be035d42df75f0bf2e9bd653d8b5619ff Mon Sep 17 00:00:00 2001 From: Prabir Pradhan Date: Tue, 19 Oct 2021 11:24:45 -0700 Subject: MotionEvent: Avoid clipping tranformed orientation angle values A recent refactor (ag/14556109) exposed an issue in the existing orientation angle transformation logic where the output was clipped incorrectly. There is no need to clip the ouput of atan2f because its output is in the range [-pi, pi], which conforms to the MotionEvent's orientation API. Test: manual with stylus and test app Bug: 202534592 Change-Id: I55df7470049922d0f579c2c1921dcacd0757ece1 --- libs/input/Input.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp index 390ff965ec..b4d9ab623c 100644 --- a/libs/input/Input.cpp +++ b/libs/input/Input.cpp @@ -56,13 +56,8 @@ float transformAngle(const ui::Transform& transform, float angleRadians) { transformedPoint.y -= origin.y; // Derive the transformed vector's clockwise angle from vertical. - float result = atan2f(transformedPoint.x, -transformedPoint.y); - if (result < -M_PI_2) { - result += M_PI; - } else if (result > M_PI_2) { - result -= M_PI; - } - return result; + // The return value of atan2f is in range [-pi, pi] which conforms to the orientation API. + return atan2f(transformedPoint.x, -transformedPoint.y); } vec2 transformWithoutTranslation(const ui::Transform& transform, const vec2& xy) { -- cgit v1.2.3-59-g8ed1b