function indice = cal_indice(COOR,X)

   x = COOR(:,1); 
   y = COOR(:,2); 
   xc = X(1); yc = X(2);
   x0 = min(COOR(:,1)); x1 = max(COOR(:,1));
   y0 = min(COOR(:,2)); y1 = max(COOR(:,2));

//  premier indice
   X1 = max(x(find(and([x <= xc, x <> x1],2))));
   Y1 = max(y(find(and([y <= yc, y <> y1],2))));
   i1 = find(and([x == X1, y == Y1],2));
   XX1 = X1; YY1 = Y1;

     
//  deuxieme indice
   X1 = min(x(find(and([x >= xc, x <> x0, x <> XX1],2))));  
   Y1 = max(y(find(and([y <= yc, y <> y1],2))));
   i2 = find(and([x == X1, y == Y1],2));


//  troisieme indice
   X1 = min(x(find(and([x >= xc, x <> x0, x <> XX1],2))));
   Y1 = min(y(find(and([y >= yc, y <> y0, y <> YY1],2))));
   i3 = find(and([x == X1, y == Y1],2));


//  quatrieme indice
   X1 = max(x(find(and([x <= xc, x <> x1],2))));
   Y1 = min(y(find(and([y >= yc, y <> y0, y <> YY1],2))));
   i4 = find(and([x == X1, y == Y1],2));

//
// choix des indices
//

   a = COOR(i4,:)- COOR(i2,:);
   b =  X - COOR(i2,:);
   signe = det([a' b']);
   if signe > = 0  then
     indice = [i1 i2 i4]
   else 
     indice = [i2 i3 i4];
   end;

endfunction
