#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
int
a[1][4],i,j,sx,sy,sz,k,b[4][4],c[1][4];
int
left=150,top=50,right=200,bottom=150,depth=25,topflag;
void
far bar3d(int left,int top,int right,int bottom,int depth,int topflag);
void
main()
{
int
gd=DETECT,gm;
clrscr();
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
setfillstyle(LINE_FILL,2);
bar3d(left,top,right,bottom,depth,1);
i=0;
for(j=0;j<3;j++)
c[i][j]=0;
printf("\nEnter
the scaling points:");
scanf("%d%d%d",&sx,&sy,&sz);
for(i=0;i<4;i++)
for(j=0;j<4;j++)
{
if(i==j)
b[i][j]=1;
else
b[i][j]=0;
}
b[0][0]=sx;
b[1][1]=sy;
b[2][2]=sz;
a[0][0]=left;
a[0][1]=top;
a[0][2]=depth;
a[0][3]=1;
i=0;
for(j=0;j<4;j++)
{
for(k=0;k<4;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
if(j==0)
left=c[i][j];
if(j==1)
top=c[i][j];
if(j==2)
depth=c[i][j];
c[i][j]=0;
}
a[0][0]=right;
a[0][1]=bottom;
a[0][2]=depth;
a[0][3]=1;
i=0;
for(j=0;j<4;j++)
{
for(k=0;k<4;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
if(j==0)
right=c[i][j];
if(j==1)
bottom=c[i][j];
if(j==2)
depth=c[i][j];
c[i][j]=0;
}
bar3d(left,top,right,bottom,depth,1);
getch();
}