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 4568006
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:00:50+00:00 2026-05-21T19:00:50+00:00

Math has come on my way again and has defeated me. I need your

  • 0

Math has come on my way again and has defeated me. I need your help to regroup and attack again.

What I’ve got:

enter image description here

I’ve got a surfaceview and a circle as a bitmap. I need to rotate the bitmap as the user moves the finger around the circle edge. The faster the user slides, the more I need to rotate the image. Seems simple but not really easy to implement.

What I need

I need to calculate the angle on which to rotate the image on onDraw event. From what I’ve thought so far I need two things:
– the angle between new touched point and the old one. I’ve done a simple function that takes care of this:

     private int getAngleBetweenTwoTouchedPoints(double oldX, double oldY, double newX, double newY)
     {
         return (int) Math.abs(Math.atan2(newY - oldY, newX - oldX));
     }

the angle returned by this varies from 0 to 1 and I believe it is correct. By incrementing the image rotation matrix angle by this value I get a slow rotation, basically by 1 unit. So, there is a chance to work, but not ok yet.
– so, the second thing I may need is the speed with which the user slides the finger around the screen. So basically something like this:

rotationAngle += angleBetweenTouches+speed

Speed, or velocity as I saw it named is the problem in my case, considering that I don’t move only on X or Y but around the circle. I have no idea how to calculate it. I saw VelocityTracker on Android help but I don’t know how it could help.

So to recap: I need to be able to rotate the image as the user moves the finger around the image border. Even simpler, when the user stops sliding, the pixel of the image that was below the finger on slide start should be the same when the slide stops.

Any help is greatly appreciated. Thank you

  • 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-21T19:00:51+00:00Added an answer on May 21, 2026 at 7:00 pm

    I suspect that given “Even simpler, when the user stops sliding, the pixel of the image that was below the finger on slide start should be the same when the slide stops. “, what you might be better off with is absolute rotations rather than relative ones.

    Incrementing the rotation with each event may accumulate errors that lead to the bitmap not appearing to “stick” to the finger.

    If you just keep track of the initial event and the last event, then always transform from the initial view to that appropriate for the last event your code will be simpler (avoiding speed), and behave better.

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

Sidebar

Related Questions

I suck at math. I need to figure out how to calculate a video
I need to calculate Math.exp() from java very frequently, is it possible to get
BigDecimal is a class in the java.math package that has a lot of benefits
Someone has suggested to me that the built in C# Math.Sqrt function in .NET
I'm hoping someone has come across this problem before too. I am trying to
Does Open64 has something equivalent to Intel Short Vector Math Library Operations . Thank
Some high school math concept has been forgotten, so I ask here. If I
Just wondering if anyone can help me with a little programming math i'm having
I need to find the minimum size that has an aspect ratio of exactly
Math skills are becoming more and more essential, and I wonder where is a

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.