(x, y, z)
| 65 | return (1 - t) * a + t * b |
| 66 | |
| 67 | def perlin3(x, y, z): |
| 68 | # grid cells |
| 69 | x_c = int(x) |
| 70 | y_c = int(y) |
| 71 | z_c = int(z) |
| 72 | # relative coords within the cell |
| 73 | x -= x_c |
| 74 | y -= y_c |
| 75 | z -= z_c |
| 76 | # wrap cells |
| 77 | x_c &= 255 |
| 78 | y_c &= 255 |
| 79 | z_c &= 255 |
| 80 | # noise contributions to corners |
| 81 | n000 = V3_P[x_c + PERM[y_c + PERM[z_c]]].dot3(x, y, z) |
| 82 | n001 = V3_P[x_c + PERM[y_c + PERM[z_c + 1]]].dot3(x, y, z - 1) |
| 83 | n010 = V3_P[x_c + PERM[y_c + 1 + PERM[z_c]]].dot3(x, y - 1, z) |
| 84 | n011 = V3_P[x_c + PERM[y_c + 1 + PERM[z_c + 1]]].dot3(x, y - 1, z - 1) |
| 85 | n100 = V3_P[x_c + 1 + PERM[y_c + PERM[z_c]]].dot3(x - 1, y, z) |
| 86 | n101 = V3_P[x_c + 1 + PERM[y_c + PERM[z_c + 1]]].dot3(x - 1, y, z - 1) |
| 87 | n110 = V3_P[x_c + 1 + PERM[y_c + 1 + PERM[z_c]]].dot3(x - 1, y - 1, z) |
| 88 | n111 = V3_P[x_c + 1 + PERM[y_c + 1 + PERM[z_c + 1]]].dot3(x - 1, y - 1, z - 1) |
| 89 | # fade curve |
| 90 | u = fade(x) |
| 91 | v = fade(y) |
| 92 | w = fade(z) |
| 93 | # interpolation |
| 94 | return lerp( |
| 95 | lerp(lerp(n000, n100, u), lerp(n001, n101, u), w), |
| 96 | lerp(lerp(n010, n110, u), lerp(n011, n111, u), w), |
| 97 | v, |
| 98 | ) |
| 99 | |
| 100 | def curl2(x, y, z): |
| 101 | # https://www.bit-101.com/2017/2021/07/curl-noise/ |
no test coverage detected