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/RIT2013027_1.c

#include <stdio.h>
#include <math.h>

int main(){
	float x,y,z,t;
	x = 0;
	y = -100;
	z = 10;

	int d,i;
	d = 10;


	float a[24] = {-100,-100,100,100,-50,-50,-150,-500,-500,-100, -50,-400,-400,-100,50,50,150,500,500,100,50,400,400,100};
	float b[24] = {700,500,700,500,0,500,0,400, 400,700, 0,400, 400,600,0,500, 0,400, 400,700, 0,400,400,600};
	float c[24] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

	//translation
	for(i = 0; i <24; i++){
		a[i] = a[i]-x;
		b[i] = b[i]-y;
		c[i] = c[i] -z; 
	}

	//rotation
	float theata = M_PI/2 + atan(0.1); 
	for(i = 0; i < 24; i++){
		t = b[i];
		b[i] = b[i]*cos(theata) - c[i]*sin(theata);
		c[i] = t*sin(theata) + c[i]*cos(theata);
	}

	//projection
	for(i = 0; i < 24; i++){
		a[i] = (a[i] * d)/c[i];
		b[i] = (b[i] * d)/c[i];
		c[i] = d;
	}
	for(i = 0; i < 24; i++){
		printf("%d,%d,%d",(int)(a[i]+0.5),(int)(b[i]+0.5),(int)(c[i]+0.5));
		printf("\n");
	}

	return 0;
}