In which, we begin implementing conversions between euler angles to matrices
The remainder of the course will use a common animation framework. This framework provides
basecode for handling user input, drawing, and loading characters and motions. With each
assignment, you will complete missing functionality to create your own basic animation
system. To see what we're working towards, we have executables of completed assignments
TODO here.
This week, we will focus on conversion routines between euler angles and matrices. These
routines will allow us to load motion files later (which use euler angles to store poses).
In a subsequent week, we will implement conversion routines between quaternions and matrices.
Quaternions will allow us to smoothly interpolate between poses.
Step 1: Get the source
The source is managed and stored on github.swarthmore.edu.
You will need a Swarthmore git account for submitting assignments. If you don't have
one already, instructions are here.
> mkdir cs91
> cd cs91
> git clone git@github.swarthmore.edu:cs91-s17/AnimationFramework-YOURUSERNAME.git AnimationFramework
You should now have a directory named AnimationFramework. The repository includes code for
a test application named BasicViewer as well as the basecode for this week's assignment.
In the remainder of your assignments, you will be implementing features to an animation library.
As we progress in the course material, we will be adding demo applications to this repository to
test these new features.
This week, we will work on the Rotations demo, where we will implement spinning teapots using Euler angles.
Step 2: Compile and run
We will use cmake to generate makefiles for the source. We will use out of source builds
for this class.
> cd AnimationFramework
> mkdir build
> cd build
> cmake ..
> make
IMPORTANT: Do not check in temporary files in build!!! This should not occur automatically because build* is listed in .gitignore.
The resulting application shows teapots in a 3 by 3 grid. Each teapot tests a conversion function. This week, we will
implement Euler angle conversions. Next week, we will complete the demo with quaternion conversions.
> ../bin/Rotations
The executable should pop up an openGL window the looks something like the following
Assignment 2: Due Feb 6
Euler angles describe rotations as a sequence of rotations around each axis. Any sequence is
valid: we can rotate first around X, then Y, then Z; or we can rotate first around Y,
then X, and then Z.
The basecode includes classes for 3x3 rotation matrices,
defined as
mat3(located in libsrc\animation\aRotation.*) and 3-tuple vectors and points, defined as
vec3 (implemented in
libsrc\animation\aVector.*). Using these
classes, this assignment asks you to implement conversions between
matrices and all euler rotation orders.
- (10 points) Convert from euler angles to a 3x3 matrix, e.g. mat3::FromEulerAnglesXYZ()
- (10 points) Convert from euler angles to a 3x3 matrix, e.g. mat3::FromEulerAnglesXZY()
- (10 points) Convert from euler angles to a 3x3 matrix, e.g. mat3::FromEulerAnglesYXZ()
- (10 points) Convert from euler angles to a 3x3 matrix, e.g. mat3::FromEulerAnglesYZX()
- (10 points) Convert from euler angles to a 3x3 matrix, e.g. mat3::FromEulerAnglesZYX()
- (10 points) Convert from euler angles to a 3x3 matrix, e.g. mat3::FromEulerAnglesZXY()
- (10 points) Convert from a 3x3 matrix to euler angles, e.g. mat3::ToEulerAnglesXYZ()
- (10 points) Convert from a 3x3 matrix to euler angles, e.g. mat3::ToEulerAnglesXZY()
- (10 points) Convert from a 3x3 matrix to euler angles, e.g. mat3::ToEulerAnglesYXZ()
- (10 points) Convert from a 3x3 matrix to euler angles, e.g. mat3::ToEulerAnglesYZX()
- (10 points) Convert from a 3x3 matrix to euler angles, e.g. mat3::ToEulerAnglesZYX()
- (10 points) Convert from a 3x3 matrix to euler angles, e.g. mat3::ToEulerAnglesZXY()
The functions of the form mat3::FromEulerAngles take a triplet of angles (stored in a vec3)
and set the contents of a mat3 instance. They then return a copy of the matrix.
The functions of the form mat3::ToEulerAngles extract the euler angles from the contents
of our matrix and set them in a reference to a vec3. Then it returns true or false based
on whether the solution is one of infinitly many solutions.
In lab today, we will sketch out together how to implement a single pair of
conversion routines for XYZ euler angles.
Implementing conversions from euler angles to a matrix
First, let's look at the functions currently available in vec3 and mat3
(located in \libsrc\animation)
After your more familiar with the implementation of these classes, try
implementing mat3::FromEulerAnglesXYZ
Implementing conversions from a matrix to euler angles
Next, derive the cosine/sine formulas for each \(a_{ij}\) element in
an XYZ euler matrix. Use Octave's symbolic package to compute the algebraic
form of the matrix.
Using the formulas for each element, extract the X, Y, and
Z angles. In your implementation, be carefull of edge cases around 90 degrees!
Your implementation to go in mat3::ToEulerAnglesXYZ.
Submission Guidelines
Submitting your assignment
Students should submit their code along with a README and videos. The README
can be very brief, consisting of
- answers to questions,
- descriptions of what was completed, including extra challenges, and
- how long the assignment took you and what was the hardest part
Videos should show results, including any extra challenges. Videos will be collected together and shown during class presentations. Please submit a mp4 of length no more than 60 seconds. For example
- Capture the demo window with recordmydesktop --windowid [OpenGLViewerId] demo.ogv
- To get the window id, run xwininfo and selected the homework window
.
- Check the recording with mplayer demo.ogv or run firefox demo.ogv
- Convert the ogv to a smaller mp4 file with ffmpeg -i demo.ogv -f mp4 -strict -2 demo.mp4
NOTE: If you're running out of space because of big files, try using the /local drive for temporary storage.
About checkins
You will be asked to talk for 1 minute about your homework assignment. This is not much time, so prepare what you want to say:
- Give your name (at least to start, until everyone gets to know each other)
- Say one interesting thing about your assignment; ideally something unique to your experience. Some ideas
- Did you learn anything (os, programming, tools, etc) while working on the assignment that might be interesting or helpful to the whole class?
- Were there any interesting/surprising bugs that you encountered?
- Describe any extra challenges you completed.
- Did the assignment make you curious about any related topics?