public static ArrayList<Coords> intervening(Coords src,Coords dest,boolean split){
  IdealHex iSrc=IdealHex.get(src);
  IdealHex iDest=IdealHex.get(dest);
  int[] directions=new int[3];
  int centerDirection=src.direction(dest);
  if (split) {
    centerDirection=(int)Math.round(src.radian(dest) + 0.0001 / HEXSIDE) % 6;
  }
  directions[2]=centerDirection;
  directions[1]=(centerDirection + 5) % 6;
  directions[0]=(centerDirection + 1) % 6;
  ArrayList<Coords> hexes=new ArrayList<>();
  Coords current=src;
  hexes.add(current);
  while (!dest.equals(current)) {
    current=Coords.nextHex(current,iSrc,iDest,directions);
    hexes.add(current);
  }
  return hexes;
}

public static ArrayList < Coords > intervening ( Coords src , Coords dest , boolean split ) { IdealHex iSrc = IdealHex . get ( src ) ; IdealHex iDest = IdealHex . get ( dest ) ; int [ ] directions = new int [ 3 ] ; int centerDirection = src . direction ( dest ) ; if ( split ) { centerDirection = ( int ) Math . round ( src . radian ( dest ) + 0.0001 / HEXSIDE ) % 6 ; } directions [ 2 ] = centerDirection ; directions [ 1 ] = ( centerDirection + 5 ) % 6 ; directions [ 0 ] = ( centerDirection + 1 ) % 6 ; ArrayList < Coords > hexes = new ArrayList < > ( ) ; Coords current = src ; hexes . add ( current ) ; while ( ! dest . equals ( current ) ) { current = Coords . nextHex ( current , iSrc , iDest , directions ) ; hexes . add ( current ) ; } return hexes ; }
returns an array of the coords of hexes that are crossed by a straight line from the center of src to the center of dest , including src & dest . the returned coordinates are in line order , and if the line passes directly between two hexes , it returns them both . based on the degree of the angle , the next hex is going to be one of three hexes . we check those three hexes , sides first , add the first one that intersects and continue from there . based off of some of the formulas at amit ' s game programming site . ( http : / / www - cs - students . stanford . edu / ~ amitp / gameprog . html ) note : this function can return coordinates that are not on the board .
