hotfix: xmin and xmax are double, not integer; added explicit conversion from double to int so that no compilation warning appears