void *algoritmoBresemham (int X1, int Y1, int X2, int Y2)

{
    struct ColorCap blanco = {1,1,1};
    int e,ax,ay,temp;
    int s1,s2,intercambio,i,x,y;
   x=X1;
   y=Y1;
   ax=abs(X2-X1);
   ay=abs(Y2-Y1);
   s1=signo(X2-X1);
   s2=signo(Y2-Y1);
   if(ay>ax)
   {       temp=ax;
         ax=ay;
         ay=temp;
         intercambio=1;
   }
   else   {
       intercambio=0;
   }
   e=2*ay-ax;
   for(i=1;i<=ax;i++)   {
      plot(x,y, blanco);
      if(e>=0)      {
         if (intercambio==1)
         {
            x=x+s1;
         }
         else
         {
             y=y+s2;
         }
            e=e-(2*ax);
      }
      if (intercambio==1)      {
          y=y+s2;
      }
      else
      {
          x=x+s1;
      }
      e=e+2*ay;
   }

}
예제 #2
0
void Imagen::potencia(double p)
{
  int largo=dim[0]*dim[1];
  double tmp;
  for(int i=0;i<largo;i++)
    {
      tmp=datos[i];
      datos[i]=signo(tmp)*pow(fabs(tmp),p);
    }
}
void LocalPlanner::getOneDeltaRepulsivo(Tupla posObst, Tupla &deltaO){
// recibe una posición de un obstáculo y calcula el componente repulsivo para ese obstáculo.
// Devuelve los valores en deltaO.x y deltaO.y
        double dist = distancia(posObst, pos); //esta sera la distancia al obhjetivo
        double angulo = atan2(posObst.y - pos.y, posObst.x - pos.x);

        if (dist < CAMPOREP.radius && dist < CAMPOREP.spread) {
                deltaO.x = -signo(cos(angulo))*999999;
                deltaO.y = -signo(sin(angulo))*999999;
                return;
        }

        if( (CAMPOREP.radius < dist)and (dist < CAMPOREP.spread - CAMPOREP.radius) ) {
                deltaO.x = -CAMPOREP.intens*(CAMPOREP.spread + CAMPOREP.radius - dist)*cos(angulo);
                deltaO.y = -CAMPOREP.intens*(CAMPOREP.spread + CAMPOREP.radius - dist)*sin(angulo);
                return;
        }

        if (dist > CAMPOREP.spread + CAMPOREP.radius) {
                deltaO.x = deltaO.y = 0;
        }
}
예제 #4
0
int main(int argc, char **argv)
{
    signo(5);
    return 0;
}