elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  Ayuda con este programa?
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda con este programa?  (Leído 1,345 veces)
V_Dan

Desconectado Desconectado

Mensajes: 8


Ver Perfil
Ayuda con este programa?
« en: 27 Septiembre 2012, 05:28 am »

Hola!
Es un "brazo" y necesito que se mueva 180 grados por el teclado , son dos piezas diferentes
pero no se como hacer lo del teclado y la transformación :o :o no me salee
Una ayudita me caería bien
Gracias!!! :o


CÓDIGO:
#include<GL/glut.h>
#include <math.h>


//Este es el tuyo

float y;
   
float q0[2]={-30,50};
   float q1[2]={-30,230};
   float q2[2]={30,230};
   float q3[2]={30,50};
   float b0[2] ,b1[2] ,b2[2],b3[2], t[2];


   float save0[2],save1[2],save2[2],save3[2];
   


float ang;
//****************************************** TRASLACIONES**************************************************


void operaciones (float p[2], float p1[2]) //Parámetros de Entrada
{
   float R[3][3]={1,0,0,  0,1,0,  0,0,1};
   p1[0]= R[0][0]*p[0]+ R[0][1]*p[1] + R[0][2]*1;
   p1[1]= R[1][0]*p[0]+ R [1][1]*p[1] + R[1][2]*1;


   
   
   return;
}

void escalado2D (float p[2], float p1[2], float s[2]) //Parámetros de Entrada y parámetros de traslación x0 y y0
{
   float S[3][3]={0,0,0,  0,1,0,  0,0,1};

   S[0][0]=s[0]; //s[0] es sx
   S[1][1]=s[1]; //s[1] es sy

   p1[0]= S[0][0]*p[0]+ S
  • [1]*p[1] + S[0][2]*1;
   p1[1]= S[1][0]*p[0]+ S [1][1]*p[1] + S[1][2]*1;

   
   //Matriz de traslación.
   return;
}
void traslacion2D (float p[2], float p1[2], float t[2]) //Parámetros de Entrada y parámetros de traslación x0 y y0
{
   float T[3][3]={0,0,0,  0,1,0,  0,0,1};

   T[0][1]=t[0]; //t[0] es sx
   T[1][0]=t[1]; //t[1] es sy

   p1[0]= T[0][0]*p[0]+ T
  • [1]*p[1] + T[0][2]*1;
   p1[1]= T[1][0]*p[0]+ T [1][1]*p[1] + T[1][2]*1;

   
   //Matriz de traslación.
   return;
}
void rotacion2D (float p[2], float p1[2], float ang) //Parámetros de Entrada y parámetros de traslación x0 y y0
{
   float R[3][3]={0,0,0,  0,1,0,  0,0,1};
   float theta;

   theta=ang*3.1415/180;


   R[0][0]=cos(theta);
   R[0][1]=-sin(theta);
   R[1][0]=sin(theta);
   R[1][1]=cos(theta);

   p1[0]= R[0][0]*p[0]+ R
  • [1]*p[1] + R[0][2]*1;
   p1[1]= R[1][0]*p[0]+ R [1][1]*p[1] + R[1][2]*1;

   
   //Matriz de Rotación.
   return;
}
//******************************************FIN TRASLACIONES***************************************************
void ejesguia()
{
   y=500-y;
    glClear(GL_COLOR_BUFFER_BIT);
     
    glColor3f(0.0,1.0,0.0);
    glBegin(GL_LINES);
    glPointSize(0.8);
         glVertex2i(0,10);     
         glVertex2i(0,490);
         
         glVertex2i(-240,10);     
            glVertex2i(240,10);

     glEnd();

    // Base
    glColor3f(1.0,1.0,0.0);
    glBegin(GL_POLYGON);
      glVertex2f(-150,10);
      glVertex2f(-150,80);
      glVertex2f(150,80);
      glVertex2f(150,10);
       
   glEnd();

   
   // PIVOTE1 (No funciona)
   glColor3f(1.0,0.10,0.10);
   glBegin(GL_POINT);
   glPointSize(30.0);
      glVertex2f(0,80);
      glEnd ();


     glFlush();
}

void Brazo1()
{
   glClear(GL_COLOR_BUFFER_BIT);
   glColor3f(1.0,0.0,1.0);
    glBegin(GL_POLYGON);
      glVertex2f(-30,50);
      glVertex2f(-30,230);
      glVertex2f(30,230);
      glVertex2f(30,50);
       
   glEnd();

   glFlush();
}


void Brazo2()
{

   glClear(GL_COLOR_BUFFER_BIT);
   glColor3f(1.0,0.0,1.0);
    glVertex2f(-30,210);
      glVertex2f(-30,430);
      glVertex2f(30,430);
      glVertex2f(30,210);
       
   glEnd();

   glFlush();

}



void moveBrazo1 ()
{
   //traslada origen
   t[0]=0.0;
   t[1]=0.0;

   traslacion2D(q0,b0,t);
   traslacion2D(q1,b1,t);
   traslacion2D(q2,b2,t);
   traslacion2D(q3,b3,t);

       save0[0]=q0[0];
      save1[0]=q1[0];
      save2[0]=q2[0];
      save3[0]=q3[0];
      

      save0[1]=q0[1];
      save1[1]=q1[1];
      save2[1]=q2[1];
        save3[1]=q3[1];
      

   

   // rota cada 10 grados
   ang= 10;
   
   rotacion2D(q0,b0,ang);
   rotacion2D(q1,b1,ang);
   rotacion2D(q2,b2,ang);
   rotacion2D(q3,b3,ang);
   
   //Posicion Inciial



}







void teclasEspeciales(int key, int x, int y)
{
   
       /*switch (key) {
       
      case GLUT_KEY_LEFT:
         if (// lame la funcion que me rota o hace
            ); 
             break;
       case GLUT_KEY_RIGHT:
         if ();
        break;
      case GLUT_KEY_UP:
         if () ;

         break;

      case GLUT_KEY_DOWN:
         if ();
         break;
      }
      */

}



void init ()
{
   glClearColor (0.0, 0.0, 0.0, 0.0);

   glColor3f(1.0, 1.0, 1.0);

    glMatrixMode (GL_PROJECTION);
   glLoadIdentity ();
   glOrtho(-250, 250, 0, 500, -1.0, 1.0); 
}

   
int main(int argc, char** argv)
{

    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); 
   glutInitWindowSize(500,500);
   glutInitWindowPosition(0,0);
   glutCreateWindow("Brazo");
   glutDisplayFunc(ejesguia);
   init();
   glutMainLoop();

}


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
ayuda con este programa
Programación C/C++
daxelmejor 1 2,398 Último mensaje 13 Mayo 2010, 16:00 pm
por Akai
Ayuda con este programa en C++
Programación C/C++
miguelb18 1 2,213 Último mensaje 25 Agosto 2010, 17:23 pm
por Littlehorse
Ayuda con este programa
Programación C/C++
nosotros12 1 2,101 Último mensaje 18 Noviembre 2011, 09:06 am
por s00rk
ayuda con este programa
Dudas Generales
ZXILER 1 2,642 Último mensaje 16 Marzo 2012, 23:16 pm
por Aprendiz-Oscuro
ayuda con este programa
Java
hairam 2 2,172 Último mensaje 9 Julio 2012, 20:56 pm
por rommel89
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines