public Matrix invertRigid() {
    /*
     * this only works for rigid body transformations!
     */
    /*
     * calculate the inverse rotation by transposing the upper 3x3 submatrix.
     */
    Matrix ri = new Matrix();
    for (int c = 0; c != 3; c++)
      for (int r = 0; r != 3; r++)
        ri.set(c, r, get(r, c));
    /*
     * calculate the inverse translation
     */
    Matrix ti = new Matrix();
    ti.set(3, 0, -get(3, 0));
    ti.set(3, 1, -get(3, 1));
    ti.set(3, 2, -get(3, 2));
    return ri.mult(ti);
  }