#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
#include<graphics.h>
#include<dos.h>
void main(){
int gd = DETECT, gm;
int midx,midy;
float deg=45,angle,x1,y1,x2,y2,x3,y3;
midx=320;midy=240;
angle=deg*M_PI/180;
initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
line(midx,midy,midx+100,midy);
line(midx+100,midy,midx+100,midy-100);
delay(1000);
x1=(midx+100-midx)*cos(angle) - (midy-midy)*sin(angle) + midx;
y1=(midx+100-midx)*sin(angle) + (midy-midy)*cos(angle) + midy;
x2=(midx+100-midx)*cos(angle) - (midy-100-midy)*sin(angle) + midx;
y2=(midx+100-midx)*sin(angle) + (midy-100-midy)*cos(angle) + midy;
delay(200);
cleardevice();
printf("%f %f",x1,y1);
line(midx,midy,x1,y1);
line(x1,y1,x2,y2);
delay(1000);
cleardevice();
deg=90;
angle=(deg*M_PI)/180;
x3=(x2-x1)*cos(angle) - (y2-y1)*sin(angle) + x1;
y3=(x2-x1)*sin(angle) + (y2-y1)*cos(angle) + y1;
printf("%f %f",x1,y1);
printf("\n%f %f",x3,y3);
line(midx,midy,x1,y1);
line(x1,y1,x3,y3);
getch();
}
#include<conio.h>
#include<stdlib.h>
#include<math.h>
#include<graphics.h>
#include<dos.h>
void main(){
int gd = DETECT, gm;
int midx,midy;
float deg=45,angle,x1,y1,x2,y2,x3,y3;
midx=320;midy=240;
angle=deg*M_PI/180;
initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
line(midx,midy,midx+100,midy);
line(midx+100,midy,midx+100,midy-100);
delay(1000);
x1=(midx+100-midx)*cos(angle) - (midy-midy)*sin(angle) + midx;
y1=(midx+100-midx)*sin(angle) + (midy-midy)*cos(angle) + midy;
x2=(midx+100-midx)*cos(angle) - (midy-100-midy)*sin(angle) + midx;
y2=(midx+100-midx)*sin(angle) + (midy-100-midy)*cos(angle) + midy;
delay(200);
cleardevice();
printf("%f %f",x1,y1);
line(midx,midy,x1,y1);
line(x1,y1,x2,y2);
delay(1000);
cleardevice();
deg=90;
angle=(deg*M_PI)/180;
x3=(x2-x1)*cos(angle) - (y2-y1)*sin(angle) + x1;
y3=(x2-x1)*sin(angle) + (y2-y1)*cos(angle) + y1;
printf("%f %f",x1,y1);
printf("\n%f %f",x3,y3);
line(midx,midy,x1,y1);
line(x1,y1,x3,y3);
getch();
}
No comments:
Post a Comment