| Current Path : /var/www/html/venkat/check3/file/cg2013/pawan/ |
| Current File : /var/www/html/venkat/check3/file/cg2013/pawan/IIT2013170_1.cpp |
#include <bits/stdc++.h>
/*#include <GL/freeglut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
*/
using namespace std;
float x[4], y[4], xtr[4], ytr[4], xndtr[10], yndtr[10];
float xnd[] = {-50, -50, -150, -500, -500, -100, -50, -400, -400, -100};
float xndneg[] = {50, 50, 150, 500, 500, 100, 50, 400, 400, 100};
float ynd[] = {0, 500, 0, 400, 400, 700, 0, 400, 400, 600};
/*void draw_line(float xa, float ya, float xb, float yb) {
float dx, dy, steps, k;
float xIncrement, yIncrement, x, y;
dx = xb - xa;
dy = yb - ya;
x = xa;
y = ya;
xIncrement = dx / 10000.0;
yIncrement = dy / 10000.0;
for (k = 0; k < 10000; k++) {
x += xIncrement;
y += yIncrement;
glVertex3f(x, y, 10);
}
}
*/
void print_points() {
for(int i=0;i<3;i++){
cout<<int(x[i] + 0.5)<<","<<int(y[i] + 0.5)<<","<<10<<endl;
}
cout<<int(x[3] + 0.5)<<","<<int(y[3]+0.5)<<","<<10<<endl;
for(int i=0;i<10;i=i+2){
cout<<int(xnd[i]+0.5)<<","<<int(ynd[i]+0.5)<<","<<10<<endl;
cout<<int(xnd[i+1]+0.5)<<","<<int(ynd[i+1]+0.5)<<","<<10<<endl;
}
for(int i=0;i<10;i=i+2){
cout<<int(xndneg[i]+0.5)<<","<<int(ynd[i]+0.5)<<","<<10<<endl;
cout<<int(xndneg[i+1]+0.5)<<","<<int(ynd[i+1]+0.5)<<","<<10<<endl;
}
}
/*
void draw_square() {
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1, 1, 1);
glBegin(GL_POINTS);
for(int i=0;i<3;i++){
draw_line(x[i], y[i], x[i+1], y[i+1]);
}
draw_line(x[0], y[0], x[3], y[3]);
for(int i=0;i<10;i=i+2){
draw_line(xnd[i], ynd[i], xnd[i+1], ynd[i+1]);
draw_line(xndneg[i], ynd[i], xndneg[i+1], ynd[i+1]);
}
glEnd();
glFlush();
}*/
void rotate_translate(){
float angle = -1*M_PI/2 + atan(0.1);
for(int i=0;i<4;i++) {
float tmpx, tmpy, tmpz;
tmpz = y[i]*sin(angle) + sqrt(10100);
tmpx = (x[i]*10/tmpz);
tmpy = (y[i]*cos(angle)*10/tmpz);
x[i]=tmpx;
y[i] = tmpy;
}
for(int i=0;i<10;i++) {
float tmpx, tmpy, tmpz;
tmpz = ynd[i]*sin(angle) + sqrt(10100);
tmpx = (xnd[i]*10/tmpz);
tmpy = (ynd[i]*cos(angle)*10/tmpz);
xnd[i]=tmpx;
//ynd[i] = tmpy;
tmpz = ynd[i]*sin(angle) + sqrt(10100);
tmpx = (xndneg[i]*10/tmpz);
tmpy = (ynd[i]*cos(angle)*10/tmpz);
xndneg[i]=tmpx;
ynd[i] = tmpy;
}
}
int main(int argc, char** argv)
{
x[0] = -100;
y[0] = 700;
x[1] = -100;
y[1] = 500;
x[2] = 100;
y[2] = 500;
x[3] = 100;
y[3] = 700;
rotate_translate();
print_points();
/*glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE);
glutInitWindowSize(1000, 1000);
glutInitWindowPosition(50, 50);
glutCreateWindow("IIT2013170");
glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0);
glutDisplayFunc(draw_square);
glutMainLoop();*/
return 0;
}