title: How to position a Node along a circular orbit around a fixed center based on mouse coordinates (JavaFX)?
body: <p>Im trying to get into some basic JavaFX game development and I'm getting confused with some circle maths.</p>
  
  <p>I have a circle at (x:250, y:250) with a radius of 50.</p>
  
  <p>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.</p>
  
  <p>Where Im getting confused is with the coordinate space and the Trig behind it all.</p>
  
  <p>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.</p>
  
  <p>My calculations are:</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>I made the app print out the angle (angle_deg) that I have calculated when I move the mouse and my output is below:</p>
  
  <p>When the mouse is (in degrees moving anti-clockwise):</p>
  
  <ul>
  <li>directly above the circle and horizontally inline with the center, the angle is -0</li>
  <li>to the left and vertically centered, the angle is -90</li>
  <li>directly below the circle and horizontally inline with the center, the angle is 0</li>
  <li>to the right and vertically centered, the angle is 90</li>
  </ul>
  
  <p>So, what can I do to make it 0, 90, 180, 270??</p>
  
  <p>I know it must be something small, but I just cant think of what it is...</p>
  
  <p>Thanks for any help
  (and no, this is not an assignment)</p>