Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <gl/freeglut.h>
- #include <cmath>
- #include <iostream>
- void init(void) // initializare fereastra de vizualizare
- {
- glClearColor(1.0, 1.0, 1.0, 0.0); // precizeaza culoarea de fond a ferestrei de vizualizare
- glMatrixMode(GL_PROJECTION); // se precizeaza este vorba de o reprezentare 2D, realizata prin proiectie ortogonala
- gluOrtho2D(0.0, 800, 0.0, 800.0); // sunt indicate coordonatele extreme ale ferestrei de vizualizare
- }
- class Punct
- {
- public:
- float x, y, z;
- Punct(int xx, int yy, int zz)
- {
- x = xx;
- y = yy;
- z = zz;
- }
- Punct()
- {
- x = y = z = 0;
- }
- };
- Punct produsVectorial(Punct A, Punct B)
- {
- Punct prod;
- prod.x = A.y * B.z - A.z * B.y;
- prod.y = A.z * B.x - A.x * B.z;
- prod.z = A.x * B.y - A.y * B.x;
- return prod;
- }
- void desen()
- {
- Punct A(1, 1, 0), B(0, 0, 1);
- Punct prod = produsVectorial(A, B);
- std::cout <<"Produsul vectorial intre A si B este: "<< prod.x << " " << prod.y << " " << prod.z<<"\n\n";
- glFlush();
- }
- void main(int argc, char** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
- glutInitWindowPosition(50, 50);
- glutInitWindowSize(800, 800);
- glutCreateWindow("Poligoane in context 3D. Fata si spatele unui poligon");
- init();
- glClear(GL_COLOR_BUFFER_BIT);
- glutDisplayFunc(desen);
- glutMainLoop();
- }
Advertisement
Add Comment
Please, Sign In to add comment