rectangle fit transformation