pyvista.perlin_noise#

perlin_noise(amplitude, freq: Sequence[float], phase: Sequence[float])[source]#

Return the implicit function that implements Perlin noise.

Uses vtk.vtkPerlinNoise and computes a Perlin noise field as an implicit function. vtk.vtkPerlinNoise is a concrete implementation of vtk.vtkImplicitFunction. Perlin noise, originally described by Ken Perlin, is a non-periodic and continuous noise function useful for modeling real-world objects.

The amplitude and frequency of the noise pattern are adjustable. This implementation of Perlin noise is derived closely from Greg Ward’s version in Graphics Gems II.

Parameters:
amplitudefloat

Amplitude of the noise function.

amplitude can be negative. The noise function varies randomly between -|Amplitude| and |Amplitude|. Therefore the range of values is 2*|Amplitude| large. The initial amplitude is 1.

freqsequence[float]

The frequency, or physical scale, of the noise function (higher is finer scale).

The frequency can be adjusted per axis, or the same for all axes.

phasesequence[float]

Set/get the phase of the noise function.

This parameter can be used to shift the noise function within space (perhaps to avoid a beat with a noise pattern at another scale). Phase tends to repeat about every unit, so a phase of 0.5 is a half-cycle shift.

Returns:
vtk.vtkPerlinNoise

Instance of vtk.vtkPerlinNoise to a Perlin noise field as an implicit function. Use with pyvista.sample_function().

Examples

Create a Perlin noise function with an amplitude of 0.1, frequency for all axes of 1, and a phase of 0 for all axes.

>>> import pyvista as pv
>>> noise = pv.perlin_noise(0.1, (1, 1, 1), (0, 0, 0))

Sample Perlin noise over a structured grid and plot it.

>>> grid = pv.sample_function(noise, [0, 5, 0, 5, 0, 5])
>>> grid.plot()
../../../_images/pyvista-perlin_noise-1_00_00.png