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

#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

double agl = (3.14159/2 - atan(0.1));
int main() {
	double x[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};
	double y[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};
	double z[24] = {0};
	
	//translation
	double tx[24], ty[24], tz[24];
	for(int i = 0; i < 24; i++) {
		tx[i] = x[i]+0;
		ty[i] = y[i]+(100);
		tz[i] = z[i]+(-10);
	}
	
	//rotate;
	double rtx[24];
	double rty[24];
	double rtz[24];
	for(int i = 0; i < 24; i++) {
		rtx[i] = tx[i];
		rty[i] = ty[i]*cos(agl) - tz[i]*sin(agl);
		rtz[i] = ty[i]*sin(agl) + tz[i]*cos(agl);
	}
//	cout<<rtx[0]<<" "<<rty[0]<<" "<<rtz[0]<<endl;
	//perspective projection
	double d = 10;
	double ppjx[24];
	double ppjy[24];
	double ppjz[24];
	for(int i = 0; i < 24; i++) {
		double k = (rtz[i]/d);
		ppjx[i] = (k != 0) ? rtx[i]/k : rtx[i];
		ppjy[i] = (k != 0) ? rty[i]/k : rty[i];
		ppjz[i] = (k != 0) ? rtz[i]/k : rtz[i];
	}
	for(int i = 0; i < 24; i++) {
	/*	if(ppjx[i] < 0) ppjx[i]-=1;
		if(ppjy[i] < 0) ppjy[i]-=1;
		if(ppjz[i] < 0) ppjz[i]-=1;
		cout<<"("<<x[i]<<","<<y[i]<<","<<z[i]<<") =>\t";
	*/	cout<<(int)(ppjx[i]+0.5)<<" "<<(int)(ppjy[i]+0.5)<<" "<<(int)(ppjz[i]+0.5)<<endl;
	}
	return 0;
}