





Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!






U.T.O. – F.N.I. ING. DE SISTEMAS – ING. INFORMÁTICA
Entender los conceptos geométricos de traslación, escalado y rotación Comprender cómo la teoría de matrices permite formalizar los conceptos anteriores. Aprender a realizar, de una forma eficaz, transformaciones geométricas mediante operaciones con matrices
2. ACTIVIDADES DE LABORATORIO. Programa en Clase .- Ejecutar el siguiente programa que realiza operaciones de traslación, rotación y escalamiento en en C++ Builder El código asociado es el siguiente: //---------------------------------------------------------------------------
maxx=Form1->Image1->Width; maxy=Form1->Image1->Height; int i; float x,y; tpunto dato; for(i=0;i<maxp;i++) { //aplica la matriz de transformacion a los puntos aplicar_mat(lista[i],&dato); //aplicar proyeccion x=dato.x1000/(1000+dato.z); y=dato.y1000/(1000+dato.z); if(lista[i].dib==0) Canvas->MoveTo(maxx/2+x,maxx/2-y); else Canvas->LineTo(maxx/2+x,maxx/2-y); } } //--------------------------------------------------------------------------- void multiplica(tmat a,tmat b,tmat c) { int i,j,k; for(i=0;i<4;i++) for(j=0;j<4;j++) { c->v[i][j]=0; for(k=0;k<4;k++) c->v[i][j]+=a.v[i][k]b.v[k][j]; } } void __fastcall TForm1::Button2Click(TObject Sender) { double ang; tmat rot,aux; ang=Edit1->Text.ToDouble(); float dcos=cos(ang3.1416/180); float dsin=sin(ang3.1416/180); rot=identidad; rot.v[1][1]=dcos; rot.v[1][2]=-dsin; rot.v[2][1]=dsin; rot.v[2][2]=dcos; aux=mat; multiplica(rot,aux,&mat); Form1->Image1->Canvas->FillRect(Form1->Image1->Canvas->ClipRect); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button3Click(TObject Sender) { double ang; tmat rot,aux; ang=Edit2->Text.ToDouble(); float dcos=cos(ang3.1416/180); float dsin=sin(ang3.1416/180); rot=identidad;
rot.v[0][0]=dcos; rot.v[0][2]=dsin; rot.v[2][0]=-dsin; rot.v[2][2]=dcos; aux=mat; multiplica(rot,aux,&mat); Form1->Image1->Canvas->FillRect(Form1->Image1->Canvas->ClipRect); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button4Click(TObject Sender) { double ang; tmat rot,aux; ang=Edit3->Text.ToDouble(); float dcos=cos(ang3.1416/180); float dsin=sin(ang*3.1416/180); rot=identidad; rot.v[0][0]=dcos; rot.v[0][1]=-dsin; rot.v[1][0]=dsin; rot.v[1][1]=dcos; aux=mat; multiplica(rot,aux,&mat); Form1->Image1->Canvas->FillRect(Form1->Image1->Canvas->ClipRect); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button5Click(TObject *Sender) { tmat a,b; a=identidad; a.v[0][3]=Edit4->Text.ToDouble(); a.v[1][3]=Edit5->Text.ToDouble(); a.v[2][3]=Edit6->Text.ToDouble(); b=mat; multiplica(a,b,&mat); Form1->Image1->Canvas->FillRect(Form1->Image1->Canvas->ClipRect); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button6Click(TObject *Sender) { tmat a,b; a=identidad; a.v[0][0]=Edit7->Text.ToDouble(); a.v[1][1]=Edit8->Text.ToDouble(); a.v[2][2]=Edit9->Text.ToDouble(); b=mat; multiplica(a,b,&mat); Form1->Image1->Canvas->FillRect(Form1->Image1->Canvas->ClipRect); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button7Click(TObject *Sender) { Application->Terminate(); } //---------------------------------------------------------------------------