Move coordinate scaling for offset from Perl to XS for better performance