Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6761457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:11:36+00:00 2026-05-26T14:11:36+00:00

Math has defeated me once again. This is such a simple task, but I

  • 0

Math has defeated me once again. This is such a simple task, but I can’t manage to get it done.

Scenario: I draw on a SurfaceView a round image. The user touches a point on image border and starts to drag it adround. I need to rotate the circle image according to user movement.
I have two important piece of information, the image center X,Y coordinates and the touched points coordinates.

enter image description here

As you can see in the image, the user touched a point, according to my draw the touched point angle should be around 40. I can’t manage to calculate it properly.

I tried using this formula:

angle = Math.atan2(touchedY - centerY, touchedX - centerX) * 180 / Math.PI 

I can’t manage to understand how I should calculate the angle, as it is now, it doesn’t work properly and values are not good. For instance, in the case of the image, the angle calculate is -50.

Thank you for your time, any informations is gladly taken.

LE: Actually I did a mistake I think, as mentioned below. Should the circle be like:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:11:37+00:00Added an answer on May 26, 2026 at 2:11 pm

    Let’s reformulate the problem: You want to find the angle between two vectors. The first vector is the upvector going straigt up from your center-point (u), and the second vector is the vector from the center point to the touch point (v).

    Now we can recall (or google) that

    cos a = uv / (|u|*|v|)

    Where a is the angle between the vectors and |u| is the length of a vector. The upvector, u, is (0, 1) and has length 1.

    Multiplying the vectors by hand cancels the x-term and gives us something like this.

    double tx = touch_x - center_x, ty = touch_y - center_y;
    double t_length = Math.sqrt(tx*tx + ty*ty);
    double a = Math.acos(ty / t_length);
    

    Note how the v vector is obtained by subtracting the center point from the touch point. Remember to convert to degrees if needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This probably has been asked before but all I can find are questions regarding
Math has come on my way again and has defeated me. I need your
This question has been asked again and again, but I have still a doubt.
I can't understand whats causing this, although math has never been my specialty so
I guess this is a math question and not a programming question, but what
I know this subject has been beaten to death but after searching for a
PHP has many builtin trig math functions, but the inverse cotangent does not seem
Someone somewhere has had to solve this problem. I can find many a great
I feel like this is math problem more than anything. My company has employees
This is fairly 'math-y' but I'm posting here because it's a Project Euler problem,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.