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

  • Home
  • SEARCH
  • 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 69343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:33:31+00:00 2026-05-10T19:33:31+00:00

Im trying to get into some basic JavaFX game development and I’m getting confused

  • 0

Im trying to get into some basic JavaFX game development and I’m getting confused with some circle maths.

I have a circle at (x:250, y:250) with a radius of 50.

My objective is to make a smaller circle to be placed on the circumference of the above circle based on the position of the mouse.

Where Im getting confused is with the coordinate space and the Trig behind it all.

My issues come from the fact that the X/Y space on the screen is not centered at 0,0. But the top left of the screen is 0,0 and the bottom right is 500,500.

My calculations are:

var xpos:Number = mouseEvent.getX(); var ypos:Number = mouseEvent.getY();  var center_pos_x:Number = 250; var center_pos_y:Number = 250;  var length = ypos - center_pos_y; var height = xpos - center_pos_x;  var angle_deg = Math.toDegrees(Math.atan(height / length)); var angle_rad = Math.toRadians(angle_deg);  var radius = 50;  moving_circ_xpos = (radius * Math.cos(angle_rad)) + center_pos_x; moving_circ_ypos = (radius * Math.sin(angle_rad)) + center_pos_y; 

I made the app print out the angle (angle_deg) that I have calculated when I move the mouse and my output is below:

When the mouse is (in degrees moving anti-clockwise):

  • directly above the circle and horizontally inline with the center, the angle is -0
  • to the left and vertically centered, the angle is -90
  • directly below the circle and horizontally inline with the center, the angle is 0
  • to the right and vertically centered, the angle is 90

So, what can I do to make it 0, 90, 180, 270??

I know it must be something small, but I just cant think of what it is…

Thanks for any help (and no, this is not an assignment)

  • 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. 2026-05-10T19:33:31+00:00Added an answer on May 10, 2026 at 7:33 pm

    atan(height/length) is not enough to get the angle. You need to compensate for each quadrant, as well as the possibility of ‘division-by-zero’. Most programming language libraries supply a method called atan2 which take two arguments; y and x. This method does this calculation for you.

    More information on Wikipedia: atan2

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

Sidebar

Ask A Question

Stats

  • Questions 114k
  • Answers 114k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The fprintf function does not add a line feed unless… May 11, 2026 at 10:18 pm
  • Editorial Team
    Editorial Team added an answer Your program should not write temporary files (or anything else… May 11, 2026 at 10:18 pm
  • Editorial Team
    Editorial Team added an answer I think you are looking for user settings: The .NET… May 11, 2026 at 10:18 pm

Related Questions

Im trying to get into some basic JavaFX game development and I'm getting confused
I'm trying to make some types in Django that map to standard Django types.
I'm looking into creating custom controls for WPF and I've found some reasonably useful
I'm in the process of trying to hack together the first bits of a
OK... I'm a VB.NET WinForms guy trying to understand WPF and all of its

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.