| Current Path : /var/www/html/venkat/check3/file/cg2013/pawan/ |
| Current File : /var/www/html/venkat/check3/file/cg2013/pawan/RIT2013071_1.cpp |
#include<bits/stdc++.h>
using namespace std;
#define pi 3.141592
double m1[100][100]={};
double m2[100][100]={};
double ans[100][100]={};
double pt[100][3];
int length = 0;
void product(int n1,int n2,int n3);
void projection(double x,double y,double z,double d);
void rotation(double x,double y,double z,double rot_angle);
int main()
{
int i;
double xcord[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 ycord[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 zcord[24] = {0.0};
for(i = 0 ; i < 24; i++)
{
ycord[i] = ycord[i] + 100;
zcord[i] = zcord[i] -10;
}
for(i = 0; i < 24; i++)
{
rotation(xcord[i],ycord[i],zcord[i],(3.14159/2)-atan(0.1));
projection(pt[i][0],pt[i][1],pt[i][2],10);
}
}
void product(int n1,int n2,int n3){
memset(ans,0,sizeof(ans));
for(int i = 0; i < n1; i++){
for(int j = 0; j < n3; j++){
for(int k = 0; k < n2; k++){
ans[i][j] += m1[i][k]*m2[k][j];
}
}
}
}
void projection(double x,double y,double z,double d){
memset(m1,0,sizeof(m1));
m1[0][0] = 1;
m1[1][1] = 1;
m1[2][2] = 1;
m1[3][2] = 1/d;
m2[0][0] = x;
m2[1][0] = y;
m2[2][0] = z;
m2[3][0] = 1;
product(4,4,1);
double xcomp = ans[0][0];
double ycomp = ans[1][0];
double zcomp = ans[2][0];
if(ans[3][0]!=0)
{
// xcomp = ans[3][0]!=0?ans[0][0]/ ans[3][0]:ans[0][0];
if(ans[3][0])
xcomp = ans[0][0]/ans[3][0];
else
xcomp = ans[0][0];
//ycomp = ans[3][0]!=0?ans[1][0]/ans[3][0]:ans[1][0];
if(ans[3][0])
ycomp = ans[1][0]/ans[3][0];
else
ycomp = ans[1][0];
//zcomp = ans[3][0]!=0?ans[2][0]/ans[3][0]:ans[2][0];
if(ans[3][0])
zcomp = ans[2][0]/ans[3][0];
else
zcomp= ans[2][0];
}
printf("%d %d %d\n",(int)(xcomp + 0.5),(int)(ycomp+0.5),(int)(zcomp+0.5));
}
void rotation(double x,double y,double z,double rot_angle){
double cosine = cos(rot_angle);
double sine = sin(rot_angle);
memset(m1,0,sizeof(m1));
m1[0][0] = 1;
m1[1][1] = cosine;
m1[1][2] = (-1)*sine;
m1[2][1] = sine;
m1[2][2] = cosine;
m1[3][3] = 1;
m2[0][0] = x;
m2[1][0] = y;
m2[2][0] = z;
m2[3][0] = 1;
product(4,4,1);
pt[length][0] = ans[0][0];
pt[length][1] = ans[1][0];
pt[length][2] = ans[2][0];
length++;
}