Circle Mi
Circle Mi
h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void parametric(int
int rx = x1
int ry = y1
printf("%d,
}
float getT(int i, int j, int x1, int y1, int rx, int ry, int x2, int y2){
float numer = (x1-rx)*i + (y1-ry)*j;
float denom = (x2-x1)*(-i) + (y2-y1)*(-j);
return numer/denom;
}
float max(float a, float b, float c){
printf("max passed %f, %f, %f\n", a, b, c);
if(a>b && a>c)return a;
else if(b>a && b>c)return b;
else return c;
}
float min(float a, float b, float c){
printf("min passed %f, %f, %f\n", a, b, c);
if(a<b && a<c)return a;
else if(b<a && b<c)return b;
else return c;
}
void putT(float t, int x1, int y1, int x2, int y2, int *px1, int *py1){
int x = int(x1 + (x2-x1)*t);
int y = int(y1 + (y2-y1)*t);
*px1 = x;
*py1 = y;
}
void drawRectangle(int
rx1 = rx1*10;
rx2 = rx2*10;
ry1 = ry1*10;
ry2 = ry2*10;
rx1 = 320+rx1;
rx2 = 320+rx2;
ry1 = 240-ry1;
ry2 = 240-ry2;
line(rx1, ry1,
line(rx1, ry2,
line(rx2, ry2,
line(rx1, ry1,
}
rx1,
rx2,
rx2,
rx1,
ry2);
ry2);
ry1);
ry2);
void foo(){
int x,y,r,h,de,dse;
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"C:\\TC\\BGI");
line(0,240,640,240);
line(320,0,320,480);
//printf("the
// printf("the
//
printf("the
//
printf("the
value
value
value
value
of
of
of
of
< 0){
getT(-1, 0, x1, y1, rx1, ry2, x2, y2);
0, x1, y1, rx2, ry2, x2, y2);
1, x1, y1, rx1, ry2, x2, y2);
-1, x1, y1, rx1, ry1, x2, y2);
tleft
tbottom
tright
ttop
=
=
=
=
%f
%f
%f
%f
%f\n",
%f\n",
%f\n",
%f\n",
tleft ,
tbottom,
tright ,
ttop ,
4.0/13);
2.0/5);
12.0/13);
6.0/5.0);
printf("\n\n");
printf("The minimum value is %f\n", min(1.0, float(tright) , float(ttop)
));
printf("The maximum value is %f\n", max(0.0, float(tbottom), float(tleft
)));
float t1 = min(1.0, float(tright) , float(ttop ));
float t2 = max(0.0, float(tbottom), float(tleft));
int px1;
int py1;
int px2;
int py2;
putT(t1, x1, y1, x2, y2, &px1, &py1);
putT(t2, x1, y1, x2, y2, &px2, &py2);
//
//
}
void linedd(int x1, int y1, int x2, int y2){
x1 *= 10;
y1 *= 10;
x2 *= 10;
y2 *= 10;
line(320+x1, 240-y1, 320+x2, 240-y2);
}
void drawLine(int x1, int y1, int x2, int y2,
int rx1, int ry1, int rx2, int ry2){
//
delay(2000);