title: Object acceleration not behaving as expected
body: <p>I have two objects in a 2D space. I expect <code>object1</code> to begin orbiting <code>object2</code>. I derived my methods from the equation</p>
  <blockquote>
  <p>f = G * (m1 * m2 / r*r)</p>
  </blockquote>
  <p>and</p>
  <blockquote>
  <p>dx1 += x1 - x2 * f</p>
  </blockquote>
  <p>etc. However, I am struggling because the object is only moving in the pos pos direction. Here is the class for each object:</p>
  <h3>Mass.java</h3>
  <pre class="lang-java prettyprint-override"><code>import java.awt.Point;
  
  public class Mass {
      public static float G = 0.1f;
  
      public Point center;
      public float mass, radius, dx = 0, dy = 0;
      public boolean locked = false;
      
      public Mass(Point center, float[] vect, float mass) {
          this.center = center;
          this.dx = vect[0];
          this.dy = vect[1];
          this.mass = mass;
          this.radius = mass;
      }
  
      public void moveVector(float[] vector) {
          if(!this.locked) {
              this.dx += vector[0];
              this.dy += vector[1];
          }
      }
  
      public void lock() {
          this.locked = true;
      }
  
      public static float distance(Mass obj1, Mass obj2) {
          float dX = obj1.center.x - obj2.center.x;
          float dY = obj1.center.y - obj2.center.y;
          double ans = Math.sqrt(Math.pow(dX, 2) + Math.pow(dY, 2));
          return (float) ans;
      }
      
      public static float force(Mass obj1, Mass obj2) {
          double ans = ((obj1.mass * obj2.mass) / Math.pow(distance(obj1, obj2), 2)) * G;
          return (float) ans;
      }
      
      public static float[] vector(Mass obj1, Mass obj2) {
          
          // total change between the two objects
          float force = force(obj1, obj2);
          
          float totalX = Math.abs(obj1.center.x - obj2.center.x);
          float totalY = Math.abs(obj1.center.y - obj2.center.y);
          
          float x = totalX * force;
          float y = totalY * force;
          
          float[] vector = {x, y};
          return vector;
      }
  }
  </code></pre>
  <p>This is the main class.</p>
  <h3>Sim.java</h3>
  <pre class="lang-java prettyprint-override"><code>import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  
  public class Sim extends JPanel {
      private static final long serialVersionUID = -2669101810074157675L;
      public static final int PREF_W = 800, PREF_H = 600;
      
      private Mass object1, object2;
      
      private Sim() {
          this.setFocusable(true);
          this.setBackground(Color.WHITE);
          
          float[] vect1 = {0, -1}, vect2 = {0, 0};
          object1 = new Mass(new Point(PREF_W / 2 - 100, PREF_H / 2 - 100), vect1, 10);
          object2 = new Mass(new Point(PREF_W / 2 + 100, PREF_H / 2 + 100), vect2, 30);
          
          gameTimer.start();
      }
      
      private Timer gameTimer = new Timer(1000/30, new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
              object1.moveVector(Mass.vector(object1, object2));
              object1.center.x += object1.dx;
              object1.center.y += object1.dy;
              System.out.println(&quot;[&quot; + object1.dx + &quot;,&quot; + object1.dy + &quot;]&quot;);
          }
      });
  
      public void paintComponent(Graphics g) {
          super.paintComponent(g);
          Graphics2D g2 = (Graphics2D) g;
  
          g2.fillOval(
                  (int) object1.center.x - (int) object1.radius, 
                  (int) object1.center.y - (int) object1.radius, 
                  (int) object1.radius, 
                  (int) object1.radius
              );
          
          g2.fillOval(
                  (int) object2.center.x - (int) object2.radius, 
                  (int) object2.center.y - (int) object2.radius, 
                  (int) object2.radius, 
                  (int) object2.radius
              );
          
          g2.drawLine(object1.center.x, object1.center.y, object2.center.x, object2.center.y);
  
          repaint();
      }
      
      /* METHODS FOR CREATING JFRAME AND JPANEL */
  
      public Dimension getPreferredSize() {
          return new Dimension(PREF_W, PREF_H);
      }
  
      public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
              public void run() {
                  JFrame frame = new JFrame(&quot;Gravity Simulation&quot;);
                  JPanel gamePanel = new Sim();
  
                  frame.getContentPane().add(gamePanel);
                  frame.pack();
                  frame.setLocationRelativeTo(null);
                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  frame.setVisible(true);
              }
          });
      }
  }
  </code></pre>
  <p>I have it printing out the DX and DY of <code>object1</code> (the unlocked object) at all times. It seems to get flung super fast, as expected, but it never slows down. Instead, the dx is just increasing slower and slower. I'm not very mathy, but it seems to be logistic. I wonder why this is happening.</p>
  <p>So far I have tried rewriting my formula and using a different equation. I have also attempted using different datatypes, and making some things negative. Nothing works, though.</p>
  <p>TLDR, the problem:
  Objects are not changing DX / DY as expected.</p>
  <p>Thank you in advance! Sorry if this was posted somewhere else, I could not find any duplicates.</p>