[SOLVED] Computer Graphics-Lab Assignment 2

35.99 $

Category:

Description

5/5 - (1 vote)
  • Place your files under the directory structure <Assignment name>/<Problem no.>/<your file> just like the following example.

+ 2020_ITE0000_2019000001

+ LabAssignment2/

+ 1/

  • py

+ 2/

  • py

+ 3/

  • py

 

  • The submission time is determined not when the commit is made but when the git push is made.

 

  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()
    6. Files to submit: A Python source file (Name the file whatever you want (in English). Extension should be .py)

Expected output:

  1. Write down a Python program to draw a regular 12-sided polygon (dodecagon, 정12각형). A. Set the window title to your student ID and the window size to (480,480).
    1. Use np.linspace() (or np.arrange()), np.cos(), np.sin() to compute the positions of vertices.
    2. Do not hardcode the position of each vertex.
    3. The 12 vertices should be specified counterclockwise starting from the vertex on the x-axis.
    4. (Hint)
    5. If the keys 1, 2, 3, … 9, 0 are entered, the primitive type should be changed.
      1. Hint: Use a global variable to store the primitive type
Key Primitive Type
1 GL_POINTS
2 GL_LINES
3 GL_LINE_STRIP
4 GL_LINE_LOOP
5 GL_TRIANGLES
6 GL_TRIANGLE_STRIP
7 GL_TRIANGLE_FAN
8 GL_QUADS
9 GL_QUAD_STRIP
10 GL_POLYGON
  1. Files to submit: A Python source file (Name the file whatever you want (in English). Extension should be .py) B. Expected result: