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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:16:13+00:00 2026-05-24T16:16:13+00:00

I want to develop a kind of wheel of fortune in Java/Android. When the

  • 0

I want to develop a kind of wheel of fortune in Java/Android. When the user touch the screen, i detect the mouvement and for each changes, i calculate the angle between the old pressure et the newest (function onScroll). I’ve a problem because i don’t remember how i can calculate the angle between 3 points…

I develop 3 functions but each one give me a various result :

public class Test {

public static void main(String[] args) {
    Test test = new Test();

    Point center = new Point(2.26f, 2.26f);
    Point current = new Point(2.54f, 3.64f);
    Point previous = new Point(2.25f, 3.73f);

    System.out.println("1) Angle is "
            + test.function1(center, current, previous));
    System.out.println("2) Angle is "
            + test.function2(center, current, previous));
    System.out.println("3) Angle is "
            + test.function3(center, current, previous));
    System.out.println("################################");

    center = new Point(2.26f, 2.26f);
    previous = new Point(3.29f, 1.04f);
    current = new Point(0.98f, 2.25f);
    System.out.println("1) Angle is "
            + test.function1(center, current, previous));
    System.out.println("2) Angle is "
            + test.function2(center, current, previous));
    System.out.println("3) Angle is "
            + test.function3(center, current, previous));
    System.out.println("################################");

    center = new Point(226.0f, 226.0f);
    previous = new Point(225.21994f, 373.3158f);
    current = new Point(254.31085f, 364.05264f);
    System.out.println("1) Angle is "
            + test.function1(center, current, previous));
    System.out.println("2) Angle is "
            + test.function2(center, current, previous));
    System.out.println("3) Angle is "
            + test.function3(center, current, previous));
    System.out.println("################################");
}

public double function1(Point center, Point current, Point previous) {

    double ang1 = Math.atan((previous.getdY() - center.getdY())
            / (previous.getdX() - center.getdX()));
    double ang2 = Math.atan((current.getdY() - center.getdY())
            / (current.getdX() - center.getdX()));
    double rslt = ang1 - ang2;

    return Math.toDegrees(rslt) * -1;
}

private double function2(Point center, Point current, Point previous) {
    float dx = current.getdX() - center.getdX();
    float dy = current.getdY() - center.getdY();
    double a = Math.atan2(dy, dx);

    float dpx = previous.getdX() - center.getdX();
    float dpy = previous.getdY() - center.getdY();
    double b = Math.atan2(dpy, dpx);

    double diff = a - b;
    double degres = Math.toDegrees(diff);
    return degres;
}

public double function3(Point center, Point current, Point previous) {
    Point p1 = new Point(current.getdX() - center.getdX(), current.getdY()
            - center.getdY());
    Point p2 = new Point(previous.getdX() - center.getdX(),
            previous.getdY() - previous.getdY());
    double angle = Math.atan2(p1.getdY() - p2.getdY(),
            p1.getdX() - p2.getdX());

    return Math.toDegrees(angle);
}

}

I found this function on the net but i can’t know which is the best.

Can you help me ?

  • 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-24T16:16:14+00:00Added an answer on May 24, 2026 at 4:16 pm

    Create two vectors out of the points and use dot product.

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

Sidebar

Related Questions

I want to develop something like the home screen of the Android's devices, where
I want to develop some kind of utility bar. I can position each element
I everyone. I'm very new to Android development and I want to develop an
I want to develop a game like wordfeud for android and iPhone. For now
I want to develop, a timeline kind of component, in which 24 hours are
I want to develop an iOS app that uses an external hardware plug-in, kind
I want to develop an application in iPhone and Android both which can display
I want develop some web product with using javascript 3d library like three.js But
Want to develop a query refinement tool just like Google Suggest so that i
I want to develop a web application, like an online scheduler. (Yes I know

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.