using the longer side to determine the number of sample points
(cherry picked from commit 1646f7b)