Resources » Articles/Knowledge Sharing » General

2d-translation-scaling


Posted Date: 04-Nov-2009  Last Updated:   Category: General    
Author: Member Level: Silver    Points: 2






2D-TRANSLATION-SCALING:
PROGRAM:
#include
#include
#include
int a[1][3],e,i,j,k,side,x[10],y[10],sx,sy;
float b[3][3],c[1][3];
void display(void);
void main()
{
int gd=DETECT,gm;
clrscr();
initgraph(&gd,&gm,"I:\\tc\\bgi");
printf("\nEnter the number of sides:");
scanf("%d",&side);
for(i=0;i{
printf("\n Enter the point %d:",i+1);
scanf("%d%d",&x[i],&y[i]);
printf("\n");
}
clrscr();
display();
getch();
i=0;
for(j=0;j<3;j++)
c[i][j]=0;
printf("\n\n\n\nEnter the scaling vector:");
scanf("%d%d",&sx,&sy);
clrscr();
display();
for(i=0;i<3;i++) {
for(j=0;j<3;j++) {
b[i][j]=0;
}}
b[0][0]=sx;
b[1][1]=sy;
b[2][2]=1;
e=0;
while(ea[0][0]=x[e];
a[0][1]=y[e];
a[0][2]=1;
i=0;
for(j=0;j<3;j++) {
for(k=0;k<3;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
if(j==0)
x[e]=c[i][j];
if(j==1)
y[e]=c[i][j];
c[i][j]=0;
}
e++;
}
display();
getch();
}
void display()
{
for(i=0;iline(x[i],y[i],x[i+1],y[i+1]);
line(x[i],y[i],x[0],y[0]);
return;
}


Did you like this resource? Share it with your friends and show your love!




Responses to "2d-translation-scaling"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Awards & Gifts
    Active Members
    TodayLast 7 Daysmore...

    ISC Technologies, Kochi - India. Copyright © All Rights Reserved.