How to find dimension of a rectangle?