Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

/ray/src/lib/numerics/noise/perlin.h

Go to the documentation of this file.
00001 /*
00002  * lib/numerics/perlin.h
00003  * 
00004  * Perlins famous noise function. 
00005  * 
00006  * Copyright (c) 2004 by Klaus Sausen (nicolasius $ users.sourceforge.net)
00007  *                   and Wolfgang Wieser ] wwieser (a) gmx <*> de [. 
00008  * 
00009  * This file may be distributed and/or modified under the terms of the 
00010  * GNU General Public License version 2 as published by the Free Software 
00011  * Foundation. (See COPYING.GPL for details.)
00012  * 
00013  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00014  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00015  * 
00016  */
00017 
00018 #ifndef _LIB_NUMERICS_NOISE_PERLIN_H_
00019 #define _LIB_NUMERICS_NOISE_PERLIN_H_ 1
00020 
00032 #include <lib/numerics/noise/noise.h>
00033 
00034 
00035 namespace NUM  // numerics
00036 {
00037 
00048 template<typename T>class NoiseGenerator_Perlin : public NoiseGenerator_Base<T>
00049 {
00050     public:
00051         static const int B=0x100; 
00052         static const int NP=12;
00053         static const int N=1<<NP; 
00054         
00055     private:
00056         int p[B + B + 2];
00057         
00058         T g1[B + B + 2];
00059         T g2[B + B + 2][2];
00060         T g3[B + B + 2][3];
00061         
00063         void _init();
00064         
00066         NoiseGenerator_Perlin(const NoiseGenerator_Perlin &);
00068         void operator=(const NoiseGenerator_Perlin &);
00069     public:
00071         NoiseGenerator_Perlin(int seed=-1) : 
00072             NoiseGenerator_Base<T>()
00073             {  if(seed>=0)  srand(seed);  _init();  }
00074         ~NoiseGenerator_Perlin()
00075             {}
00076         
00078         T noise1(T) const;
00079         
00081         T noise2(const T *) const;
00082         
00084         T noise3(const T *) const;
00085 };
00086 
00087 }  // end of namespace NUM
00088 
00089 #endif  /* _LIB_NUMERICS_NOISE_PERLIN_H_ */
00090 

Generated on Sat Feb 19 22:33:46 2005 for Ray by doxygen 1.3.5