Computer-Graphics Lab 2 Solved

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

Rate this product

1. Write down a Python program to:

  1. Create a 1d array M with values ranging from 2 to 26 and print M.
  2. Reshape M as a 5×5 matrix and print M.
  3. Set the value of “inner” elements of the matrix M to 0 and print M.
  4. Assign M2 to the M and print M.
  5. Let’s call the first row of the matrix M a vector v. Calculate the magnitude of the vector v and print it.
    1. Hint:
    2. Hint: Use np.sqrt()

F. Files to submit: A Python source file (Name the file whatever you want (in English). Extension should be .py)

Expected output:

[ 2

 [17 18 19 20 21]
 [22 23 24 25 26]]

[[ 2 [ 7

3

4 5 6]

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26]

     8
[12 13 14 15 16]

9 10 11]

[[ 2 3
[ 7 0
[12 0
[17 0
[22 23 24 25 26]]

4 5 6] 0 0 11] 0 0 16] 0 0 21]

[[ 290 144 152 160 370] [ 256 274 292 310 328] [ 376 404 432 460 488] [ 496 534 572 610 648] [1490 664 712 760 1970]]

538.924855615326

2. Write down a Python program to draw clock with a regular 12-sided polygon (정12각형).

  1. Set the window title to your student ID and the window size to (480,480).
  2. Use np.linspace() (or np.arrange()), np.cos(), np.sin() to compute the positions of vertices.
  3. Use a loop statement to set the positions of all vertices. Do not specify the position by calling glVertex() individually for each vertex.
  4. The 12 vertices should be specified counterclockwise starting from the vertex on the x-axis.
  5. (Hint)
  6. If the keys 1, 2, 3, … 9, 0, Q, W are entered, the time should be changed.

i. Hint1: Use a global variable to store which keyboard button was pressed.

ii. Hint2: Use GL_LINE_LOOP to draw clock, GL_LINES to draw hour hand(시침)

G. Files to submit: A Python source file (Name the file whatever you want (in English). Extension should be .py)

H. Expected result:
When the program starts

Press ‘1’ Press ‘2’ Press ‘3’ Press ‘4’ Press ‘5’ Press ‘6’

Press ‘7’ Press ‘8’ Press ‘9’ Press ‘10’ Press ‘Q’ Press ‘W’

  • LabAssignment2-eifuj5.zip