0% found this document useful (0 votes)
16 views

Composite Transformation

The document describes a program for rotating a rectangle about an arbitrary point. The program takes user input for the coordinates of the rectangle vertices, the angle of rotation, and the point of rotation. It then applies a rotation transformation to each vertex coordinate and redraws the rotated rectangle.

Uploaded by

damannaughty1
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Composite Transformation

The document describes a program for rotating a rectangle about an arbitrary point. The program takes user input for the coordinates of the rectangle vertices, the angle of rotation, and the point of rotation. It then applies a rotation transformation to each vertex coordinate and redraws the rotated rectangle.

Uploaded by

damannaughty1
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

1)Program of Composite Transformation.

( Rotation about an arbitrarty point)


#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void main()
{
int gd=DETECT,gm;
float a[4][2],r,x,y,temp=0;
initgraph(&gd,&gm,"C:\\tc\\bgi");
cout<<"enter cordinate of rectangle : ";
for(int i=0;i<4;i++)
{
for(int j=0;j<2;j++)
{
cin>>a[i][j];
}
}
line(a[0][0],a[0][1],a[1][0],a[1][1]);
line(a[1][0],a[1][1],a[2][0],a[2][1]);
line(a[2][0],a[2][1],a[3][0],a[3][1]);
line(a[3][0],a[3][1],a[0][0],a[1][1]);
cout<<"enter the angle for rotation : ";
cin>>r;
cout<<"enter the arbitary point for rotation : ";
cin>>x>>y;
for(int i=0;i<4;i++)

{
temp=a[i][0];
a[i][0]=x+{(a[i][0]-x)*cos(r) -(a[i][1]-y)*sin(r)};

a[i][1]=y+{(temp-x)*sin(r) +(a[i][1]-y)*cos(r)};
}

line(a[0][0],a[0][1],a[1][0],a[1][1]);
line(a[1][0],a[1][1],a[2][0],a[2][1]);
line(a[2][0],a[2][1],a[3][0],a[3][1]);
line(a[3][0],a[3][1],a[0][0],a[1][1]);
getch();
closegraph();
}

You might also like