title: How do I get a matrix where I translate then rotate then translate then rotate a second time?
body: <p>In an Android app I want to draw a running leg. To output the top part of the leg I do something like:</p>
  
  <pre><code>// legCX,legCY is the location on screen about which the leg rotates.
  Matrix m = new Matrix();
  m.postTranslate(-legCX,-legCY);
  m.postRotate(legRot);
  m.postTranslate(legCX,legCY);
  </code></pre>
  
  <p>I then set the matrix to the canvas and draw the leg.</p>
  
  <p>How do I draw the second part of the leg below the knee? It rotates at a different rate than the leg above it and has a center point which moves with the leg above it. I tried the following, but it turns out that the end result is rotation around some single point which doesn't follow the leg above.</p>
  
  <pre><code>Matrix m = new Matrix();
  m.postTranslate(-legCX,-legCY);
  m.postRotate(legRot);
  m.postTranslate(0,-legLength);
  m.postRotate(footRot);
  m.postTranslate(0,legLength);
  m.postTranslate(legCX,legCY);
  </code></pre>
  
  <p>I suspect that it's probably necessary to do the two rotations in two different Matrix objects and then combine them somehow, but I can't figure out how exactly to do that.</p>
  
  <p>EDIT:
  This type of matrix seems to be called a "transformation matrix". Combining multiple operations is called composition of transformations. However, none of the pages on this topic mention how to do a series of translations and rotations.</p>
  
  <p>Surely, if you can use a matrix to do rotation about one point, it must be possible to do multiple matrix operations somehow to allow rotation about one point and then an additional rotation around a different point.</p>
  
  <p>I've tried looking at pages on skeletal animation, but I can't make head nor tail of what they're talking about.</p>