ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
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:tcbgi");
line(x1,y1,x2,y2);
printf("nnn[ 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);
xn=((x2*r11)-(y2*r21));
(x1*r11)-(y1*r21) (x1*r12)+(y1*r22) (x2*r11)-(y2*r21) (x2*r12)+(y2*r22)
yn=((x2*r12)+(y2*r22));
line(x1,y1,xn,yn);
getch();
closegraph();

More Related Content

2 d rotation

  • 1. 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:tcbgi"); line(x1,y1,x2,y2); printf("nnn[ 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); xn=((x2*r11)-(y2*r21)); (x1*r11)-(y1*r21) (x1*r12)+(y1*r22) (x2*r11)-(y2*r21) (x2*r12)+(y2*r22) yn=((x2*r12)+(y2*r22)); line(x1,y1,xn,yn); getch(); closegraph();