public static double angle(Tuple3d a,Tuple3d b){
  double dx=b.x - a.x;
  double dy=b.y - a.y;
  double angle=0.0d;
  if (dx == 0.0) {
    if (dy == 0.0)     angle=0.0;
 else     if (dy > 0.0)     angle=Math.PI / 2.0;
 else     angle=(Math.PI * 3.0) / 2.0;
  }
 else   if (dy == 0.0) {
    if (dx > 0.0)     angle=0.0;
 else     angle=Math.PI;
  }
 else {
    if (dx < 0.0)     angle=Math.atan(dy / dx) + Math.PI;
 else     if (dy < 0.0)     angle=Math.atan(dy / dx) + (2 * Math.PI);
 else     angle=Math.atan(dy / dx);
  }
  return angle;
}

public static double angle ( Tuple3d a , Tuple3d b ) { double dx = b . x - a . x ; double dy = b . y - a . y ; double angle = 0.0d ; if ( dx == 0.0 ) { if ( dy == 0.0 ) angle = 0.0 ; else if ( dy > 0.0 ) angle = Math . PI / 2.0 ; else angle = ( Math . PI * 3.0 ) / 2.0 ; } else if ( dy == 0.0 ) { if ( dx > 0.0 ) angle = 0.0 ; else angle = Math . PI ; } else { if ( dx < 0.0 ) angle = Math . atan ( dy / dx ) + Math . PI ; else if ( dy < 0.0 ) angle = Math . atan ( dy / dx ) + ( 2 * Math . PI ) ; else angle = Math . atan ( dy / dx ) ; } return angle ; }
compute the angle between the first and second point .
