mojira.dev

Ailo0810

Assigned

No issues.

Reported

No issues.

Comments

in my inequalities above, n = 0, 1, 2, … can be thought of as the number of times the 32-bit signed integer has been overflown. for example, the first ring occurs when it was overflown n = 1 time.

\[

2^{32} n \le \left(\frac{x}{8}\right)^2 + \left(\frac{z}{8}\right)^2 < 2^{32}\left(n + \frac12\right)

\]

$$

2^{32} n \le \left(\frac{x}{8}\right)^2 + \left(\frac{z}{8}\right)^2 < 2^{32}\left(n + \frac12\right)

$$

The issue is in the expression

MathHelper.sqrt((float)(i * i + j * j))

here, i * i + j * j can overflow the 231 - 1 limit of a 32-bit signed integer even before getting converted into float. The next 231 values become negative so sqrt returns NaN.

i and j correspond to the terrain generation coordinates, which for The End are x/8 and z/8.

A 32-bit signed integer can take 232 unique values before getting wrapped on itself, which can be interpreted as only the first half being positive.

So terrain generates only when

[media: IMG_8548.png]

where n = 0, 1, 2, …

The horizontal distance r from the origin at which terrain generates therefore satisfies

[media: IMG_8549.png]

Note that x/8 and z/8 in are evaluated as integers, so the strict inequality can be replaced with the exact upper bounds

[media: IMG_8550.png]

Interestingly, the area of the nth ring is approximately

[media: IMG_8552.png]

which does not depend on n, meaning that all the rings have equal area.