SHEARING OF AN OBJECT


/* SHEARING OF AN OBJECT */
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<process.h>
#include<stdlib.h>
void main()
{
int ch,ch1;
int gd=DETECT,gm;
int n,a[3][3],b[3][10],i,x[10],y[10],c[3][10],j,k,a1,b1;
initgraph(&gd,&gm,"");
line(320,0,320,480);
line(0,240,640,240);
printf("enter th eno. of vertices");
scanf("%d",&n);
printf("enter the coordinates");
for(i=0;i<n;i++)
{
scanf("%d",&x[i]);
scanf("%d",&y[i]);
}
for(i=0;i<n;i++)
{
b[0][i]=x[i];
b[1][i]=y[i];
b[2][i]=1;
}
for(i=0;i<n-1;i++)
{
line(b[0][i]+320,b[1][i]+240,b[0][i+1]+320,b[1][i+1]+240);
line(b[0][n-1]+320,b[1][n-1]+240,b[0][0]+320,b[1][0]+240);
printf("\n 1.about x-axis");
printf("\n 2.about y-axis");
printf("\n 3.about both axis");
scanf("%d",&ch1);
a[0][0]=1;
a[0][1]=a1;
a[0][2]=0;
a[1][0]=b1;
a[1][1]=1;
a[1][2]=0;
a[2][0]=0;
a[2][1]=0;
a[2][2]=1;
if(ch!=1)
{
printf("\n enter the value of shear in x direction");
scanf("%d",&a1) ;
a[0][1]=a1 ;
for(i=0;i<3;i++)
{
for(j=0;j<n;j++)
{
c[i][j] =0;
for(k=0;k<3;k++)
{
c[i][j]+=a[i][k]*b[k][j] ;
}
}
}
}
if(ch!=2)
{
printf("\n enter the value of shear in x direction");
scanf("%d",&b1) ;
a[1][0]=b1 ;
for(i=0;i<3;i++)
{
for(j=0;j<n;j++)
{
c[i][j] =0;
for(k=0;k<3;k++)
{
c[i][j]+=a[i][k]*b[k][j] ;
}
}
}
}
  if(ch!=3)
{
printf("\n enter the value of shear in both  direction");
scanf("%d%d",&a1,&b1) ;
a[0][1]=a1 ;
a[1][0]=b1;
for(i=0;i<3;i++)
{
for(j=0;j<n;j++)
{
c[i][j] =0;
for(k=0;k<3;k++)
{
c[i][j]+=a[i][k]*b[k][j] ;
}
 }
}
}
  for(j=0;j<n;j++)
{
for(i=0;i<1;i++)
{
line(c[i][j]+320,c[i+1][j]+240,c[i][j+1]+320,c[i+1][j+1]+240);
}
}
getch();
}
closegraph();
}

Comments