Chaste Commit::baa90ac2819b962188b7562f2326be23c47859a7
OpenSimplex2S.hpp
Go to the documentation of this file.
1
28#include <memory>
29
31{
32 struct Grad2
33 {
34 double dx {};
35 double dy {};
36 };
37
38 struct Grad3
39 {
40 double dx {};
41 double dy {};
42 double dz {};
43 };
44
45 struct Grad4
46 {
47 double dx {};
48 double dy {};
49 double dz {};
50 double dw {};
51 };
52
54 {
55 int xsv {};
56 int ysv {};
57 double dx {};
58 double dy {};
59
61 LatticePoint2D(int xsv, int ysv);
62 };
63
65 {
66 double dxr {};
67 double dyr {};
68 double dzr {};
69 int xrv {};
70 int yrv {};
71 int zrv {};
72 std::shared_ptr<LatticePoint3D> nextOnFailure {};
73 std::shared_ptr<LatticePoint3D> nextOnSuccess {};
75 LatticePoint3D(int xrv, int yrv, int zrv, int lattice);
76 };
77
79 {
80 int xsv {};
81 int ysv {};
82 int zsv {};
83 int wsv {};
84 double dx {};
85 double dy {};
86 double dz {};
87 double dw {};
88
90 LatticePoint4D(int xsv, int ysv, int zsv, int wsv);
91 };
92
93 static const int PSIZE = 2048;
94 static const int PMASK = 2047;
95
96 constexpr static const double N2 = 0.05481866495625118;
97 constexpr static const double N3 = 0.2781926117527186;
98 constexpr static const double N4 = 0.11127401889945551;
99
100 static Grad2 GRADIENTS_2D[PSIZE];
101 static Grad3 GRADIENTS_3D[PSIZE];
102 static Grad4 GRADIENTS_4D[PSIZE];
103
104 static LatticePoint2D LOOKUP_2D[8 * 4];
105 static LatticePoint3D LOOKUP_3D[8];
106 static LatticePoint4D LOOKUP_4D[256][20];
107 static unsigned char LOOKUP_4D_SIZE[256];
108
109 short perm[PSIZE];
110 Grad2 permGrad2[PSIZE];
111 Grad3 permGrad3[PSIZE];
112 Grad4 permGrad4[PSIZE];
113
118 double noise2_Base(double xs, double ys);
119
126 double noise3_BCC(double xr, double yr, double zr);
127
134 double noise4_Base(double xs, double ys, double zs, double ws);
135
136 static int fastFloor(double x);
137
138 static void initLatticePoints();
139 static void initGradients();
140
142 {
143 Initializer();
144 };
145 static Initializer initializer;
146
147public:
148 explicit OpenSimplex2S(long seed = 0);
149
153 double noise2(double x, double y);
154
160 double noise2_XBeforeY(double x, double y);
161
168 double noise3_Classic(double x, double y, double z);
169
178 double noise3_XYBeforeZ(double x, double y, double z);
179
188 double noise3_XZBeforeY(double x, double y, double z);
189
193 double noise4_Classic(double x, double y, double z, double w);
194
200 double noise4_XYBeforeZW(double x, double y, double z, double w);
201
206 double noise4_XZBeforeYW(double x, double y, double z, double w);
207
213 double noise4_XYZBeforeW(double x, double y, double z, double w);
214};
double noise3_XYBeforeZ(double x, double y, double z)
static Grad2 GRADIENTS_2D[PSIZE]
double noise2_Base(double xs, double ys)
double noise4_XZBeforeYW(double x, double y, double z, double w)
double noise3_BCC(double xr, double yr, double zr)
double noise2_XBeforeY(double x, double y)
double noise3_XZBeforeY(double x, double y, double z)
double noise3_Classic(double x, double y, double z)
double noise2(double x, double y)
double noise4_Classic(double x, double y, double z, double w)
double noise4_XYZBeforeW(double x, double y, double z, double w)
double noise4_Base(double xs, double ys, double zs, double ws)
double noise4_XYBeforeZW(double x, double y, double z, double w)