| Current Path : /var/www/html/venkat/check3/file/cg2013/pawan/ |
| Current File : /var/www/html/venkat/check3/file/cg2013/pawan/ism2013005_1.cpp |
#include <bits/stdc++.h>
using namespace std;
double matrix[100][100];
double matrix1[100][100];
double ans[100][100];
void MatrixMul(int n1,int n2,int n3){
bzero(ans,0);
for(int i = 0; i < n1; i++){
for(int j = 0; j < n3; j++){
for(int k = 0; k < n2; k++){
ans[i][j] += matrix[i][k]*matrix1[k][j];
}
}
}
}
void perspective_projection(double x,double y,double z,double d){
bzero(matrix,0);
matrix[0][0] = 1;
matrix[1][1] = 1;
matrix[2][2] = 1;
matrix[3][2] = 1/d;
matrix1[0][0] = x;
matrix1[1][0] = y;
matrix1[2][0] = z;
matrix1[3][0] = 1;
MatrixMul(4,4,1);
//cout<<"x' = "<<(ans[3][0]!=0?ans[0][0]/ans[3][0]:ans[0][0])<<endl;
if(ans[3][0] != 0)
{
cout<<"x' = "<<ans[0][0]/ans[3][0];
cout<<endl;
}
else
{
cout<<"x' = "<<ans[0][0];
cout<<endl;
}
if(ans[3][0] != 0)
{
cout<<"y' = "<<ans[1][0]/ans[3][0];
cout<<endl;
}
else
{
cout<<"y' = "<<ans[1][0];
cout<<endl;
}
if(ans[3][0] != 0)
{
cout<<"z' = "<<ans[2][0]/ans[3][0];
cout<<endl;
}
else
{
cout<<"z' = "<<ans[2][0];
cout<<endl;
}
}
int main()
{
double x,y,z,d;
cin>>x>>y>>z>>d;
perspective_projection(x,y,z,d);
}