GLAMERDOC++
Gravitational Lensing Code Library
Loading...
Searching...
No Matches
perlin.h
1#ifndef PERLIN_H_
2
3#define PERLIN_H_
4
5#include <stdlib.h>
6
7
8#define SAMPLE_SIZE 1024
9
10class Perlin
11{
12public:
13
14 Perlin(int octaves,float freq,float amp,int seed);
15
16
17 float Get(float x,float y)
18 {
19 float vec[2];
20 vec[0] = x;
21 vec[1] = y;
22 return perlin_noise_2D(vec);
23 };
24
25private:
26 void init_perlin(int n,float p);
27 float perlin_noise_2D(float vec[2]);
28
29 float noise1(float arg);
30 float noise2(float vec[2]);
31 float noise3(float vec[3]);
32 void normalize2(float v[2]);
33 void normalize3(float v[3]);
34 void init(void);
35
36 int mOctaves;
37 float mFrequency;
38 float mAmplitude;
39 int mSeed;
40
41 int p[SAMPLE_SIZE + SAMPLE_SIZE + 2];
42 float g3[SAMPLE_SIZE + SAMPLE_SIZE + 2][3];
43 float g2[SAMPLE_SIZE + SAMPLE_SIZE + 2][2];
44 float g1[SAMPLE_SIZE + SAMPLE_SIZE + 2];
45 bool mStart;
46
47};
48
49#endif
50