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/iit2013146_1.cpp

//#include <GL/glut.h>
#include <bits/stdc++.h>

using namespace std;


void perspective(float square[], float squarey[]) {
	float d, zvp, prpx;
	float prpy, prpz;

	d = 10;
	prpx = 0;
	prpy = -100;
	prpz = 10 ;

	zvp = 0;

	float a = (prpz-zvp) / (prpz - 0);
	float b = (zvp - 0) / (prpz - 0);
	float ang = atan(0.1);
	ang = 90 - ang;
	ang = ang * (22/7) / 180;
	float xsquare[24], ysquarey[24];
	for (int i = 0; i < 24; i++) {
		
		xsquare[i] = square[i] * cos(ang) - squarey[i] * sin(ang);
		ysquarey[i] = square[i] * sin (ang) + squarey[i] * cos(ang);
		cout << xsquare[i] << " "; 
		cout << ysquarey[i] << endl;
	}
}

void show()

{

float square[24], squarey[24];
        square[0] = -100;
        squarey[0] = 700;
        square[1] = -100;
        squarey[1] = 500;

        square[2] = 100;
        squarey[2] = 500;
        square[3] = 100;
        squarey[3] = 700;


        square[4] = -50;
        squarey[4] = 0;
        square[5] = -50;
        squarey[5] = 500;
        square[6] = -150;
        squarey[6] = 0;
        square[7] = -500;
        squarey[7] = 400;
        square[8] = -500;
        squarey[8] = 400;

        square[9] = -100;
        squarey[9] = 700;
        square[10] = -50;
        squarey[10] = 0;
        square[11] = -400;
        squarey[11] = 400;
        square[12] = -400;
        squarey[12] = 400;

        square[13] = -100;
        squarey[13] = 600;
        square[14] = 50;
        squarey[14] = 0;
        square[15] = 50;
        squarey[15] = 500;

        square[16] = 150;
        squarey[16] = 0;
        square[17] = 500;
        squarey[17] = 400;
        square[18] = 500;
        squarey[18] = 400;
        square[19] = 100;
        squarey[19] = 700;
        square[20] = 50;
        squarey[20] = 0;

        square[21] = 400;
        squarey[21] = 400;
        square[22] = 400;
        squarey[22] = 400;
        square[23] = 100;
        squarey[23] = 600;
	/*glClear(GL_COLOR_BUFFER_BIT);

	glColor3f(1.0, 0.0, 0.0);

	glBegin(GL_LINES);

	glVertex2f(square[0],squarey[0]);
        glVertex2f(square[1],squarey[1]);
        glVertex2f(square[1],squarey[1]);
        glVertex2f(square[2],squarey[2]);
        glVertex2f(square[2],squarey[2]);
        glVertex2f(square[3],squarey[3]);
        glVertex2f(square[3],squarey[3]);
        glVertex2f(square[0],squarey[0]);
*/
	for (int i = 4; i < 23; i += 2) {
//		glVertex2f(square[i],squarey[i]);
  //     		 glVertex2f(square[i+1],squarey[i+1]);
	}

	//glEnd();
	perspective(square, squarey);
	//glFlush();

}
 
struct Queue
{
    int front, rear, size;
    unsigned capacity;
    int* array;
};
 
struct Queue* createQueue(unsigned capacity)
{
    struct Queue* queue = (struct Queue*) malloc(sizeof(struct Queue));
    queue->capacity = capacity;
    queue->front = queue->size = 0; 
    queue->rear = capacity - 1;  
    queue->array = (int*) malloc(queue->capacity * sizeof(int));
    return queue;
}
 

int isFull(struct Queue* queue)
{  return (queue->size == queue->capacity);  }
 
int isEmpty(struct Queue* queue)
{  return (queue->size == 0); }
 
void enqueue(struct Queue* queue, int item)
{
    if (isFull(queue))
        return;
    queue->rear = (queue->rear + 1)%queue->capacity;
    queue->array[queue->rear] = item;
    queue->size = queue->size + 1;
    printf("%d enqueued to queue\n", item);
}
 
// Function to remove an item from queue.  It changes front and size
int dequeue(struct Queue* queue)
{
    if (isEmpty(queue))
        return INT_MIN;
    int item = queue->array[queue->front];
    queue->front = (queue->front + 1)%queue->capacity;
    queue->size = queue->size - 1;
    return item;
}
 
// Function to get front of queue
int front(struct Queue* queue)
{
    if (isEmpty(queue))
        return INT_MIN;
    return queue->array[queue->front];
}
 
// Function to get rear of queue
int rear(struct Queue* queue)
{
    if (isEmpty(queue))
        return INT_MIN;
    	return queue->array[queue->rear];
}
 


int main(int argc,char *argv[])
{
	int a,b;
	float c,d;
	//glutInit(&argc,argv);
	//glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
	//glutInitWindowSize (500, 500);
	//glutInitWindowPosition (100, 100);
	//glutCreateWindow ("IIT2013079");
	//init2D(0.0,0.0,0.5);
	//glutDisplayFunc(display);
	show();
	//glutMainLoop();

	return 0;

}