code: private static double get_angle(final int p1,
                                      final int p2) {
          int delta_x, delta_y;
          double ret = 0.0;
          /*
           * Calculate (x2 - x1) and (y2 - y1). The points are passed in the form
           * x1y1 and x2y2. get_x() and get_y() are passed these points and return
           * the x and y values respectively. For example, get_x(1020) returns 10.
           */
          delta_x = get_x( p2 ) - get_x( p1 );
          delta_y = get_y( p2 ) - get_y( p1 );
  
          if ( delta_x == 0 ) {
              if ( delta_y > 0 ) {
                  ret = WaltzUtil.PI / 2;
              } else if ( delta_y < 0 ) {
                  ret = -WaltzUtil.PI / 2;
              }
          } else if ( delta_y == 0 ) {
              if ( delta_x > 0 ) {
                  ret = 0.0;
              } else if ( delta_x < 0 ) {
                  ret = WaltzUtil.PI;
              }
          } else {
              ret = Math.atan2( delta_y,
                                delta_x );
          }
          return ret;
      }
docs: *************************************************************************
  This function is passed two points and calculates the angle between the
  line defined by these points and the x-axis.
  ************************************************************************