Code file for 2D Perlin noise functions.
More...
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "Common.h"
|
float | noise2 (float vec[2]) |
|
void | normalize2 (float v[2]) |
|
void | swap (int &x, int &y) |
|
void | initPerlin2D () |
| Initialize Perlin's permutation and gradient tables.
|
|
float | PerlinNoise2D (float x, float y, float alpha, float beta, int n) |
| Generate a cell of 2D Perlin noise.
|
|
Initialize gradient and permutation tables.
float noise2 |
( |
float |
vec[2] | ) |
|
Compute a single octave at 2D noise at a single point.
- Parameters
-
vec | Point at which to evaluate noise. |
- Returns
- Noise value between -1.0 and 1.0.
void normalize2 |
( |
float |
v[2] | ) |
|
2D vector normalize. Works by side-effect.
- Parameters
-
float PerlinNoise2D |
( |
float |
x, |
|
|
float |
y, |
|
|
float |
alpha, |
|
|
float |
beta, |
|
|
int |
n |
|
) |
| |
Compute turbulence, also known as 1/f noise.
- Parameters
-
x | X coordinate. |
y | Y coordinate. |
alpha | Persistence. |
beta | Lacunarity. |
n | Side of square grid. |
- Returns
- Scale factor required to bring it down to range [-1, 1].
void swap |
( |
int & |
x, |
|
|
int & |
y |
|
) |
| |
Swap two values.
- Parameters
-
x | First value. |
y | Second value. |