Introduction to Computer Graphics (C++) using OpenGL 1. Set the screenWidth = 80
ID: 3583571 • Letter: I
Question
Introduction to Computer Graphics (C++) using OpenGL
1. Set the screenWidth = 800, screenHeight = 600.
2. Set the world window Left: 0, Right: screenWidth, Bottom: 0, Top: screenHeight
3. Set the viewport Left: 0, Bottom: 0, Width: screenWidth, and Height: screenHeight.
4. Set the point size to 8.
5. Allow the user to place points on the screen using the right mouse button. Display the points in the blue color.
6. After the third point you will need to draw:
a. A triangle in grey color comprising of all three points.
b. Assuming three points are A, B, and C. The triangle has three line segments: AB, BC, and CA.
c. Draw the mid-points midAB, midBC and midCA of AB, BC, and AC in grey color.
d. Calculate three vectors: vAB = B-A, vBC = C – B, and vCA = A – C.
e. Calculate the perpendicular vectors vAB, vBC, vCA.
f. Calculate the start and end points of the three perpendicular bisectors:
i. startAB = midAB – 10 * vAB
ii. endAB = midAB + 10 * vAB
iii. startBC = midBC – 10 * vBC
iv. endBC = midBC + 10 * vBC
v. startCA = midCA – 10 * vCA
vi. endCA = midCA + 10 * vCA
g. If the user presses the ‘b’ key then draw the three perpendicular bisectors in Magenta. There will be three line segements:
i. Line #1: startAB – endAB
ii. Line #2: startBC – endBC
iii. Line #3: startCA – endCA
Explanation / Answer
#include #include #include #include using namespace std; const int LOW = 0; const int HIGH = 10; int main(int argc, char **argv) { time_t seconds; time(&seconds); srand((unsigned int) seconds); int u1, u2, u3, v1, v2, v3; u1 = rand() % (HIGH - LOW + 1) + LOW; u2 = rand() % (HIGH - LOW + 1) + LOW; u3 = rand() % (HIGH - LOW + 1) + LOW; v1 = rand() % (HIGH - LOW + 1) + LOW; v2 = rand() % (HIGH - LOW + 1) + LOW; v3 = rand() % (HIGH - LOW + 1) + LOW; int uvi, uvj, uvk; uvi = u2 * v3 - v2 * u3; uvj = v1 * u3 - u1 * v3; uvk = u1 * v2 - v1 * u2; coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.