Está en la página 1de 3

“Gráfico de Línea y Circulo”

Universidad José Carlos Mariátegui

PRESENTADO POR:

Donovan Leonidas Cuayla López

DOCENTE:

Javier Coaila Coayla

ESCUELA PROFESIONAL:

Ingeniería de Sistemas e Informática

ASIGNATURA:

Computación Gráfica

CICLO X

MOQUEGUA, SEPTIEMBRE DE 2018


Algoritmo DDA Línea

void linea_DDA (int x1,int y1,int x2,int y2)

float ax,ay,x,y,m;

int i;

if(abs(x2-x1)>=abs(y2-y1))

m=abs(x2-x1);

else

m=abs(y2-y1);

ax=(x2-x1)/m;

ay=(y2-y1)/m;

x=(float)x1;

y=(float)y1;

i=1;

while(i<=m)

putpixel((150+floor(x)),(120-floor(y)),3);

x=x+ax;

y=y+ay;

i=i+1;

}
Algoritmo DDA circulo

void circulo_DDA(double radio,double col)

double rx=radio;

double x=round(rx);

double y=0;

int pos=200;

while(y<=x)

putpixel(pos+x,pos+y,3); putpixel(pos+y,pos+x,4);//inferior derecho

putpixel(pos+-x,pos+y,5); putpixel(pos+-y,pos+x,6);

putpixel(pos+x,pos-y,7); putpixel(pos+y,pos-x,8);

putpixel(pos+-x,pos+-y,1); putpixel(pos+-y,pos+-x,2);

rx=rx-(y/rx);

x=round(rx);

y=y+1;

Ventana resultante

También podría gustarte