| Current Path : /var/www/html/venkat/check3/file/cg2013/pawan/ |
| Current File : /var/www/html/venkat/check3/file/cg2013/pawan/program.cpp |
#include <bits/stdc++.h>
#include <GL/freeglut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
using namespace std;
float point1;
float point2;
float point3;
float point4;
float point5;
float point6;
float point7;
float point8;
void draw_line(float x1, float y0, float x2, float y2)
{
float m = (y2 - y0)/(x2 - x1);
float small = 0.0005,y,x;
if(abs(m) < 1) {
for(x = min(x1, x2); x <= max(x1, x2); x += small) {
y = m*(x - x1) + y0;
glVertex2f(x, y);
}
}
else {
for(y = min(y0, y2); y <= max(y0, y2); y += small) {
x = (y - y0)/m + x1;
glVertex2f(x, y);
}
}
}
void matrix_mul(int a[][20],int n,int m)
{
int i;
int j;
int c[20][20];
int b[20][20];
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
c[i][j]=0;
for(int k=0;k<m;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
}
void rotation(float xfirst, float yfirst, float xsecond, float ysecond)
{
float za, zb;
float xpoint;
float ypoint;
float zpoint;
float xpoint1;
float ypoint1;
float zpoint1;
float angle;
angle = acos(-1)/2 - atan(0.1);
xpoint = xfirst;
ypoint = yfirst * cos(angle);
zpoint = yfirst * sin(angle);
xpoint1 = xsecond;
ypoint1 = ysecond * cos(angle);
zpoint1 = ysecond * sin(angle);
za = zpoint + sqrt(1.0100);
zb = zpoint1 + sqrt(1.0100);
xfirst = (xfirst / za) * 1;
yfirst = (ypoint / za) * 1;
xsecond = (xsecond / zb) * 1;
ysecond = (ypoint1 / zb) * 1;
cout << xfirst << " " << yfirst << endl;
draw_line(xfirst, yfirst, xsecond, ysecond );
}
void project() {
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1, 1, 1);
glBegin(GL_POINTS);
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
rotation(point1, point2, point3, point4);
rotation(point3, point4, point7, point8);
rotation(point7, point8, point5, point6);
rotation(point5, point6, point1, point2);
rotation(-0.050, 0.0, -0.050,0.500);
rotation(-0.150,0.0, -0.500,0.400);
rotation(-0.500,0.400, -0.100,0.700);
rotation(-0.050, 0.0, -0.400,0.400);
rotation(-0.400, 0.400 ,-0.100,0.600);
rotation(0.050, 0.0, 0.050,0.500);
rotation(0.150,0.0, 0.500,0.400);
rotation(0.500,0.400, 0.100,0.700);
rotation(0.050, 0.0, 0.400,0.400);
rotation(0.400, 0.400 ,0.100,0.600);
glEnd();
glFlush();
}
int main(int argc, char ** argv)
{
point1 = -0.100;
point2 = 0.700;
point3 = -0.100;
point4 =0.500;
point5 = 0.100;
point6 = 0.700;
point7 = 0.100;
point8 =0.500;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE);
glutInitWindowSize(500, 500);
glutInitWindowPosition(50, 50);
glutCreateWindow("yeah");
glutDisplayFunc(project);
glutMainLoop();
return 0;
}