- Reflection And Shearing In Computer Graphics Programs
- Reflection And Shearing In Computer Graphics Programming
/* C PROGRAM TO DEMONSTRATE SHEARING TRANSFORMATION*/
/* AUTHOR : DEEPAK MAHAKALE 3RD YEAR IT SRCOEM, NAGPUR*/#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
void main()
{
int poly[30],a[9][3],b[3][3],c[9][3],poly2[30];
int x=0,y=0,p,i,j,k,xc,yc,ch;
int gd=DETECT,gm;
clrscr();
initgraph(&gd,&gm,'C:/TC/BGI');
xc=getmaxx()/2;
yc=getmaxy()/2;
setcolor(1);
setbkcolor(15);
setfillstyle(6,3);
printf('n Enter number of points : ');
scanf('%d',&p);
j=0;
for(i=0;i<p*2;i+=2)
{
printf('n Enter cordinate point x%d and y%d : ',j+1,j+1);
scanf('%d',&poly[i]);
scanf('%d',&poly[i+1]);
j++;
}
poly[p*2]=poly[0];
poly[p*2+1]=poly[1];
for(i=0;i<p*2;i+=2)
{
poly2[i]=xc+poly[i];
poly2[i+1]=yc-poly[i+1];
}
poly2[p*2]=poly2[0];
poly2[p*2+1]=poly2[1];
fillpoly(p+1,poly2);
line(0,yc,xc*2,yc);
line(xc,0,xc,yc*2);
printf('n Shearing of : n 1. x n 2. y n 3. Bothn enter choice : ');
scanf('%d',&ch);
if(ch1)
{
printf('n Enter x shear value : ');
scanf('%d',&x);
}
if(ch2)
{
printf('n Enter y shear value : ');
scanf('%d',&y);
}
if(ch3)
{
printf('n Enter x shear value : ');
scanf('%d',&x);
printf('n Enter y shear value : ');
scanf('%d',&y);
}
j=0;
for(i=0;i<p;i++)
{
a[i][0]=poly[j];
a[i][1]=poly[++j];
a[i][2]=1;
++j;
}
if(ch1)
{
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
b[i][j]=0;
if(ij)
{
b[i][j]=1;
}
}
}
b[1][0]=x;
}
else if(ch2)
{
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
b[i][j]=0;
if(ij)
{
b[i][j]=1;
}
}
}
b[0][1]=y;
}
else if(ch3)
{
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
b[i][j]=0;
if(ij)
{
b[i][j]=1;
}
}
}
b[1][0]=x;
b[0][1]=y;
}
for(i=0;i<p;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=0;
for(k=0;k<3;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf('nnnnnt After Shearing : ');
for(i=0,j=0;i<p;i++,j+=2)
{
poly[j] =xc+c[i][0];
poly[j+1]=yc-c[i][1];
}
poly[j] =poly[0];
poly[j+1]=poly[1];
setfillstyle(9,2);
fillpoly(p+1,poly);
getch();
closegraph();
}
Reflection And Shearing In Computer Graphics Programs
C program to draw circle in second quadrant in ant. C program to draw circle in second quadrant in clo. C program to draw circle in first quadrant in anti. C program to draw circle in first quadrant in cloc. C program to demonstrate scaling transformation; c program to demonstrate reflection transformation. C program to demonstrate. C graphics program for reflection about X- axis, Y. Program using Bresenham's line drawing algorithm (. C graphics program to rotate an object about the o. C graphics program to rotate an object using arbit. C graphics program to scale a triangle ( in all qu. C graphics program to translate a triangle from on. Midpoint Circle.
Reflection And Shearing In Computer Graphics Programming
Types of Transformations (Reflection and Shearing) in Computer Graphics. Translations in Computer Graphics. Rotation in Computer Graphics. Scaling in Computer Graphics. Window port and Viewport in Computer Graphics. Pointing and positioning techniques in Computer Graphics. Clipping in Computer Graphics. In this article, we will discuss how to perform reflection in C using computer graphics using logic rather than the direct matrix formula of translation followed by rotation and translation. This technique has currently been applied for the object taken as a triangle, the code can be applied to any object, provided the (X n, Y n ) coordinates. Besides basic transformations other transformations are reflection and shearing. Reflection: Reflection is a transformation that produces the mirror image of an object relative to an axis of reflection. The mirror image is generated relative to an axis of reflection by rotating the object by 180 degree about the axis.