$30
ECE 417/598: Homework 1
Max marks: 100
You are allowed to use any matrix or linear algebra library (Eigen or xtensor), but no library
that implements rotation matrices. You are not
allowed to use Eigen/Geometry. You can use
the following code for generating random rotation matrices: random rotation.cpp. You can
also use the following template to fill in your answers: hw1.cpp
1 Jan 24 Lecture: 3D transformations
Problem 1 Degrees of Freedom of a quantity is
the number independent scalar variables needed
to represent that quantity. What is degrees of
freedom required to
1. Position and orientation in 1-D
2. Position and orientation in 2-D
3. Position and orientation in 3-D
4. Position and orientation in 4-D
(10 marks. Estimated time: 15 min) Justify your
answer.
Problem 2 Write a program in C++ that
checks if a given 3x3 matrix is a valid Rotation
matrix is a valid Rotation matrix (check for orthonormality i.e. orthogonality and determinant
= 1). You may use Eigen’s matrix multiplication
and determinant() function. (10 marks. Used
in the following problems. Estimated time: 15
min).
Problem 3 In class, we proved the expression
to convert roll (θ), pitch (φ), yaw (ψ) from Euler
Angles to Rotation matrix,
R(θ, φ, ψ) =
r11 r12 r13
r21 r22 r23
r31 r32 r33
= Rz(ψ)Ry(φ)Rx(θ).
(1)
What if we want to do the inverse? Prove that
given a proper 3x3 rotation matrix (R>R = I
and det(R) = 1) , the Euler angles are given by
θ(R)
φ(R)
ψ(R)
=
arctan2(r32, r33)
− arcsin(r31)
arctan2(r21, r11)
(2)
where rij is the element in ith row and jth column of the rotation matrix R. (10 marks. Used
in the following problems. Estimated time: 15
min).
Problem 4 Write a pair of functions in C++
that converts rotation matrix from XYZ Euler
angles (roll, pitch, yaw) and vice versa. Test the
pair of functions with randomly generated Euler
angles. And check if the converted rotation matrix is orthonormal. What happens when pitch =
π/2, are you able to convert from rotation matrix to Euler angle? Why or why not? (50 marks.
Estimated time: 30 min)
Problem 5 Write a function in C++ that generates a 4x4 transformation matrix given XYZ
Euler angles (roll, pitch, yaw) and translation.
You can use the function that you wrote in
Prob 4(20 marks. Estimated time: 15 min).
1