Entradas

Mostrando entradas de febrero, 2018

Código Menú|Animación // Diana Vargas B

Imagen
#include <windows.h> #include <stdlib.h> #include <stdio.h> #include <math.h> #include <GL/glut.h> float rotar = 0,inc=0.1, ry=0, rx=0,ang=0,botar=1, relleno=1;// botar =una bandera float r=1,g=0,b=0; int figurita =1; float x,y; float radio=0; float cx=0; float cy=0; float dx, dy; void dibujaCuadro(void) {     if(relleno==1){     glColor3f(r, g, b);     glBegin(GL_QUADS);     glVertex2f(5, 5);     glVertex2f(-5, 5);     glVertex2f(-5, -5);     glVertex2f(5, -5);     glEnd();     }else{     glColor3f(r, g, b);     glBegin(GL_LINE_LOOP);     glVertex2f(5, 5);     glVertex2f(-5, 5);     glVertex2f(-5, -5);     glVertex2f(5, -5);     glEnd();     } } //CAP AMERICA void estrella(float r, float g, float b){     if(relleno==1){     glColor3f...

Código Menú|Animación Israel

#include <windows.h> #include <stdlib.h> #include <stdio.h> #include <math.h> #include <GL/glut.h> #define PI 3.141592653 float rotar = 0,inc=0.1, ry=0, rx=0, ang=0,botar=1; float r=1,g=0,b=0; int figura=0; float r1=40, r2=25, r3=60, r4=30, r5=18, dx, dy; void dibujaCuadro(void) {     glColor3f(r, g, b);     glBegin(GL_QUADS);     glVertex2f(5, 5);     glVertex2f(-5, 5);     glVertex2f(-5, -5);     glVertex2f(5, -5);     glEnd(); } void circulo1 (void){     glColor3f(0,0,0);     glBegin(GL_POLYGON);     for(float i=0.0; i<2*PI; i+=0.01){         dx=r1*cos(i);         dy=r1*sin(i)-75;         glVertex2f(dx, dy);         }     glEnd(); } void circulo2 (void){     glColor3f(0,0,0);     glBegin(GL_POLYGON); ...

Código Logos Israel González

Imagen
#include <windows.h> #include <math.h> #include <GL/glut.h> #define PI 3.141592653 float r1=40,r2=25,r3=60,r4=30,r5=18,dx,dy; void circulo1 (void){     glColor3f(0,0,0);     glBegin(GL_POLYGON);     for(float i=0.0; i<2*PI; i+=0.01){         dx=r1*cos(i);         dy=r1*sin(i)-75;         glVertex2f(dx, dy);         }     glEnd(); } void circulo2 (void){     glColor3f(0,0,0);     glBegin(GL_POLYGON);     for(float i=0.0; i<2*PI; i+=0.01){         dx=r2*cos(i);         dy=r2*sin(i);         glVertex2f(dx, dy);         }     glEnd(); } void circulo3 (void){     glColor3f(0,0,0);     glBegin(GL_POLYGON);     for(float i=0.0; i<2*PI; i+=0.01){     ...

Código Yin&Yang Diana Vargas

Imagen
#include <windows.h> #include <math.h> #ifdef _APPLE_ #else #include <GL/glut.h> #include <math.h> #define PI 3.1415926 #endif float x,y; float radio=0; float cx=0; float cy=0; float dx, dy; void medcirculo (float radio, float r, float g, float b){     glColor3f(r,g,b);     glBegin(GL_POLYGON);     for(float i = 0; i<=3.1415926; i+=0.01){         dx = radio*cos(i)+cx;         dy = radio*sin(i)+cy;         glVertex2f(dy,dx);     }     glEnd(); } void circulo (float radio, float r, float g, float b){     glColor3f(r,g,b);     glBegin(GL_LINE_STRIP);     for(float i = 0; i<=2*3.1415926; i+=0.01){         dx = radio*cos(i)+cx;         dy = radio*sin(i)+cy;         glVertex2f(dx,dy);     }     glEnd(); } void c...

Código Capitán América Diana Vargas

Imagen
#include <windows.h> #include <math.h> #ifdef _APPLE_ #include <GLUT/glut.h> #else #include <GL/glut.h> #include <math.h> #define PI 3.1415926 #endif float x,y; float radio=0; float cx=0; float cy=0; float dx, dy; void estrella(float r, float g, float b){     glColor3f(r,g,g);     glBegin(GL_POLYGON);     glVertex2f(-2,2);     glVertex2f(2,2);     glVertex2f(3,-1);     glVertex2f(0,-3);     glVertex2f(-3,-1);     glEnd();     glBegin(GL_TRIANGLES);     glVertex2f(-2,2);     glVertex2f(2,2);     glVertex2f(0,6);     glVertex2f(2,2);     glVertex2f(3,-1);     glVertex2f(5.5,2);     glVertex2f(-2,2);     glVertex2f(-3,-1);     glVertex2f(-5.5,2);     glVertex2f(3,-1);     glVertex2f(0,-3);     glVertex2f(3.8,-4.7)...

Algoritmo de Bresenham y DDA

Imagen
Algoritmo de Bresenham Es un algoritmo que determina los puntos en un mapa de bits de n-dimensiones que deben ser trazados con el fin de formar una aproximación a una línea recta entre dos puntos dados. Es uno de los primeros algoritmos desarrollados en el campo de gráficos por ordenador, también se ocupa de dibujar círculos. Partimos de que las coordenadas de los pixeles en una imagen son coordenadas enteras y que conocemos los extremos del segmento que forma la línea siendo sus coordenadas (x0,y0 ) y (x1,y1 ). El algoritmo de Bresenham selecciona el entero 'y' correspondiente al pixel central que está más cercano del que sería calculado con fracciones y lo mismo para la coordenada 'x'. En las sucesivas columnas la coordenada 'y' puede permanecer con el mismo valor o incrementarse en cada paso a una unidad. La ecuación general de la línea que pasa por los extremos conocidos es: Puesto que conocemos la columna, 'x', la fila ...