Fixes #791.

As per the description in #791, `d == distance_normalization` in some cases, which produces a bad access in the octants/quadrants vector.

By using the floor function (minus one), we guarantee that the result will fall between 0 and 12 inclusive, but never reach 13. The subtraction by an integer makes the `static_cast` unnecessary.