[SOLVED] Computer-Graphics Lab 9

30.00 $

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

You will receive the following solution file(s) instantly after successful payment:

zip file icon LabAssignment9-4optau.zip (95.4 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
Rate this product

1. Write down a Python program to visualize ZXZ Euler angles.

A.

B.

This is how ZXZ Euler angles works

  1. Rotate along Z-axis by α
  2. Rotate along X-axis of the new frame by β
  3. Rotate along Z-axis of the new frame by γ

Start from 9-Orientation&Rotation practice code, implement ZXZ Euler angles and add code to change α, β, γ values in the following way.

i. If you press or repeat a key, the value of α, β, γ should be changed as shown in the table:

Key

Transformation

A

Increase α by 10°

Z

Decrease α by 10°

S

Increase β by 10°

X

Decrease β by 10°

D

Increase γ by 10°

C

Decrease γ by 10°

V

Initialize orientation

C. Hint: You do not need to store a composed rotation matrix as a global variable. You can just store α, β, γ as global variables.

  1. Set the window title to your student ID and the window size to (480,480).
  2. Expected result: Uploaded LabAssignment9-1.mp4
  3. Files to submit: A Python source file (Name the file whatever you want (in English). Extension should be .py)

2. Write down a Python program to compare 4 orientation interpolation methods.

A. B.

First, implement following functions:

exp & log functions

  1. exp(rv)
    1. Converts a rotation vector to a rotation matrix
    2. You can use Rodrigues’ rotation formula or the method in 9-Orientation& Rotation
    3. Returns a rotation matrix
  2. log(R)
    1. Converts a rotation matrix to a rotation vector
    2. You can use the method in 9-Orientation& Rotation slides.
    3. Returns a rotation vector (the length of the vector is the rotation angle)

Interpolation functions:
i. slerp(R1, R2, t) – slerp

1. R1 & R2: rotation matrices for start & end orientations

C.

D.

E. F.

G.

i. All interpolation functions return a rotation matrix

iv. v. vi. vii.

H. I.

D key: Toggle interpolateZYXEuler() result F key: Toggle interpolateRotMat() result
Z key: Hide all results
X key: Show all results

Set the window title to your student ID and the window size to (480,480). Expected result: Uploaded LabAssignment9-2.mp4

ii. interpolateRotVec(rv1, rv2, t) – interpolate each element of two vectors 1. rv1 & rv2: rotation vectors for start & end orientations

iii. interpolateZYXEuler(euler1, euler2, t) – interpolate each element of two euler angle tuples

iv.

1. euler1 & euler2: tuples of ZYX Euler angles for start & end orientations (euler1[0]: xang, euler1[1]: yang, euler1[2]: zang)

interpolateRotMat(R1, R2, t) – interpolate each element of two matrices

1. R1 & R2: rotation matrices for start & end orientations For all interpolation functions:

ii.

The parameter t ranges from 0.0 to 1.0
Start from the uploaded code skeleton (LabAssignment9-2-code-skeleton.py). You will need to use

  1. The given lerp() for interpolateRotVec(), interpolateZYXEuler(), interpolateRotMat()
  2. The given ZYXEulerToRotMat() for interpolateZYXEuler()
  3. Your exp(), log() implementation for slerp(), interpolateRotVec()

Program usage (already implemented in the code skeleton):

  1. When the program is run, only slerp() result is visible
  2. A key: Toggle slerp() result
  3. S key: Toggle interpolateRotVec() result

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

  • LabAssignment9-4optau.zip