15 #include "perlinNoise3.h" 33 double xf = cfloor(x);
34 double yf = cfloor(y);
35 double zf = cfloor(z);
37 int X = ((int)xf) & _table_size_mask;
38 int Y = ((int)yf) & _table_size_mask;
39 int Z = ((int)zf) & _table_size_mask;
53 int A = _index[X] + Y;
54 int AA = _index[A] + Z;
55 int AB = _index[A + 1] + Z;
56 int B = _index[X + 1] + Y;
57 int BA = _index[B] + Z;
58 int BB = _index[B + 1] + Z;
62 lerp(w, lerp(v, lerp(u, grad(_index[AA], x, y, z),
63 grad(_index[BA], x - 1, y, z)),
64 lerp(u, grad(_index[AB], x, y - 1, z),
65 grad(_index[BB], x - 1, y - 1, z))),
66 lerp(v, lerp(u, grad(_index[AA + 1], x, y, z - 1),
67 grad(_index[BA + 1], x - 1, y, z - 1)),
68 lerp(u, grad(_index[AB + 1], x, y - 1, z - 1),
69 grad(_index[BB + 1], x - 1, y - 1, z - 1))));
83 init_unscaled_xform() {
85 _randomizer.random_real_unit(),
86 _randomizer.random_real_unit(),
87 _randomizer.random_real_unit());
89 rot.extract_to_matrix(_unscaled_xform);
94 _randomizer.random_real_unit(),
95 _randomizer.random_real_unit()));
void set_row(int row, const LVecBase4d &v)
Replaces the indicated row of the matrix.
LVecBase3d xform_point(const LVecBase3d &v) const
The matrix transforms a 3-component point (including translation component) and returns the result...
This is the base class for all three-component vectors and points.
This is a unit quaternion representing a rotation.
double noise(double x, double y, double z) const
Returns the noise function of the three inputs.