Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Perlin1D Class Reference

Encapsulates a perlin noise generator in one-dimension. More...

#include <Noise.h>

List of all members.

Public Types

enum  Interpolation { LINEAR, COSINE, CUBIC }

Public Methods

 Perlin1D (double persistence=0.5, int octaves=1, Interpolation interpolation=LINEAR)
 Construct a new perline noise generator.

void setParameters (double persistence, int octaves)
 Set the noise parameters.

void setInterpolation (Interpolation interpolation)
 Set the interpolation method.

void setOffset (int idx)
 Set the offset into the noise functions.

void randomize ()
 Randomize the offset.

double _simpleRandom (int x) const
 A simple pseudo-random number regenator.

double _getSmoothedNoise (int x)
 Get a weighted sum of adjacent random numbers to smooth the distribution.

double _linearInterpolate (double a, double b, double x)
 Linear interpolation.

double _cosineInterpolate (double a, double b, double x)
 Cosine interpolation.

double _cubicInterpolate (double v0, double v1, double v2, double v3, double x)
 Cubic interpolation.

double _getInterpolatedNoise (double x)
 Returns the noise value interpolated between the smoothed noise at successive points in the distribution.

double getValue (double x)
 Get the noise vaule at a particular position.

std::vector< float > generate (int n, bool periodic, double scale=1.0, double amplitude=1.0, double offset=0.0)
 Generate a list of noise values.


Detailed Description

Encapsulates a perlin noise generator in one-dimension.

Many introductions to perlin noise and its uses are available online, via Google. Here's one such site:

http://freespace.virgin.net/hugo.elias/models/m_perlin.htm

Author:
Mark Rose <mrose@stm.lbl.gov>


Member Enumeration Documentation

enum Perlin1D::Interpolation
 

Enumeration values:
LINEAR 
COSINE 
CUBIC 


Constructor & Destructor Documentation

NAMESPACE_SIMDATA Perlin1D::Perlin1D double    persistence = 0.5,
int    octaves = 1,
Interpolation    interpolation = LINEAR
 

Construct a new perline noise generator.

Parameters:
persistence  scale factor between succesive octaves
octaves  number of octaves to generate
interpolation  the method of interpolation between noise values


Member Function Documentation

double Perlin1D::_cosineInterpolate double    a,
double    b,
double    x
[inline]
 

Cosine interpolation.

Parameters:
a  the first value
b  the second value
x  the fraction from a to b (0-1)
Returns:
the interpolated value

double Perlin1D::_cubicInterpolate double    v0,
double    v1,
double    v2,
double    v3,
double    x
[inline]
 

Cubic interpolation.

Parameters:
v0  value(i-1)
v1  value(i)
v2  value(i+1)
v3  value(i+2)
x  the fraction from v1 to v2 (0-1)
Returns:
the interpolated value

double Perlin1D::_getInterpolatedNoise double    x
 

Returns the noise value interpolated between the smoothed noise at successive points in the distribution.

Parameters:
x  the point in the distribution
Returns:
the smoothed, interpolated noise value

double Perlin1D::_getSmoothedNoise int    x [inline]
 

Get a weighted sum of adjacent random numbers to smooth the distribution.

Parameters:
x  the central point for the weighted sum
Returns:
the weighted sum

double Perlin1D::_linearInterpolate double    a,
double    b,
double    x
[inline]
 

Linear interpolation.

Parameters:
a  the first value
b  the second value
x  the fraction from a to b (0-1)
Returns:
the interpolated value

double Perlin1D::_simpleRandom int    x const [inline]
 

A simple pseudo-random number regenator.

Parameters:
x  the random seed.
Returns:
a pseudo-random number in the range 0-1.

std::vector< float > Perlin1D::generate int    n,
bool    periodic,
double    scale = 1.0,
double    amplitude = 1.0,
double    offset = 0.0
 

Generate a list of noise values.

This is a convenience method to pregenerate a discrete perlin noise field. Both perioidic and aperiodic fields can be created (the former have the same value at the start and at the end). The noise field can be scaled in X and Y (e.g. time and amplitude), as well as offset so that the mean value is non-zero.

Parameters:
n  the number of noise values
periodic  if true, the lists ends are blended to make them continuous
scale  the scaling factor from the list index to the noise function
amplitude  the noise amplitude
offset  the noise offset

double Perlin1D::getValue double    x
 

Get the noise vaule at a particular position.

Parameters:
x  the point in the distribution
Returns:
the noise value

void Perlin1D::randomize  
 

Randomize the offset.

Subsequent noise will generally be uncorrelated to previously generated noise. Be aware that the random offset is in the range 10^9, so for large noise sets this property will break down.

void Perlin1D::setInterpolation Interpolation    interpolation
 

Set the interpolation method.

Parameters:
interpolation  the method of interpolation between noise values

void Perlin1D::setOffset int    idx
 

Set the offset into the noise functions.

The offset can be used to reproducibly generate a given noise distribution, or to create independent finite noise distributions from the same generator.

void Perlin1D::setParameters double    persistence,
int    octaves
 

Set the noise parameters.

Parameters:
persistence  scale factor between succesive octaves
octaves  number of octaves to generate


The documentation for this class was generated from the following files:
SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage.

Generated on Tue Oct 14 12:06:42 2003, using Doxygen 1.2.18.

[SF.net]