Posts

Showing posts from October, 2022

Reflection of triangle|computer graphics|

Image
 Reflection triangle in 2D transformation code #include <conio.h> #include <graphics.h> #include <stdio.h>    // Driver Code void main() {     int gm, gd = DETECT, a,x1,y1,x2,y2,x3,y3;     initgraph(&gd, &gm, "c:\\turboc3\\bgi");     cleardevice();        // Draw the graph     line(getmaxx() / 2, 0, getmaxx() / 2,          getmaxy());     line(0, getmaxy() / 2, getmaxx(), getmaxy() / 2); printf("Enter x1 and y1:\n"); scanf("%d%d",&x1,&y1); printf("Enter x2 and y2"); scanf("%d%d",&x2,&y2); printf("Enter x3 and y3\n"); scanf("%d%d",&x3,&y3);     setcolor(14);     line(x1, y1, x2, y2);     line(x2, y2, x3, y3);     line(x3, y3, x1, y1);///     getch(); printf("Enter 1 for x and 2 for y:\n"); scanf("%d",&a); switch(a){ case 1:     setcolor(3);     line(getma...

COMPOSITE 2D C PROGRAM|Computer graphics|

Image
COMPOSITE 2D TRANSFORMATION code: #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include <math.h> int xa,xb,xc,ya,yb,yc,y1a,y1b,y1c,x1a,x1b,x1c,x2a,x2b,x2c,y2a,y2b,y2c; int x3a,x3b,x3c,y3a,y3b,y3c,x4a,x4b,x4c,y4a,y4b,y4c,x5a,x5b,x5c,y5a,y5b,y5c; int tx,shx,t,ch,a,ty; float ang,theta,sx,sy; int main(void) { int gdriver = DETECT, gmode, errorcode; initgraph(&gdriver, &gmode,"c:\\turboc3\\bgi"); printf("Enter all coordinates values :"); scanf("%d %d %d %d %d %d",&xa,&ya,&xb,&yb,&xc,&yc); setcolor(GREEN); line(xa,ya,xb,yb); /* draw the original image*/ line(xb,yb,xc,yc); line(xc,yc,xa,ya); printf("Enter the value tranlsation factor :"); /* get the translation factor*/ scanf("%d",&tx); printf("Enter ty:"); scanf("%d",&ty); x1a=xa+tx; x1b=xb+tx; x1c=xc+tx; y1a=ya+ty; y1b=yb+ty; y1c=yc+ty; setcolor(RED); line(x1a,y1a,x1b,...