| Current Path : /var/www/html/venkat/check3/file/cg2013/pawan/ |
| Current File : /var/www/html/venkat/check3/file/cg2013/pawan/iit2013155.c |
#include <stdio.h>
#include <math.h>
float xN,yN;
int flag = 0;
int drawLine(double x1, double y1, double x2, double y2, float theta) {
float dX, dY, iSteps;
float xInc, yInc, iCount, x, y;
dX = x1 - x2;
dY = y1 - y2;
if (abs(dX) > abs(dY)) {
iSteps = abs(dX);
} else {
iSteps = abs(dY);
}
xInc = dX/iSteps;
yInc = dY/iSteps;
x = x1;
y = y1;
for (iCount = 1; iCount <= iSteps; iCount++) {
xN =x*cos(theta) - y*sin(theta);
yN = x*sin(theta) + y*cos(theta);
x -= xInc;
y -= yInc;
}
xN =x*cos(theta) - y*sin(theta);
yN = x*sin(theta) + y*cos(theta);
}
int drawLineS(double x1, double y1, double x2, double y2, float theta) {
float dX, dY, iSteps;
float xInc, yInc, iCount, x, y;
dX = x1 - x2;
dY = y1 - y2;
if (abs(dX) > abs(dY)) {
iSteps = abs(dX);
} else {
iSteps = abs(dY);
}
xInc = dX/iSteps;
yInc = dY/iSteps;
x = x1;
y = y1;
xN =x*cos(theta) - y*sin(theta);
yN = x*sin(theta) + y*cos(theta);
xN =x2*cos(theta) - y2*sin(theta);
yN = x2*sin(theta) + y2*cos(theta);
if (flag == 0) {
int xCord[] = {-100,-100,100,100,-50,-50,-150,-500,-500,-100,-50,-400,-400,-100,50,50,150,500,500,100,50,400,400,100};
int yCord[] = {700,500,700,500,0,500,0,400,400,700,0,400,400,600,0,500,0,400,400,700,0,400,400,600};
int i;
int l = sizeof(xCord)/sizeof(xCord[0]);
for (i = 0; i < l; i++) {
float db = xCord[i]*cos(theta) - yCord[i]*sin(theta);
float cd = xCord[i]*sin(theta) + yCord[i]*cos(theta);
printf ("%d,%d,%d\n",(int)(db+0.5), (int)(cd+0.5), 10);
}
flag = 1;
}
for (iCount = 1; iCount <= iSteps; iCount++) {
x -= xInc;
y -= yInc;
}
xN =x*cos(theta) - y*sin(theta);
yN = x*sin(theta) + y*cos(theta);
}
void show() {
drawLine(-100, 700, 100, 700,-0.09966);
drawLine(-100, 700, -100, 500,-0.09966);
drawLine(-100, 500, 100, 500,-0.09966);
drawLine(100, 500, 100, 700,-0.09966);
drawLine(-50, 0, -50, 500,-0.09966);
drawLine(-150, 0, -500, 400,-0.09966);
drawLine(-500, 400, -100, 700,-0.09966);
drawLine(-50, 0, -400, 400,-0.09966);
drawLine(-400, 400, -100, 600,-0.09966);
drawLineS(-500, 400, -100, 700,-0.09966);
drawLineS(-50, 0, -50, 500,-0.09966);
drawLineS(-150, 0, -500, 400,-0.09966);
drawLineS(-500, 400, -100, 700,-0.09966);
drawLineS(-50, 0, -400, 400,-0.09966);
}
int main() {
show();
return 0;
}