A `Skeleton`(defined in `scene/skeleton.h`) is what we use to drive our animation. You can think of them like the set of bones we have in our own bodies and joints that connect these bones. For convenience, we have merged the bones and joints into the `Joint` class which holds the orientation of the joint relative to its parent as euler angle in its `pose`, and `extent` representing the direction and length of the bone with respect to its parent `Joint`. Each `Mesh` has an associated `Skeleton` class which holds a rooted tree of `Joint`s, where each `Joint` can have an arbitrary number of children.
All of our joints are ball `Joint`s which have a set of 3 rotations around the [[task2_media/0027.png|height=9px]], [[task2_media/0028.png|height=12px]], and [[task2_media/0029.png|height=9px]] axes, called _Euler angles_. Whenever you deal with angles in this way, a fixed order of operations must be enforced, otherwise the same set of angles will not represent the same rotation. In order to get the full rotational transformation matrix, [[task2_media/0030.png|height=14px]], we can create individual rotation matrices around the [[task2_media/0031.png|height=14px]], [[task2_media/0032.png|height=14px]], and [[task2_media/0033.png|height=14px]] axes, which we call [[task2_media/0034.png|height=16px]], [[task2_media/0035.png|height=18px]], and [[task2_media/0036.png|height=16px]] respectively. The particular order of operations that we adopted for this assignment is that [[task2_media/0037.png|height=18px]].
All of our joints are ball `Joint`s which have a set of 3 rotations around the <imgsrc=task2_media/0027.pngheight="20">, <imgsrc=task2_media/0028.pngheight="20">, and <imgsrc=task2_media/0029.pngheight="20"> axes, called _Euler angles_. Whenever you deal with angles in this way, a fixed order of operations must be enforced, otherwise the same set of angles will not represent the same rotation. In order to get the full rotational transformation matrix, <imgsrc=task2_media/0030.pngheight="20">, we can create individual rotation matrices around the<imgsrc=task2_media/0031.pngheight="20">, <imgsrc=task2_media/0032.pngheight="20">, and <imgsrc=task2_media/0033.pngheight="20"> axes, which we call <imgsrc=task2_media/0034.pngheight="20">, <imgsrc=task2_media/0035.pngheight="20">, and <imgsrc=task2_media/0036.pngheight="20"> respectively. The particular order of operations that we adopted for this assignment is that <imgsrc=task2_media/0037.pngheight="20">.
### Forward Kinematics
_Note: These diagrams are in 2D for visual clarity, but we will work with a 3D kinematic skeleton._
When a joint's parent is rotated, that transformation should be propagated down to all of its children. In the diagram below, [[task2_media/0038.png|height=12px]] is the parent of [[task2_media/0039.png|height=12px]] and [[task2_media/0040.png|height=12px]] is the parent of [[task2_media/0041.png|height=12px]]. When a translation of [[task2_media/0042.png|height=12px]] and rotation of [[task2_media/0043.png|height=16px]] is applied to [[task2_media/0044.png|height=12px]], all of the descendants are affected by this transformation as well. Then, [[task2_media/0045.png|height=12px]] is rotated by [[task2_media/0046.png|height=16px]] which affects itself and [[task2_media/0047.png|height=12px]]. Finally, when rotation of [[task2_media/0048.png|height=16px]] is applied to [[task2_media/0049.png|height=12px]], it only affects itself because it has no children.
When a joint's parent is rotated, that transformation should be propagated down to all of its children. In the diagram below, <imgsrc=task2_media/0038.pngheight="20"> is the parent of <imgsrc=task2_media/0039.pngheight="20"> and <imgsrc=task2_media/0040.pngheight="20"> is the parent of <imgsrc=task2_media/0041.pngheight="20">. When a translation of <imgsrc=task2_media/0042.pngheight="20"> and rotation of <imgsrc=task2_media/0043.pngheight="20"> is applied to <imgsrc=task2_media/0044.pngheight="20">, all of the descendants are affected by this transformation as well. Then, <imgsrc=task2_media/0045.pngheight="20"> is rotated by <imgsrc=task2_media/0046.pngheight="20"> which affects itself and <imgsrc=task2_media/0047.pngheight="20">. Finally, when rotation of <imgsrc=task2_media/0048.pngheight="20"> is applied to <imgsrc=task2_media/0049.pngheight="20">, it only affects itself because it has no children.
You need to implement these routines in `student/skeleton.cpp` for forward kinematics.
...
...
@@ -102,4 +102,4 @@ A key thing for this part is to _remember what coordinate frame you're in_, beca
Once you have IK implemented, you should be able to create a series of joints, and get a particular joint to move to the desired final position you have selected.