Fixed a few related math errors

There were mistakes in the Matrix.inverse() and perpendicular_to() code