Perlin noise: Difference between revisions
The Java reference implementation uses Math.floor, whereas in Python we had int(). The difference is in how it handles negative inputs: int() rounds towards 0.
Drkameleon (talk | contribs) (added Arturo implementation) |
(The Java reference implementation uses Math.floor, whereas in Python we had int(). The difference is in how it handles negative inputs: int() rounds towards 0.) |
||
Line 1,754:
{{trans|Java}}
<syntaxhighlight lang="python">
X = int(x) & 255 # FIND UNIT CUBE THAT▼
def perlin_noise(x, y, z):
Y = int(y) & 255 # CONTAINS POINT.▼
Z = math.floor(z) & 255
z -= int(z)▼
u = fade(x) # COMPUTE FADE CURVES
v = fade(y) # FOR EACH OF X,Y,Z.
|