title: Bounce a circle of another circle with LibGDX
body: <p>In my game i have an array of circles that form a circular boundary, inside the the boundary i have a ball that is supposed to bounce around, I want the ball to bounce off any of the boundary circles. The problem is that the ball is not bouncing, it's just passing right through. Here is my code:</p>
  
  <pre><code>private Array&lt;Circle&gt; colCircles = new Array&lt;Circle&gt;(); // circle array
  
   // method to calculate circle position
   private Vector2 calculatePosition(int i) {
      float cx = Constants.CENTER_X;
      float cy = Constants.CENTER_Y;
      float angle = 4 * i;
  
      float x = (float) (cx + m * Math.cos(Math.toRadians(angle)));
      float y = (float) (cy + m * Math.sin(Math.toRadians(angle)));
  
      return new Vector2(x, y);
  }
  </code></pre>
  
  <p>Then i create the circles like this:</p>
  
  <pre><code>for (int i = 0; i &lt; 90; i++) {
          Vector2 pos = new Vector2(calculatePosition(i));
          Circle c = new Circle(pos, colRadius);
          colCircles.add(c);
  
          Vector2 pos1 = new Vector2(calculateExPosition(i));
          Circle c1 = new Circle(pos1, colRadius);
          exCircles.add(c1);
  
      }
  </code></pre>
  
  <p>The update method for my ball is this:</p>
  
  <pre><code>public void update(float delta) {
      direction.x = (float) Math.cos(Math.toRadians(angle));
      direction.y = (float) Math.sin(Math.toRadians(angle));
  
      if (direction.len() &gt; 0) {
          direction = direction.nor();
      }
  
      velocity.x = direction.x * speed;
      velocity.y = direction.y * speed;
  
      position.x += velocity.x * delta;
      position.y += velocity.y * delta;
  
      circle.set(position.x + width / 2, position.y + height / 2, width / 2);
  }
  </code></pre>
  
  <p>when collision happens between the ball and any of the circles i use this code to try and bounce but there is no bounce help!:</p>
  
  <pre><code> public void bouncer(Ball b){
      // original velocity vector
      Vector2 v1 = new Vector2(b.getVelocity().x, b.getVelocity().y);
  
      // normal vector
      Vector2 n = new Vector2(
              Constants.CENTER_X - b.getPosition().x,
              Constants.CENTER_Y - b.getPosition().y
      );
  
      // normalize
      if (n.len() &gt; 0) n = n.nor();
  
      // dot product
      float dot = v1.x * n.x + v1.y * n.y;
  
      // reflected vector values
      v2.x = v1.x - 2 * dot * n.x;
      v2.y = v1.y - 2 * dot * n.y;
  
      // set new velocity
      b.setVelocity(v2);
  }
  </code></pre>