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

#include <iostream>
#include <cmath> 


using namespace std; 
 
typedef struct {
    float x;
    float y;
    float z;
} Point;

Point p[100], perP[100];
Point prp;
int n;
double zvp;


void perProFormula(int x, int y, int z, Point prp, Point &perP, double zvp);
void showPoint(Point jiskoDisplayKarnaHai); 


int main(int argc, char** argv)
{
	n = 14;
	
	int pts[][3] = {{-100, 700, 0}, {-100, 500,0},{100, 500, 0}, {100, 700, 0}, {-50,0,0},{-50,500,0},{50,0,0},{50,0,0}, {-500,400,0},{500,400,0} ,{-400,400,0},{400,400,0}, {-100,600,0},{100,600,0}};
	
    	prp.x = 0; 
	prp.y = -100;
	prp.z = 10;
	
    	zvp = -10;

	for (int i = 0; i < n; i++) {
    perProFormula(pts[i][0],pts[i][1],pts[i][2], prp, perP[i], zvp);
	
		
	}
	
    return 0;
}



void perProFormula(int x, int y, int z, Point prp, Point &perP, double zvp)
{	
	
	double a = (prp.z - zvp) / (prp.z - z);
	double b = (zvp - z) / (prp.z - z);

	double x1 = x * a + prp.x * b;
	double y1 = y * a + prp.y * b;
	
	
	 cout << x1 <<"," << y1 << "," << -10 << endl;
}

void showPoint(Point p) 
{
    cout  << p.x << "," << p.y << "," << p.z << endl;
}