Noise#

class augraphy.utilities.meshgenerator.Noise[source]#

Bases: object

Generates 2D Perlin Noise, a type of gradient noise used to create natural looking textures, animations, and procedural meshes. This code generates smooth, continuous Perlin Noise Values that can be used for variety of applications in computer graphics and simulations.

fade(t)[source]#

Returns a smooth interpolation curve between 0 and 1 :param t: Distance vector coordinate :type t: float

getConstantVector(v)[source]#

Used to generate the gradient in Perlin Noise Algorithm. The vector points in four of the cardinal directions. Returns one the four pre-defined ‘Vector2’ objects based on the last two bits of the input integer ‘v’. :param v: Input integer from the permutation table :type v: int

lerp(t, a1, a2)[source]#

Based on the Linear Interpolation Function that returns a value linearly interpolated between a1 and a2 based on the input parameter ‘t’. It is a smoothening functions. :param t: Distance vector coordinate :type t: float :param a1: Dot product result from Gradient Vector and Distance Vector :type a1: float :param a2: Dot product result from Gradient Vector and Distaince Vector :type a2: float

makePermutation()[source]#

Generates a permutation table, a randomly shuffled array of integers from 0 to 255.

noise2D(x, y)[source]#

Generates a noise mesh based on x and y coordinates given as an input. It performs the following steps: 1. Calculates the integer grid coordinates of the bottom-left corner of the cell containing the input point, as well as the fractional offesets from that corner to the input point. 2. Computes the dot product between the gradient vectors at each of the cell’s four corners and the vectors pointing from those corners to the input point. 3. Applies the fade and lerp function to interpolate(smoothening function) between these dot products and computes the final noise value at the input point.

shuffle(arrayToShuffle)[source]#

Randomly shuffles array of integers from 0 to 255 :param: arrayToShuffle :type: A list of integers

Overview#

Noise is the base class to generate Perlin Noise. It is a type of gradient noise used to create natural looking textures. Very useful to create smooth and organic looking documents.