Mmm there seems to be a problem with these transformation matrices. Instead of : 
| a b 0 |
| c d 0 |
| 0 0 1 |

it should read:
| a b o.x |
| c d o.y |
| 0 0 1   |

Otherwise you are assuming o.x=0 and o.y=0.

Algebra equations below seem correct, so it is just the documentation what is wrong.