Your IP : 216.73.216.40


Current Path : /var/www/html/venkat/check3/file/cg2013/pawan/
Upload File :
Current File : /var/www/html/venkat/check3/file/cg2013/pawan/IRM2013015.cpp

/**
	@Author :: Shubham
**/

#include <iostream>
#include<algorithm>
#include<bits/stdc++.h>
//#include <GL/freeglut.h>
//#include <GL/gl.h>
#define scaleValue 1000
#define pack vector<point>
#define pack3 vector<point3>

using namespace std;

struct point{
	int px;
	int py;
};

struct point3{
	int px;
	int py;
	int pz;
};

pack3 group;
pack3 group1;
pack3 group2;
pack3 group3;
pack3 group4;

pack3 group5;
pack3 group6;
pack3 group7;
pack3 group8;
pack3 group9;

int i,j,k;

double convert_angle(float t){
	double temp;
	temp = 0.0174603 * t;
	return temp;
}

/*void init_plot(){
	glutInitWindowSize(500, 500);
	glutInitWindowPosition(10, 10);
	glutCreateWindow( "Shubham Plot " );
	glOrtho(-1 * scaleValue, scaleValue, -1 * scaleValue, scaleValue, -1 * scaleValue, scaleValue);
}

void reset_screen(){
	glClearColor(0.8, 0.8, 0.8, 1.0);	// Screen color
	glClear(GL_COLOR_BUFFER_BIT);		// Reset Screen
	glColor3f(0, 0, 0);			// Plotter color
}


void draw_point(float x, float y){
	glPointSize(10.0f);			// point size
	glBegin(GL_POINTS);
		glVertex2f(x, y);
	glEnd();
	glFlush();
}

void draw_line3(point3 s, point3 e){
	GLfloat flt = 2.0;
	glLineWidth(flt);
	glBegin(GL_LINES);
		glVertex3f(s.px,s.py,s.pz);
		glVertex3f(e.px,e.py,e.pz);
	glEnd();
	glFlush();
}

void draw_line(float x, float y, float fx, float fy){
	GLfloat flt = 2.0;
	glLineWidth(flt);
	glBegin(GL_LINES);
		glVertex3f(x,y,0.0);
		glVertex3f(fx,fy,0.0);
	glEnd();
	glFlush();
}

void draw_triangle(float xa,float ya, float xb, float yb, float xc, float yc){
	glBegin(GL_TRIANGLES);
		glVertex3f(xa, ya, 0.0f);
		glVertex3f(xb, yb, 0.0f);
		glVertex3f(xc, yc, 0.0f);
	glEnd();
	glFlush();
}*/

void print_coordinates(pack3 v){
	pack3 temp;
	pack3::iterator it;
	for(it = v.begin(); it != v.end(); it++){
		point3 t = *it;
		cout << t.px << " " << t.py << " " << t.pz << endl;
	}
}

pack3 translate_particle3(pack3 v,point3 p){
	pack3 temp;
	pack3::iterator it;
	for(it = v.begin(); it != v.end(); it++){
		point3 t = *it;
		t.px +=  p.px;
		t.py += p.py;
		t.pz += p.pz;
		temp.push_back(t);
	}
	return temp;
}

pack3 perspective(pack3 v){
	pack3 temp;
	pack3::iterator it;
	for(it = v.begin(); it != v.end(); it++){
		point3 t = *it;
		int zv = t.pz;
		int zx = t.px;
		int zy = t.py;

		t.px = (float)(10 * t.px)/(10-zv);
		t.py = (float)(10 * t.py)/(10-zv);
		t.pz = 10;
		temp.push_back(t);
	}
	return temp;
}

pack3 reflect_Y(pack3 v){
	pack3 temp;
	pack3::iterator it;
	for(it = v.begin(); it != v.end(); it++){
		point3 t = *it;
		t.px = -1 * t.px;
		temp.push_back(t);
	}
	return temp;
}

pack3 rotate_particleQ(pack3 v,float theta){
	pack3 temp;
	pack3::iterator it;
	
	float angle = convert_angle(theta);
	double s = sin(theta);
	double c = cos(theta);

	for(it = v.begin(); it != v.end(); it++){
		point3 t = *it;
		point3 new_point;
		new_point.px = t.px;
		new_point.py = (float)(t.py)*c - (float)(t.pz)*s;
		new_point.pz = (float)(t.py)*s + (float)(t.pz)*c;
		temp.push_back(new_point);
	}
	return temp;
}

pack translate_particle(pack v,point p){
	pack temp;
	pack::iterator it;
	for(it = v.begin(); it != v.end(); it++){
		point t = *it;
		t.px +=  p.px;
		t.py += p.py;
		temp.push_back(t);
	}
	return temp;
}

pack rotate_particle(pack v, point p,float theta){
	pack temp;
	pack::iterator it;
	
	float angle = convert_angle(theta);
	double s = sin(angle);
	double c = cos(angle);

	for(it = v.begin(); it != v.end(); it++){
		point t = *it;
		point new_point;
		new_point.px = p.px + (float)(t.px-p.px)*c - (float)(t.py-p.py)*s;
		new_point.py = p.py + (float)(t.px-p.px)*s + (float)(t.py-p.py)*c;
		temp.push_back(new_point);
	}
	return temp;
}

pack scale_particle(pack v, point p){
	pack temp;
	pack::iterator it;
	for(it = v.begin(); it != v.end(); it++){
		point t = *it;
		t.px *=  p.px;
		t.py *= p.py;
		temp.push_back(t);
	}
	return temp;
}

/*void draw_random(){  	// Main area to define which part to make what
	pack3::iterator it;
	for(it = group.begin(); it != group.end(); it++){
		point3 temp = *it;
		it++;
		point3 temp2 = *it;
		it++;
		point3 temp3 = *it;
		it++;
		point3 temp4 = *it;
	
		draw_line3(temp,temp2);
		draw_line3(temp2,temp4);
		draw_line3(temp4,temp3);
		draw_line3(temp3,temp);
	}
	for(it = group9.begin(); it != group9.end(); it++){
		point3 temp = *it;
		it++;
		point3 temp2 = *it;
		it++;
		point3 temp3 = *it;
		it++;
		point3 temp4 = *it;
	
		draw_line3(temp,temp2);
		draw_line3(temp2,temp4);
		draw_line3(temp4,temp3);
		draw_line3(temp3,temp);
	}

	for(it = group1.begin(); it != group1.end(); it++){
		point3 temp = *it;
		it++;
		point3 temp2 = *it;
		draw_line3(temp,temp2);
	}
	for(it = group3.begin(); it != group3.end(); it++){
		point3 temp = *it;
		it++;
		point3 temp2 = *it;
		draw_line3(temp,temp2);
	}
	for(it = group7.begin(); it != group7.end(); it++){
		point3 temp = *it;
		it++;
		point3 temp2 = *it;
		draw_line3(temp,temp2);
	}
	for(it = group8.begin(); it != group8.end(); it++){
		point3 temp = *it;
		it++;
		point3 temp2 = *it;
		draw_line3(temp,temp2);
//		draw_triangle(temp.px,temp.py,temp2.px,temp2.py,temp3.px,temp3.py);
	}


}
void draw() {
	reset_screen();
	draw_random();

}*/

void computations(){
	point3 p;
	int arr[4][2] = {{-100, 700},{-100, 500},{100, 700},{100, 500}};
	int arr2[10][2] = {{-50, 0},{-50, 500},{-150, 0}, {-500, 400},{ -500, 400}, {-100, 700},{ -50, 0}, {-400, 400}, {-400, 400},{ -100, 600}};
	for(i = 0; i < 4; i++){
		cin >> p.px >> p.py;
	//	p.px = arr[i][0];
//		p.py = arr[i][1];
		p.pz = 0;
		group.push_back(p);		
	}
	for(i = 0; i < 10; i++){
		cin >> p.px >> p.py;
		//p.px = arr2[i][0];
		//p.py = arr2[i][1];
		p.pz = 0;
		group1.push_back(p);		
	}
	group3 = reflect_Y(group1);

	group4 = rotate_particleQ(group1,1.57-atan(0.1));
	group5 = rotate_particleQ(group3,1.57-atan(0.1));
	group6 = rotate_particleQ(group,1.57-atan(0.1));


	group9 = perspective(group6);
	print_coordinates(group9);
	group7 = perspective(group4);	
	print_coordinates(group7);
	group8 = perspective(group5);
	print_coordinates(group8);

}

int main(int argc, char** argv)
{	
	computations();

/*	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE);
	init_plot();

	glutDisplayFunc(draw);

	glutMainLoop();*/
	return 0;
}


/*

-100 700
-100 500
100 700
100 500
-50 0 -50 500
-150 0 -500 400
-500 400 -100 700
-50 0 -400 400
-400 400 -100 600

*/