Programs
MCA Syllabus
HSC What next?
About Us
Contact Us
2D Transformation Translation Rotation Scaling
The Below Programs are for 2D Transformation. This is a part
of Mumbai University MCA Colleges Computer Graphics MCA
Sem 2.2D Translation:
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
void main()
{
int graphdriver=DETECT,graphmode,errorcode;
int i;
int x2,y2,x1,y1,x,y;
printf("Enter the 2 line end points:");
printf("x1,y1,x2,y2");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
initgraph(&graphdriver,&graphmode,"c:\\tc\\bgi");
line(x1,y1,x2,y2);
printf("Enter translation co-ordinates ");
printf("x,y");
scanf("%d%d",&x,&y);
x1=x1+x;
y1=y1+y;
x2=x2+x;
y2=y2+y;
printf("Line after translation");
line(x1,y1,x2,y2);
getch();
closegraph();
2D Rotation:
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
void main()
{
int graphdriver=DETECT,graphmode,errorcode;
int i;
int x2,y2,x1,y1,x,y,xn,yn;
double r11,r12,r21,r22,th;
clrscr();
printf("Enter the 2 line end points:");
printf("x1,y1,x2,y2");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
initgraph(&graphdriver,&graphmode,"c:\\tc\\bgi");
line(x1,y1,x2,y2);
printf("\n\n\n[ Enter the angle");
scanf("%lf",&th);
r11=cos((th*3.1428)/180);
r12=sin((th*3.1428)/180);
r21=(-sin((th*3.1428)/180));
r22=cos((th*3.1428)/180);
//printf("%lf %lf %lf %lf",r11,r12,r21,r22);
xn=((x2*r11)-(y2*r12));
yn=((x2*r12)+(y2*r11));
line(x1,y1,xn,yn);
getch();
closegraph();
}
2D Scaling:
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
void main()
{
int graphdriver=DETECT,graphmode,errorcode;
int i;
int x2,y2,x1,y1,x,y;
printf("Enter the 2 line end points:");
printf("x1,y1,x2,y2");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
initgraph(&graphdriver,&graphmode,"c:\\tc\\bgi");
line(x1,y1,x2,y2);
printf("Enter scaling co-ordinates ");
printf("x,y");
scanf("%d%d",&x,&y);
x1=(x1*x);
y1=(y1*y);
x2=(x2*x);
y2=(y2*y);
printf("Line after scaling");
line(x1,y1,x2,y2);
getch();
closegraph();
}
Hope this Program is useful to you in some sense or other. Keep
on following this blog for more Mumbai University MCA
College Programs. Happy Programming and Studying.
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest
No comments:
Post a Comment
Post a Comment
Newer Post Older Post Home
Subscribe to: Post Comments (Atom)
Download
Browse
2012 (75)
2011 (64)
2010 (44)
o December 2010 (16)
o November 2010 (14)
Sutherland-Hodgeman Polygon Clipping
2D Transformations 1 program
Mid Point Ellipse Drawing Algorithm
Character Generation Computer Graphics
Liang-Barsky Algorithm CG
Cohen-Sutherland Algorithm
Cohen-Sutherland Line Clipping
3D Transformations, Translation, Rotation, Scaling...
2D Transformation Translation Rotation Scaling
Display File Creation CG
line drawing using DDA algorithm
Normalized to Actual coordinates conversion
Animation/Movement of Circles Graphics
Bresenhams Line Drawing Algorithm
o October 2010 (1)
o March 2010 (13)
Total Pageviews
795,936
Contributors
SS Sagar
Siddhesh Shetye
Mukesh Patidar
Interesting
Data Structure
UML Diagrams
Data Communication And networking
Computer Graphics
Interview Questions
Popular Posts
UML Diagrams Library Management System
UML Diagrams for ATM Machine
Template images by dino4. Powered by Blogger.