propane 3.9.0-java → 3.10.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG.md +2 -2
  4. data/README.md +3 -3
  5. data/Rakefile +6 -6
  6. data/lib/java/japplemenubar/JAppleMenuBar.java +88 -0
  7. data/lib/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  8. data/lib/java/monkstone/ColorUtil.java +127 -0
  9. data/lib/java/monkstone/MathToolModule.java +287 -0
  10. data/lib/java/monkstone/PropaneLibrary.java +46 -0
  11. data/lib/java/monkstone/core/LibraryProxy.java +136 -0
  12. data/lib/java/monkstone/fastmath/DegLutTables.java +111 -0
  13. data/lib/java/monkstone/fastmath/Deglut.java +71 -0
  14. data/lib/java/monkstone/fastmath/package-info.java +6 -0
  15. data/lib/java/monkstone/filechooser/Chooser.java +39 -0
  16. data/{src/main → lib}/java/monkstone/noise/FastTerrain.java +0 -0
  17. data/{src/main → lib}/java/monkstone/noise/Noise.java +0 -0
  18. data/{src/main → lib}/java/monkstone/noise/NoiseGenerator.java +0 -0
  19. data/{src/main → lib}/java/monkstone/noise/NoiseMode.java +0 -0
  20. data/lib/java/monkstone/noise/OpenSimplex2F.java +881 -0
  21. data/lib/java/monkstone/noise/OpenSimplex2S.java +1106 -0
  22. data/{src/main → lib}/java/monkstone/noise/SmoothTerrain.java +0 -0
  23. data/lib/java/monkstone/slider/CustomHorizontalSlider.java +164 -0
  24. data/lib/java/monkstone/slider/CustomVerticalSlider.java +178 -0
  25. data/lib/java/monkstone/slider/SimpleHorizontalSlider.java +145 -0
  26. data/lib/java/monkstone/slider/SimpleSlider.java +166 -0
  27. data/lib/java/monkstone/slider/SimpleVerticalSlider.java +157 -0
  28. data/lib/java/monkstone/slider/Slider.java +61 -0
  29. data/lib/java/monkstone/slider/SliderBar.java +245 -0
  30. data/lib/java/monkstone/slider/SliderGroup.java +56 -0
  31. data/lib/java/monkstone/slider/WheelHandler.java +35 -0
  32. data/lib/java/monkstone/vecmath/GfxRender.java +86 -0
  33. data/lib/java/monkstone/vecmath/JRender.java +56 -0
  34. data/lib/java/monkstone/vecmath/ShapeRender.java +87 -0
  35. data/lib/java/monkstone/vecmath/package-info.java +20 -0
  36. data/lib/java/monkstone/vecmath/vec2/Vec2.java +802 -0
  37. data/lib/java/monkstone/vecmath/vec2/package-info.java +6 -0
  38. data/lib/java/monkstone/vecmath/vec3/Vec3.java +727 -0
  39. data/lib/java/monkstone/vecmath/vec3/package-info.java +6 -0
  40. data/lib/java/monkstone/videoevent/CaptureEvent.java +27 -0
  41. data/lib/java/monkstone/videoevent/MovieEvent.java +32 -0
  42. data/lib/java/monkstone/videoevent/package-info.java +20 -0
  43. data/lib/java/processing/awt/PGraphicsJava2D.java +3040 -0
  44. data/lib/java/processing/awt/PImageAWT.java +377 -0
  45. data/lib/java/processing/awt/PShapeJava2D.java +387 -0
  46. data/lib/java/processing/awt/PSurfaceAWT.java +1581 -0
  47. data/lib/java/processing/awt/ShimAWT.java +581 -0
  48. data/lib/java/processing/core/PApplet.java +15156 -0
  49. data/lib/java/processing/core/PConstants.java +523 -0
  50. data/lib/java/processing/core/PFont.java +1126 -0
  51. data/lib/java/processing/core/PGraphics.java +8600 -0
  52. data/lib/java/processing/core/PImage.java +3377 -0
  53. data/lib/java/processing/core/PMatrix.java +208 -0
  54. data/lib/java/processing/core/PMatrix2D.java +562 -0
  55. data/lib/java/processing/core/PMatrix3D.java +890 -0
  56. data/lib/java/processing/core/PShape.java +3561 -0
  57. data/lib/java/processing/core/PShapeOBJ.java +483 -0
  58. data/lib/java/processing/core/PShapeSVG.java +2016 -0
  59. data/lib/java/processing/core/PStyle.java +63 -0
  60. data/lib/java/processing/core/PSurface.java +198 -0
  61. data/lib/java/processing/core/PSurfaceNone.java +431 -0
  62. data/lib/java/processing/core/PVector.java +1066 -0
  63. data/lib/java/processing/core/ThinkDifferent.java +115 -0
  64. data/lib/java/processing/data/DoubleDict.java +850 -0
  65. data/lib/java/processing/data/DoubleList.java +928 -0
  66. data/lib/java/processing/data/FloatDict.java +847 -0
  67. data/lib/java/processing/data/FloatList.java +936 -0
  68. data/lib/java/processing/data/IntDict.java +807 -0
  69. data/lib/java/processing/data/IntList.java +936 -0
  70. data/lib/java/processing/data/JSONArray.java +1260 -0
  71. data/lib/java/processing/data/JSONObject.java +2282 -0
  72. data/lib/java/processing/data/JSONTokener.java +435 -0
  73. data/lib/java/processing/data/LongDict.java +802 -0
  74. data/lib/java/processing/data/LongList.java +937 -0
  75. data/lib/java/processing/data/Sort.java +46 -0
  76. data/lib/java/processing/data/StringDict.java +613 -0
  77. data/lib/java/processing/data/StringList.java +800 -0
  78. data/lib/java/processing/data/Table.java +4936 -0
  79. data/lib/java/processing/data/TableRow.java +198 -0
  80. data/lib/java/processing/data/XML.java +1156 -0
  81. data/lib/java/processing/dxf/RawDXF.java +404 -0
  82. data/lib/java/processing/event/Event.java +125 -0
  83. data/lib/java/processing/event/KeyEvent.java +70 -0
  84. data/lib/java/processing/event/MouseEvent.java +114 -0
  85. data/lib/java/processing/event/TouchEvent.java +57 -0
  86. data/lib/java/processing/javafx/PGraphicsFX2D.java +32 -0
  87. data/lib/java/processing/javafx/PSurfaceFX.java +173 -0
  88. data/lib/java/processing/net/Client.java +744 -0
  89. data/lib/java/processing/net/Server.java +388 -0
  90. data/lib/java/processing/opengl/FontTexture.java +378 -0
  91. data/lib/java/processing/opengl/FrameBuffer.java +513 -0
  92. data/lib/java/processing/opengl/LinePath.java +627 -0
  93. data/lib/java/processing/opengl/LineStroker.java +681 -0
  94. data/lib/java/processing/opengl/PGL.java +3483 -0
  95. data/lib/java/processing/opengl/PGraphics2D.java +615 -0
  96. data/lib/java/processing/opengl/PGraphics3D.java +281 -0
  97. data/lib/java/processing/opengl/PGraphicsOpenGL.java +13753 -0
  98. data/lib/java/processing/opengl/PJOGL.java +2008 -0
  99. data/lib/java/processing/opengl/PShader.java +1484 -0
  100. data/lib/java/processing/opengl/PShapeOpenGL.java +5269 -0
  101. data/lib/java/processing/opengl/PSurfaceJOGL.java +1385 -0
  102. data/lib/java/processing/opengl/Texture.java +1696 -0
  103. data/lib/java/processing/opengl/VertexBuffer.java +88 -0
  104. data/lib/java/processing/opengl/cursors/arrow.png +0 -0
  105. data/lib/java/processing/opengl/cursors/cross.png +0 -0
  106. data/lib/java/processing/opengl/cursors/hand.png +0 -0
  107. data/lib/java/processing/opengl/cursors/license.txt +27 -0
  108. data/lib/java/processing/opengl/cursors/move.png +0 -0
  109. data/lib/java/processing/opengl/cursors/text.png +0 -0
  110. data/lib/java/processing/opengl/cursors/wait.png +0 -0
  111. data/lib/java/processing/opengl/shaders/ColorFrag.glsl +32 -0
  112. data/lib/java/processing/opengl/shaders/ColorVert.glsl +34 -0
  113. data/lib/java/processing/opengl/shaders/LightFrag.glsl +33 -0
  114. data/lib/java/processing/opengl/shaders/LightVert.glsl +151 -0
  115. data/lib/java/processing/opengl/shaders/LineFrag.glsl +32 -0
  116. data/lib/java/processing/opengl/shaders/LineVert.glsl +100 -0
  117. data/lib/java/processing/opengl/shaders/MaskFrag.glsl +40 -0
  118. data/lib/java/processing/opengl/shaders/PointFrag.glsl +32 -0
  119. data/lib/java/processing/opengl/shaders/PointVert.glsl +56 -0
  120. data/lib/java/processing/opengl/shaders/TexFrag.glsl +37 -0
  121. data/lib/java/processing/opengl/shaders/TexLightFrag.glsl +37 -0
  122. data/lib/java/processing/opengl/shaders/TexLightVert.glsl +157 -0
  123. data/lib/java/processing/opengl/shaders/TexVert.glsl +38 -0
  124. data/lib/java/processing/pdf/PGraphicsPDF.java +581 -0
  125. data/lib/java/processing/svg/PGraphicsSVG.java +378 -0
  126. data/lib/propane/app.rb +8 -13
  127. data/lib/propane/version.rb +1 -1
  128. data/mvnw +3 -3
  129. data/mvnw.cmd +2 -2
  130. data/pom.rb +7 -2
  131. data/pom.xml +14 -2
  132. data/propane.gemspec +2 -2
  133. data/src/main/java/monkstone/FastNoiseModuleJava.java +127 -0
  134. data/src/main/java/monkstone/MathToolModule.java +30 -30
  135. data/src/main/java/monkstone/PropaneLibrary.java +2 -0
  136. data/src/main/java/monkstone/SmoothNoiseModuleJava.java +127 -0
  137. data/src/main/java/monkstone/fastmath/DegLutTables.java +15 -15
  138. data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
  139. data/src/main/java/monkstone/noise/OpenSimplex2F.java +752 -820
  140. data/src/main/java/monkstone/noise/OpenSimplex2S.java +1138 -1106
  141. data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
  142. data/src/main/java/monkstone/vecmath/JRender.java +6 -6
  143. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +20 -19
  144. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +12 -12
  145. data/src/main/java/processing/awt/PGraphicsJava2D.java +11 -3
  146. data/src/main/java/processing/core/PApplet.java +89 -89
  147. data/src/main/java/processing/core/PConstants.java +155 -163
  148. data/src/main/java/processing/opengl/PJOGL.java +6 -5
  149. data/vendors/Rakefile +1 -1
  150. metadata +136 -19
@@ -24,43 +24,43 @@ public final class DegLutTables {
24
24
  /**
25
25
  *
26
26
  */
27
- static public final float PI = 3.1415927f;
27
+ static public float PI = 3.1415927f;
28
28
 
29
29
  /**
30
30
  *
31
31
  */
32
- static public final float PI2 = PI * 2;
32
+ public static final float PI2 = PI * 2;
33
33
  static private final int SIN_BITS = 15; // 16KB. Adjust for accuracy.
34
34
  static private final int SIN_MASK = ~(-1 << SIN_BITS);
35
35
  static private final int SIN_COUNT = SIN_MASK + 1;
36
36
 
37
- static private final float RAD_FULL = PI * 2;
38
- static private final float DEG_FULL = 360;
39
- static private final float RAD_TO_INDEX = SIN_COUNT / RAD_FULL;
40
- static private final float DEG_TO_INDEX = SIN_COUNT / DEG_FULL;
37
+ private static final float RAD_FULL = PI * 2;
38
+ private static final float DEG_FULL = 360;
39
+ private static final float RAD_TO_INDEX = SIN_COUNT / RAD_FULL;
40
+ private static final float DEG_TO_INDEX = SIN_COUNT / DEG_FULL;
41
41
 
42
42
  /**
43
43
  * multiply by this to convert from radians to degrees
44
44
  */
45
- static public final float RADIANS_TO_DEGREES = 180f / PI;
45
+ public static final float RADIANS_TO_DEGREES = 180f / PI;
46
46
 
47
47
  /**
48
48
  *
49
49
  */
50
- static public final float RAD_DEG = RADIANS_TO_DEGREES;
50
+ public static final float RAD_DEG = RADIANS_TO_DEGREES;
51
51
  /**
52
52
  * multiply by this to convert from degrees to radians
53
53
  */
54
- static public final float DEGREES_TO_RADIANS = PI / 180;
54
+ public static final float DEGREES_TO_RADIANS = PI / 180;
55
55
 
56
56
  /**
57
57
  *
58
58
  */
59
- static public final float DEG_RAD = DEGREES_TO_RADIANS;
59
+ public static final float DEG_RAD = DEGREES_TO_RADIANS;
60
60
 
61
61
  static private class Sin {
62
62
 
63
- static final float[] table = new float[SIN_COUNT];
63
+ static float[] table = new float[SIN_COUNT];
64
64
 
65
65
  static {
66
66
  for (int i = 0; i < SIN_COUNT; i++) {
@@ -77,7 +77,7 @@ public final class DegLutTables {
77
77
  * @param radians
78
78
  * @return
79
79
  */
80
- static public final float sin(float radians) {
80
+ static public float sin(float radians) {
81
81
  return Sin.table[(int) (radians * RAD_TO_INDEX) & SIN_MASK];
82
82
  }
83
83
 
@@ -86,7 +86,7 @@ public final class DegLutTables {
86
86
  * @param radians
87
87
  * @return
88
88
  */
89
- static public final float cos(float radians) {
89
+ static public float cos(float radians) {
90
90
  return Sin.table[(int) ((radians + PI / 2) * RAD_TO_INDEX) & SIN_MASK];
91
91
  }
92
92
 
@@ -95,7 +95,7 @@ public final class DegLutTables {
95
95
  * @param degrees
96
96
  * @return
97
97
  */
98
- static public final float sinDeg(float degrees) {
98
+ static public float sinDeg(float degrees) {
99
99
  return Sin.table[(int) (degrees * DEG_TO_INDEX) & SIN_MASK];
100
100
  }
101
101
 
@@ -104,7 +104,7 @@ public final class DegLutTables {
104
104
  * @param degrees
105
105
  * @return
106
106
  */
107
- static public final float cosDeg(float degrees) {
107
+ static public float cosDeg(float degrees) {
108
108
  return Sin.table[(int) ((degrees + 90) * DEG_TO_INDEX) & SIN_MASK];
109
109
  }
110
110
  }
@@ -35,5 +35,5 @@ import java.io.File;
35
35
  @FunctionalInterface
36
36
  public interface Chooser {
37
37
 
38
- public void file_selected(File selection);
38
+ void file_selected(File selection);
39
39
  }
@@ -1,881 +1,813 @@
1
1
  package monkstone.noise;
2
-
3
2
  /**
4
3
  * K.jpg's OpenSimplex 2, faster variant
5
4
  *
6
- * - 2D is standard simplex implemented using a lookup table. - 3D is
7
- * "Re-oriented 4-point BCC noise" which constructs a congruent BCC lattice in a
8
- * much different way than usual. - 4D constructs the lattice as a union of five
9
- * copies of its reciprocal. It successively finds the closest point on each.
5
+ * - 2D is standard simplex implemented using a lookup table.
6
+ * - 3D is "Re-oriented 4-point BCC noise" which constructs a
7
+ * congruent BCC lattice in a much different way than usual.
8
+ * - 4D constructs the lattice as a union of five copies of its
9
+ * reciprocal. It successively finds the closest point on each.
10
10
  *
11
- * Multiple versions of each function are provided. See the documentation above
12
- * each, for more info.
11
+ * Multiple versions of each function are provided. See the
12
+ * documentation above each, for more info.
13
13
  */
14
- public class OpenSimplex2F implements Noise {
14
+ public class OpenSimplex2F {
15
15
 
16
- private static final int PSIZE = 2048;
17
- private static final int PMASK = 2047;
16
+ private static final int PSIZE = 2048;
17
+ private static final int PMASK = 2047;
18
18
 
19
- private final short[] perm;
20
- private final Grad2[] permGrad2;
21
- private final Grad3[] permGrad3;
22
- private final Grad4[] permGrad4;
19
+ private final short[] perm;
20
+ private final Grad2[] permGrad2;
21
+ private final Grad3[] permGrad3;
22
+ private final Grad4[] permGrad4;
23
23
 
24
- public OpenSimplex2F(long seed) {
25
- perm = new short[PSIZE];
26
- permGrad2 = new Grad2[PSIZE];
27
- permGrad3 = new Grad3[PSIZE];
28
- permGrad4 = new Grad4[PSIZE];
29
- short[] source = new short[PSIZE];
30
- for (short i = 0; i < PSIZE; i++) {
31
- source[i] = i;
32
- }
33
- for (int i = PSIZE - 1; i >= 0; i--) {
34
- seed = seed * 6364136223846793005L + 1442695040888963407L;
35
- int r = (int) ((seed + 31) % (i + 1));
36
- if (r < 0) {
37
- r += (i + 1);
38
- }
39
- perm[i] = source[r];
40
- permGrad2[i] = GRADIENTS_2D[perm[i]];
41
- permGrad3[i] = GRADIENTS_3D[perm[i]];
42
- permGrad4[i] = GRADIENTS_4D[perm[i]];
43
- source[r] = source[i];
44
- }
45
- }
46
-
47
- /*
48
- * Noise Evaluators
49
- */
50
24
  /**
51
- * 2D Simplex noise, standard lattice orientation.
52
25
  *
26
+ * @param seed
27
+ */
28
+ public OpenSimplex2F(long seed) {
29
+ perm = new short[PSIZE];
30
+ permGrad2 = new Grad2[PSIZE];
31
+ permGrad3 = new Grad3[PSIZE];
32
+ permGrad4 = new Grad4[PSIZE];
33
+ short[] source = new short[PSIZE];
34
+ for (short i = 0; i < PSIZE; i++)
35
+ source[i] = i;
36
+ for (int i = PSIZE - 1; i >= 0; i--) {
37
+ seed = seed * 6364136223846793005L + 1442695040888963407L;
38
+ int r = (int)((seed + 31) % (i + 1));
39
+ if (r < 0)
40
+ r += i + 1;
41
+ perm[i] = source[r];
42
+ permGrad2[i] = GRADIENTS_2D[perm[i]];
43
+ permGrad3[i] = GRADIENTS_3D[perm[i]];
44
+ permGrad4[i] = GRADIENTS_4D[perm[i]];
45
+ source[r] = source[i];
46
+ }
47
+ }
48
+
49
+ /*
50
+ * Noise Evaluators
51
+ */
52
+
53
+ /**
54
+ * 2D Simplex noise, standard lattice orientation.
53
55
  * @param x
54
56
  * @param y
55
- * @return
56
- */
57
- public double noise2(double x, double y) {
57
+ * @return
58
+ */
59
+ public double noise2(double x, double y) {
58
60
 
59
- // Get points for A2* lattice
60
- double s = 0.366025403784439 * (x + y);
61
- double xs = x + s, ys = y + s;
61
+ // Get points for A2* lattice
62
+ double s = 0.366025403784439 * (x + y);
63
+ double xs = x + s, ys = y + s;
62
64
 
63
- return noise2_Base(xs, ys);
64
- }
65
+ return noise2_Base(xs, ys);
66
+ }
65
67
 
66
- /**
67
- * 2D Simplex noise, with Y pointing down the main diagonal.Might be better
68
- * for a 2D sandbox style game, where Y is vertical.Probably slightly less
69
- * optimal for heightmaps or continent maps.
70
- *
68
+ /**
69
+ * 2D Simplex noise, with Y pointing down the main diagonal.Might be better for a 2D sandbox style game, where Y is vertical.Probably slightly less optimal for heightmaps or continent maps.
71
70
  * @param x
72
71
  * @param y
73
- * @return
74
- */
75
- public double noise2_XBeforeY(double x, double y) {
72
+ * @return
73
+ */
74
+ public double noise2_XBeforeY(double x, double y) {
76
75
 
77
- // Skew transform and rotation baked into one.
78
- double xx = x * 0.7071067811865476;
79
- double yy = y * 1.224744871380249;
76
+ // Skew transform and rotation baked into one.
77
+ double xx = x * 0.7071067811865476;
78
+ double yy = y * 1.224744871380249;
80
79
 
81
- return noise2_Base(yy + xx, yy - xx);
82
- }
80
+ return noise2_Base(yy + xx, yy - xx);
81
+ }
83
82
 
84
- /**
85
- * 2D Simplex noise base. Lookup table implementation inspired by
86
- * DigitalShadow.
87
- */
88
- private double noise2_Base(double xs, double ys) {
89
- double value = 0;
83
+ /**
84
+ * 2D Simplex noise base.
85
+ * Lookup table implementation inspired by DigitalShadow.
86
+ */
87
+ private double noise2_Base(double xs, double ys) {
88
+ double value = 0;
90
89
 
91
- // Get base points and offsets
92
- int xsb = fastFloor(xs), ysb = fastFloor(ys);
93
- double xsi = xs - xsb, ysi = ys - ysb;
90
+ // Get base points and offsets
91
+ int xsb = fastFloor(xs), ysb = fastFloor(ys);
92
+ double xsi = xs - xsb, ysi = ys - ysb;
94
93
 
95
- // Index to point list
96
- int index = (int) ((ysi - xsi) / 2 + 1);
94
+ // Index to point list
95
+ int index = (int)((ysi - xsi) / 2 + 1);
97
96
 
98
- double ssi = (xsi + ysi) * -0.211324865405187;
99
- double xi = xsi + ssi, yi = ysi + ssi;
97
+ double ssi = (xsi + ysi) * -0.211324865405187;
98
+ double xi = xsi + ssi, yi = ysi + ssi;
100
99
 
101
- // Point contributions
102
- for (int i = 0; i < 3; i++) {
103
- LatticePoint2D c = LOOKUP_2D[index + i];
100
+ // Point contributions
101
+ for (int i = 0; i < 3; i++) {
102
+ LatticePoint2D c = LOOKUP_2D[index + i];
104
103
 
105
- double dx = xi + c.dx, dy = yi + c.dy;
106
- double attn = 0.5 - dx * dx - dy * dy;
107
- if (attn <= 0) {
108
- continue;
109
- }
104
+ double dx = xi + c.dx, dy = yi + c.dy;
105
+ double attn = 0.5 - dx * dx - dy * dy;
106
+ if (attn <= 0) continue;
110
107
 
111
- int pxm = (xsb + c.xsv) & PMASK, pym = (ysb + c.ysv) & PMASK;
112
- Grad2 grad = permGrad2[perm[pxm] ^ pym];
113
- double extrapolation = grad.dx * dx + grad.dy * dy;
108
+ int pxm = (xsb + c.xsv) & PMASK, pym = (ysb + c.ysv) & PMASK;
109
+ Grad2 grad = permGrad2[perm[pxm] ^ pym];
110
+ double extrapolation = grad.dx * dx + grad.dy * dy;
114
111
 
115
- attn *= attn;
116
- value += attn * attn * extrapolation;
117
- }
112
+ attn *= attn;
113
+ value += attn * attn * extrapolation;
114
+ }
118
115
 
119
- return value;
120
- }
116
+ return value;
117
+ }
121
118
 
122
- /**
123
- * 3D Re-oriented 4-point BCC noise, classic orientation.Proper substitute
124
- * for 3D Simplex in light of Forbidden Formulae.Use noise3_XYBeforeZ or
125
- * noise3_XZBeforeY instead, wherever appropriate.
126
- *
119
+ /**
120
+ * 3D Re-oriented 4-point BCC noise, classic orientation.Proper substitute for 3D Simplex in light of Forbidden Formulae.Use noise3_XYBeforeZ or noise3_XZBeforeY instead, wherever appropriate.
127
121
  * @param x
128
122
  * @param y
129
123
  * @param z
130
- * @return
131
- */
132
- public double noise3_Classic(double x, double y, double z) {
133
-
134
- // Re-orient the cubic lattices via rotation, to produce the expected look on cardinal planar slices.
135
- // If texturing objects that don't tend to have cardinal plane faces, you could even remove this.
136
- // Orthonormal rotation. Not a skew transform.
137
- double r = (2.0 / 3.0) * (x + y + z);
138
- double xr = r - x, yr = r - y, zr = r - z;
139
-
140
- // Evaluate both lattices to form a BCC lattice.
141
- return noise3_BCC(xr, yr, zr);
142
- }
143
-
144
- /**
145
- * 3D Re-oriented 4-point BCC noise, with better visual isotropy in (X,
146
- * Z).Recommended for 3D terrain and time-varied animations.The Y coordinate
147
- * should always be the "different" coordinate in your use case.If Y is
148
- * vertical in world coordinates, call noise3_XZBeforeY(x, Y, z).If Z is
149
- * vertical in world coordinates, call noise3_XZBeforeY(x, Z, y) or use
150
- * noise3_XYBeforeZ. For a time varied animation, call noise3_XZBeforeY(x,
151
- * T, y) or use noise3_XYBeforeZ.
152
- *
124
+ * @return
125
+ */
126
+ public double noise3_Classic(double x, double y, double z) {
127
+
128
+ // Re-orient the cubic lattices via rotation, to produce the expected look on cardinal planar slices.
129
+ // If texturing objects that don't tend to have cardinal plane faces, you could even remove this.
130
+ // Orthonormal rotation. Not a skew transform.
131
+ double r = (2.0 / 3.0) * (x + y + z);
132
+ double xr = r - x, yr = r - y, zr = r - z;
133
+
134
+ // Evaluate both lattices to form a BCC lattice.
135
+ return noise3_BCC(xr, yr, zr);
136
+ }
137
+
138
+ /**
139
+ * 3D Re-oriented 4-point BCC noise, with better visual isotropy in (X, Y).Recommended for 3D terrain and time-varied animations.The Z coordinate should always be the "different" coordinate in your use case.If Y is vertical in world coordinates, call noise3_XYBeforeZ(x, z, Y) or use noise3_XZBeforeY.If Z is vertical in world coordinates, call noise3_XYBeforeZ(x, y, Z).
140
+ * For a time varied animation, call noise3_XYBeforeZ(x, y, T).
153
141
  * @param x
154
142
  * @param y
155
143
  * @param z
156
- * @return
157
- */
158
- public double noise3_XZBeforeY(double x, double y, double z) {
159
-
160
- // Re-orient the cubic lattices without skewing, to make X and Z triangular like 2D.
161
- // Orthonormal rotation. Not a skew transform.
162
- double xz = x + z;
163
- double s2 = xz * -0.211324865405187;
164
- double yy = y * 0.577350269189626;
165
- double xr = x + s2 - yy;
166
- double zr = z + s2 - yy;
167
- double yr = xz * 0.577350269189626 + yy;
144
+ * @return
145
+ */
146
+ public double noise3_XYBeforeZ(double x, double y, double z) {
147
+
148
+ // Re-orient the cubic lattices without skewing, to make X and Y triangular like 2D.
149
+ // Orthonormal rotation. Not a skew transform.
150
+ double xy = x + y;
151
+ double s2 = xy * -0.211324865405187;
152
+ double zz = z * 0.577350269189626;
153
+ double xr = x + s2 - zz, yr = y + s2 - zz;
154
+ double zr = xy * 0.577350269189626 + zz;
155
+
156
+ // Evaluate both lattices to form a BCC lattice.
157
+ return noise3_BCC(xr, yr, zr);
158
+ }
159
+
160
+ /**
161
+ * 3D Re-oriented 4-point BCC noise, with better visual isotropy in (X, Z).Recommended for 3D terrain and time-varied animations.The Y coordinate should always be the "different" coordinate in your use case.If Y is vertical in world coordinates, call noise3_XZBeforeY(x, Y, z).If Z is vertical in world coordinates, call noise3_XZBeforeY(x, Z, y) or use noise3_XYBeforeZ.
162
+ * For a time varied animation, call noise3_XZBeforeY(x, T, y) or use noise3_XYBeforeZ.
163
+ * @param x
164
+ * @param y
165
+ * @param z
166
+ * @return
167
+ */
168
+ public double noise3_XZBeforeY(double x, double y, double z) {
169
+
170
+ // Re-orient the cubic lattices without skewing, to make X and Z triangular like 2D.
171
+ // Orthonormal rotation. Not a skew transform.
172
+ double xz = x + z;
173
+ double s2 = xz * -0.211324865405187;
174
+ double yy = y * 0.577350269189626;
175
+ double xr = x + s2 - yy; double zr = z + s2 - yy;
176
+ double yr = xz * 0.577350269189626 + yy;
177
+
178
+ // Evaluate both lattices to form a BCC lattice.
179
+ return noise3_BCC(xr, yr, zr);
180
+ }
181
+
182
+ /**
183
+ * Generate overlapping cubic lattices for 3D Re-oriented BCC noise.
184
+ * Lookup table implementation inspired by DigitalShadow.
185
+ * It was actually faster to narrow down the points in the loop itself,
186
+ * than to build up the index with enough info to isolate 4 points.
187
+ */
188
+ private double noise3_BCC(double xr, double yr, double zr) {
189
+
190
+ // Get base and offsets inside cube of first lattice.
191
+ int xrb = fastFloor(xr), yrb = fastFloor(yr), zrb = fastFloor(zr);
192
+ double xri = xr - xrb, yri = yr - yrb, zri = zr - zrb;
193
+
194
+ // Identify which octant of the cube we're in. This determines which cell
195
+ // in the other cubic lattice we're in, and also narrows down one point on each.
196
+ int xht = (int)(xri + 0.5), yht = (int)(yri + 0.5), zht = (int)(zri + 0.5);
197
+ int index = (xht) | (yht << 1) | (zht << 2);
198
+
199
+ // Point contributions
200
+ double value = 0;
201
+ LatticePoint3D c = LOOKUP_3D[index];
202
+ while (c != null) {
203
+ double dxr = xri + c.dxr, dyr = yri + c.dyr, dzr = zri + c.dzr;
204
+ double attn = 0.5 - dxr * dxr - dyr * dyr - dzr * dzr;
205
+ if (attn < 0) {
206
+ c = c.nextOnFailure;
207
+ } else {
208
+ int pxm = (xrb + c.xrv) & PMASK, pym = (yrb + c.yrv) & PMASK, pzm = (zrb + c.zrv) & PMASK;
209
+ Grad3 grad = permGrad3[perm[perm[pxm] ^ pym] ^ pzm];
210
+ double extrapolation = grad.dx * dxr + grad.dy * dyr + grad.dz * dzr;
211
+
212
+ attn *= attn;
213
+ value += attn * attn * extrapolation;
214
+ c = c.nextOnSuccess;
215
+ }
216
+ }
217
+ return value;
218
+ }
219
+
220
+ /**
221
+ * 4D OpenSimplex2F noise, classic lattice orientation.
222
+ * @param x
223
+ * @param y
224
+ * @param w
225
+ * @param z
226
+ * @return
227
+ */
228
+ public double noise4_Classic(double x, double y, double z, double w) {
168
229
 
169
- // Evaluate both lattices to form a BCC lattice.
170
- return noise3_BCC(xr, yr, zr);
171
- }
230
+ // Get points for A4 lattice
231
+ double s = -0.138196601125011 * (x + y + z + w);
232
+ double xs = x + s, ys = y + s, zs = z + s, ws = w + s;
172
233
 
173
- /**
174
- * Generate overlapping cubic lattices for 3D Re-oriented BCC noise. Lookup
175
- * table implementation inspired by DigitalShadow. It was actually faster to
176
- * narrow down the points in the loop itself, than to build up the index
177
- * with enough info to isolate 4 points.
178
- */
179
- private double noise3_BCC(double xr, double yr, double zr) {
180
-
181
- // Get base and offsets inside cube of first lattice.
182
- int xrb = fastFloor(xr), yrb = fastFloor(yr), zrb = fastFloor(zr);
183
- double xri = xr - xrb, yri = yr - yrb, zri = zr - zrb;
184
-
185
- // Identify which octant of the cube we're in. This determines which cell
186
- // in the other cubic lattice we're in, and also narrows down one point on each.
187
- int xht = (int) (xri + 0.5), yht = (int) (yri + 0.5), zht = (int) (zri + 0.5);
188
- int index = (xht) | (yht << 1) | (zht << 2);
189
-
190
- // Point contributions
191
- double value = 0;
192
- LatticePoint3D c = LOOKUP_3D[index];
193
- while (c != null) {
194
- double dxr = xri + c.dxr, dyr = yri + c.dyr, dzr = zri + c.dzr;
195
- double attn = 0.5 - dxr * dxr - dyr * dyr - dzr * dzr;
196
- if (attn < 0) {
197
- c = c.nextOnFailure;
198
- } else {
199
- int pxm = (xrb + c.xrv) & PMASK, pym = (yrb + c.yrv) & PMASK, pzm = (zrb + c.zrv) & PMASK;
200
- Grad3 grad = permGrad3[perm[perm[pxm] ^ pym] ^ pzm];
201
- double extrapolation = grad.dx * dxr + grad.dy * dyr + grad.dz * dzr;
202
-
203
- attn *= attn;
204
- value += attn * attn * extrapolation;
205
- c = c.nextOnSuccess;
206
- }
207
- }
208
- return value;
209
- }
234
+ return noise4_Base(xs, ys, zs, ws);
235
+ }
210
236
 
211
- /**
212
- * 4D OpenSimplex2F noise, classic lattice orientation.
213
- *
237
+ /**
238
+ * 4D OpenSimplex2F noise, with XY and ZW forming orthogonal triangular-based planes.Recommended for 3D terrain, where X and Y (or Z and W) are horizontal.Recommended for noise(x, y, sin(time), cos(time)) trick.
214
239
  * @param x
215
- * @param y
216
240
  * @param z
241
+ * @param y
217
242
  * @param w
218
- * @return
219
- */
220
- public double noise4_Classic(double x, double y, double z, double w) {
243
+ * @return
244
+ */
245
+ public double noise4_XYBeforeZW(double x, double y, double z, double w) {
221
246
 
222
- // Get points for A4 lattice
223
- double s = -0.138196601125011 * (x + y + z + w);
224
- double xs = x + s, ys = y + s, zs = z + s, ws = w + s;
247
+ double s2 = (x + y) * -0.178275657951399372 + (z + w) * 0.215623393288842828;
248
+ double t2 = (z + w) * -0.403949762580207112 + (x + y) * -0.375199083010075342;
249
+ double xs = x + s2, ys = y + s2, zs = z + t2, ws = w + t2;
225
250
 
226
- return noise4_Base(xs, ys, zs, ws);
227
- }
251
+ return noise4_Base(xs, ys, zs, ws);
252
+ }
228
253
 
229
- /**
230
- * 4D OpenSimplex2F noise, with XY and ZW forming orthogonal
231
- * triangular-based planes.Recommended for 3D terrain, where X and Y (or Z
232
- * and W) are horizontal.Recommended for noise(x, y, sin(time), cos(time))
233
- * trick.
234
- *
254
+ /**
255
+ * 4D OpenSimplex2F noise, with XZ and YW forming orthogonal triangular-based planes.Recommended for 3D terrain, where X and Z (or Y and W) are horizontal.
235
256
  * @param x
236
- * @param y
237
257
  * @param z
258
+ * @param y
238
259
  * @param w
239
- * @return
240
- */
241
- public double noise4_XYBeforeZW(double x, double y, double z, double w) {
260
+ * @return
261
+ */
262
+ public double noise4_XZBeforeYW(double x, double y, double z, double w) {
242
263
 
243
- double s2 = (x + y) * -0.178275657951399372 + (z + w) * 0.215623393288842828;
244
- double t2 = (z + w) * -0.403949762580207112 + (x + y) * -0.375199083010075342;
245
- double xs = x + s2, ys = y + s2, zs = z + t2, ws = w + t2;
264
+ double s2 = (x + z) * -0.178275657951399372 + (y + w) * 0.215623393288842828;
265
+ double t2 = (y + w) * -0.403949762580207112 + (x + z) * -0.375199083010075342;
266
+ double xs = x + s2, ys = y + t2, zs = z + s2, ws = w + t2;
246
267
 
247
- return noise4_Base(xs, ys, zs, ws);
248
- }
268
+ return noise4_Base(xs, ys, zs, ws);
269
+ }
249
270
 
250
- /**
251
- * 4D OpenSimplex2F noise, with XYZ oriented like noise3_Classic, and W for
252
- * an extra degree of freedom.W repeats eventually.Recommended for
253
- * time-varied animations which texture a 3D object (W=time)
254
- *
271
+ /**
272
+ * 4D OpenSimplex2F noise, with XYZ oriented like noise3_Classic,
273
+ * and W for an extra degree of freedom.W repeats eventually.Recommended for time-varied animations which texture a 3D object (W=time)
255
274
  * @param x
275
+ * @param w
256
276
  * @param y
257
277
  * @param z
258
- * @param w
259
278
  * @return
260
- */
261
- public double noise4_XYZBeforeW(double x, double y, double z, double w) {
262
-
263
- double xyz = x + y + z;
264
- double ww = w * 0.2236067977499788;
265
- double s2 = xyz * -0.16666666666666666 + ww;
266
- double xs = x + s2, ys = y + s2, zs = z + s2, ws = -0.5 * xyz + ww;
279
+ */
280
+ public double noise4_XYZBeforeW(double x, double y, double z, double w) {
281
+
282
+ double xyz = x + y + z;
283
+ double ww = w * 0.2236067977499788;
284
+ double s2 = xyz * -0.16666666666666666 + ww;
285
+ double xs = x + s2, ys = y + s2, zs = z + s2, ws = -0.5 * xyz + ww;
286
+
287
+ return noise4_Base(xs, ys, zs, ws);
288
+ }
289
+
290
+ /**
291
+ * 4D OpenSimplex2F noise base.
292
+ * Current implementation not fully optimized by lookup tables.
293
+ * But still comes out slightly ahead of Gustavson's Simplex in tests.
294
+ */
295
+ private double noise4_Base(double xs, double ys, double zs, double ws) {
296
+ double value = 0;
297
+
298
+ // Get base points and offsets
299
+ int xsb = fastFloor(xs), ysb = fastFloor(ys), zsb = fastFloor(zs), wsb = fastFloor(ws);
300
+ double xsi = xs - xsb, ysi = ys - ysb, zsi = zs - zsb, wsi = ws - wsb;
301
+
302
+ // If we're in the lower half, flip so we can repeat the code for the upper half. We'll flip back later.
303
+ double siSum = xsi + ysi + zsi + wsi;
304
+ double ssi = siSum * 0.309016994374947; // Prep for vertex contributions.
305
+ boolean inLowerHalf = siSum < 2;
306
+ if (inLowerHalf) {
307
+ xsi = 1 - xsi; ysi = 1 - ysi; zsi = 1 - zsi; wsi = 1 - wsi;
308
+ siSum = 4 - siSum;
309
+ }
310
+
311
+ // Consider opposing vertex pairs of the octahedron formed by the central cross-section of the stretched tesseract
312
+ double aabb = xsi + ysi - zsi - wsi, abab = xsi - ysi + zsi - wsi, abba = xsi - ysi - zsi + wsi;
313
+ double aabbScore = Math.abs(aabb), ababScore = Math.abs(abab), abbaScore = Math.abs(abba);
314
+
315
+ // Find the closest point on the stretched tesseract as if it were the upper half
316
+ int vertexIndex, via, vib;
317
+ double asi, bsi;
318
+ if (aabbScore > ababScore && aabbScore > abbaScore) {
319
+ if (aabb > 0) {
320
+ asi = zsi; bsi = wsi; vertexIndex = 0b0011; via = 0b0111; vib = 0b1011;
321
+ } else {
322
+ asi = xsi; bsi = ysi; vertexIndex = 0b1100; via = 0b1101; vib = 0b1110;
323
+ }
324
+ } else if (ababScore > abbaScore) {
325
+ if (abab > 0) {
326
+ asi = ysi; bsi = wsi; vertexIndex = 0b0101; via = 0b0111; vib = 0b1101;
327
+ } else {
328
+ asi = xsi; bsi = zsi; vertexIndex = 0b1010; via = 0b1011; vib = 0b1110;
329
+ }
330
+ } else {
331
+ if (abba > 0) {
332
+ asi = ysi; bsi = zsi; vertexIndex = 0b1001; via = 0b1011; vib = 0b1101;
333
+ } else {
334
+ asi = xsi; bsi = wsi; vertexIndex = 0b0110; via = 0b0111; vib = 0b1110;
335
+ }
336
+ }
337
+ if (bsi > asi) {
338
+ via = vib;
339
+ double temp = bsi;
340
+ bsi = asi;
341
+ asi = temp;
342
+ }
343
+ if (siSum + asi > 3) {
344
+ vertexIndex = via;
345
+ if (siSum + bsi > 4) {
346
+ vertexIndex = 0b1111;
347
+ }
348
+ }
349
+
350
+ // Now flip back if we're actually in the lower half.
351
+ if (inLowerHalf) {
352
+ xsi = 1 - xsi; ysi = 1 - ysi; zsi = 1 - zsi; wsi = 1 - wsi;
353
+ vertexIndex ^= 0b1111;
354
+ }
355
+
356
+ // Five points to add, total, from five copies of the A4 lattice.
357
+ for (int i = 0; i < 5; i++) {
358
+
359
+ // Update xsb/etc. and add the lattice point's contribution.
360
+ LatticePoint4D c = VERTICES_4D[vertexIndex];
361
+ xsb += c.xsv; ysb += c.ysv; zsb += c.zsv; wsb += c.wsv;
362
+ double xi = xsi + ssi, yi = ysi + ssi, zi = zsi + ssi, wi = wsi + ssi;
363
+ double dx = xi + c.dx, dy = yi + c.dy, dz = zi + c.dz, dw = wi + c.dw;
364
+ double attn = 0.5 - dx * dx - dy * dy - dz * dz - dw * dw;
365
+ if (attn > 0) {
366
+ int pxm = xsb & PMASK, pym = ysb & PMASK, pzm = zsb & PMASK, pwm = wsb & PMASK;
367
+ Grad4 grad = permGrad4[perm[perm[perm[pxm] ^ pym] ^ pzm] ^ pwm];
368
+ double ramped = grad.dx * dx + grad.dy * dy + grad.dz * dz + grad.dw * dw;
369
+
370
+ attn *= attn;
371
+ value += attn * attn * ramped;
372
+ }
373
+
374
+ // Maybe this helps the compiler/JVM/LLVM/etc. know we can end the loop here. Maybe not.
375
+ if (i == 4) break;
376
+
377
+ // Update the relative skewed coordinates to reference the vertex we just added.
378
+ // Rather, reference its counterpart on the lattice copy that is shifted down by
379
+ // the vector <-0.2, -0.2, -0.2, -0.2>
380
+ xsi += c.xsi; ysi += c.ysi; zsi += c.zsi; wsi += c.wsi;
381
+ ssi += c.ssiDelta;
382
+
383
+ // Next point is the closest vertex on the 4-simplex whose base vertex is the aforementioned vertex.
384
+ double score0 = 1.0 + ssi * (-1.0 / 0.309016994374947); // Seems slightly faster than 1.0-xsi-ysi-zsi-wsi
385
+ vertexIndex = 0b0000;
386
+ if (xsi >= ysi && xsi >= zsi && xsi >= wsi && xsi >= score0) {
387
+ vertexIndex = 0b0001;
388
+ }
389
+ else if (ysi > xsi && ysi >= zsi && ysi >= wsi && ysi >= score0) {
390
+ vertexIndex = 0b0010;
391
+ }
392
+ else if (zsi > xsi && zsi > ysi && zsi >= wsi && zsi >= score0) {
393
+ vertexIndex = 0b0100;
394
+ }
395
+ else if (wsi > xsi && wsi > ysi && wsi > zsi && wsi >= score0) {
396
+ vertexIndex = 0b1000;
397
+ }
398
+ }
399
+
400
+ return value;
401
+ }
402
+
403
+ /*
404
+ * Utility
405
+ */
267
406
 
268
- return noise4_Base(xs, ys, zs, ws);
269
- }
407
+ private static int fastFloor(double x) {
408
+ int xi = (int)x;
409
+ return x < xi ? xi - 1 : xi;
410
+ }
270
411
 
271
- /**
272
- * 4D OpenSimplex2F noise base. Current implementation not fully optimized
273
- * by lookup tables. But still comes out slightly ahead of Gustavson's
274
- * Simplex in tests.
275
- */
276
- private double noise4_Base(double xs, double ys, double zs, double ws) {
277
- double value = 0;
278
-
279
- // Get base points and offsets
280
- int xsb = fastFloor(xs), ysb = fastFloor(ys), zsb = fastFloor(zs), wsb = fastFloor(ws);
281
- double xsi = xs - xsb, ysi = ys - ysb, zsi = zs - zsb, wsi = ws - wsb;
282
-
283
- // If we're in the lower half, flip so we can repeat the code for the upper half. We'll flip back later.
284
- double siSum = xsi + ysi + zsi + wsi;
285
- double ssi = siSum * 0.309016994374947; // Prep for vertex contributions.
286
- boolean inLowerHalf = (siSum < 2);
287
- if (inLowerHalf) {
288
- xsi = 1 - xsi;
289
- ysi = 1 - ysi;
290
- zsi = 1 - zsi;
291
- wsi = 1 - wsi;
292
- siSum = 4 - siSum;
293
- }
294
-
295
- // Consider opposing vertex pairs of the octahedron formed by the central cross-section of the stretched tesseract
296
- double aabb = xsi + ysi - zsi - wsi, abab = xsi - ysi + zsi - wsi, abba = xsi - ysi - zsi + wsi;
297
- double aabbScore = Math.abs(aabb), ababScore = Math.abs(abab), abbaScore = Math.abs(abba);
298
-
299
- // Find the closest point on the stretched tesseract as if it were the upper half
300
- int vertexIndex, via, vib;
301
- double asi, bsi;
302
- if (aabbScore > ababScore && aabbScore > abbaScore) {
303
- if (aabb > 0) {
304
- asi = zsi;
305
- bsi = wsi;
306
- vertexIndex = 0b0011;
307
- via = 0b0111;
308
- vib = 0b1011;
309
- } else {
310
- asi = xsi;
311
- bsi = ysi;
312
- vertexIndex = 0b1100;
313
- via = 0b1101;
314
- vib = 0b1110;
315
- }
316
- } else if (ababScore > abbaScore) {
317
- if (abab > 0) {
318
- asi = ysi;
319
- bsi = wsi;
320
- vertexIndex = 0b0101;
321
- via = 0b0111;
322
- vib = 0b1101;
323
- } else {
324
- asi = xsi;
325
- bsi = zsi;
326
- vertexIndex = 0b1010;
327
- via = 0b1011;
328
- vib = 0b1110;
329
- }
330
- } else {
331
- if (abba > 0) {
332
- asi = ysi;
333
- bsi = zsi;
334
- vertexIndex = 0b1001;
335
- via = 0b1011;
336
- vib = 0b1101;
337
- } else {
338
- asi = xsi;
339
- bsi = wsi;
340
- vertexIndex = 0b0110;
341
- via = 0b0111;
342
- vib = 0b1110;
343
- }
344
- }
345
- if (bsi > asi) {
346
- via = vib;
347
- double temp = bsi;
348
- bsi = asi;
349
- asi = temp;
350
- }
351
- if (siSum + asi > 3) {
352
- vertexIndex = via;
353
- if (siSum + bsi > 4) {
354
- vertexIndex = 0b1111;
412
+ /*
413
+ * Definitions
414
+ */
415
+
416
+ private static final LatticePoint2D[] LOOKUP_2D;
417
+ private static final LatticePoint3D[] LOOKUP_3D;
418
+ private static final LatticePoint4D[] VERTICES_4D;
419
+ static {
420
+ LOOKUP_2D = new LatticePoint2D[4];
421
+ LOOKUP_3D = new LatticePoint3D[8];
422
+ VERTICES_4D = new LatticePoint4D[16];
423
+
424
+ LOOKUP_2D[0] = new LatticePoint2D(1, 0);
425
+ LOOKUP_2D[1] = new LatticePoint2D(0, 0);
426
+ LOOKUP_2D[2] = new LatticePoint2D(1, 1);
427
+ LOOKUP_2D[3] = new LatticePoint2D(0, 1);
428
+
429
+ for (int i = 0; i < 8; i++) {
430
+ int i1, j1, k1, i2, j2, k2;
431
+ i1 = (i) & 1; j1 = (i >> 1) & 1; k1 = (i >> 2) & 1;
432
+ i2 = i1 ^ 1; j2 = j1 ^ 1; k2 = k1 ^ 1;
433
+
434
+ // The two points within this octant, one from each of the two cubic half-lattices.
435
+ LatticePoint3D c0 = new LatticePoint3D(i1, j1, k1, 0);
436
+ LatticePoint3D c1 = new LatticePoint3D(i1 + i2, j1 + j2, k1 + k2, 1);
437
+
438
+ // Each single step away on the first half-lattice.
439
+ LatticePoint3D c2 = new LatticePoint3D(i1 ^ 1, j1, k1, 0);
440
+ LatticePoint3D c3 = new LatticePoint3D(i1, j1 ^ 1, k1, 0);
441
+ LatticePoint3D c4 = new LatticePoint3D(i1, j1, k1 ^ 1, 0);
442
+
443
+ // Each single step away on the second half-lattice.
444
+ LatticePoint3D c5 = new LatticePoint3D(i1 + (i2 ^ 1), j1 + j2, k1 + k2, 1);
445
+ LatticePoint3D c6 = new LatticePoint3D(i1 + i2, j1 + (j2 ^ 1), k1 + k2, 1);
446
+ LatticePoint3D c7 = new LatticePoint3D(i1 + i2, j1 + j2, k1 + (k2 ^ 1), 1);
447
+
448
+ // First two are guaranteed.
449
+ c0.nextOnFailure = c0.nextOnSuccess = c1;
450
+ c1.nextOnFailure = c1.nextOnSuccess = c2;
451
+
452
+ // Once we find one on the first half-lattice, the rest are out.
453
+ // In addition, knowing c2 rules out c5.
454
+ c2.nextOnFailure = c3; c2.nextOnSuccess = c6;
455
+ c3.nextOnFailure = c4; c3.nextOnSuccess = c5;
456
+ c4.nextOnFailure = c4.nextOnSuccess = c5;
457
+
458
+ // Once we find one on the second half-lattice, the rest are out.
459
+ c5.nextOnFailure = c6; c5.nextOnSuccess = null;
460
+ c6.nextOnFailure = c7; c6.nextOnSuccess = null;
461
+ c7.nextOnFailure = c7.nextOnSuccess = null;
462
+
463
+ LOOKUP_3D[i] = c0;
464
+ }
465
+
466
+ for (int i = 0; i < 16; i++) {
467
+ VERTICES_4D[i] = new LatticePoint4D((i) & 1, (i >> 1) & 1, (i >> 2) & 1, (i >> 3) & 1);
468
+ }
469
+ }
470
+
471
+ private static class LatticePoint2D {
472
+ int xsv, ysv;
473
+ double dx, dy;
474
+ public LatticePoint2D(int xsv, int ysv) {
475
+ this.xsv = xsv; this.ysv = ysv;
476
+ double ssv = (xsv + ysv) * -0.211324865405187;
477
+ this.dx = -xsv - ssv;
478
+ this.dy = -ysv - ssv;
479
+ }
480
+ }
481
+
482
+ private static class LatticePoint3D {
483
+ public double dxr, dyr, dzr;
484
+ public int xrv, yrv, zrv;
485
+ LatticePoint3D nextOnFailure, nextOnSuccess;
486
+ public LatticePoint3D(int xrv, int yrv, int zrv, int lattice) {
487
+ this.dxr = -xrv + lattice * 0.5; this.dyr = -yrv + lattice * 0.5; this.dzr = -zrv + lattice * 0.5;
488
+ this.xrv = xrv + lattice * 1024; this.yrv = yrv + lattice * 1024; this.zrv = zrv + lattice * 1024;
489
+ }
490
+ }
491
+
492
+ private static class LatticePoint4D {
493
+ int xsv, ysv, zsv, wsv;
494
+ double dx, dy, dz, dw;
495
+ double xsi, ysi, zsi, wsi;
496
+ double ssiDelta;
497
+ public LatticePoint4D(int xsv, int ysv, int zsv, int wsv) {
498
+ this.xsv = xsv + 409; this.ysv = ysv + 409; this.zsv = zsv + 409; this.wsv = wsv + 409;
499
+ double ssv = (xsv + ysv + zsv + wsv) * 0.309016994374947;
500
+ this.dx = -xsv - ssv;
501
+ this.dy = -ysv - ssv;
502
+ this.dz = -zsv - ssv;
503
+ this.dw = -wsv - ssv;
504
+ this.xsi = xsi = 0.2 - xsv;
505
+ this.ysi = ysi = 0.2 - ysv;
506
+ this.zsi = zsi = 0.2 - zsv;
507
+ this.wsi = wsi = 0.2 - wsv;
508
+ this.ssiDelta = (0.8 - xsv - ysv - zsv - wsv) * 0.309016994374947;
509
+ }
510
+ }
511
+
512
+ /*
513
+ * Gradients
514
+ */
515
+
516
+ private static class Grad2 {
517
+ double dx, dy;
518
+ public Grad2(double dx, double dy) {
519
+ this.dx = dx; this.dy = dy;
520
+ }
521
+ }
522
+
523
+ private static class Grad3 {
524
+ double dx, dy, dz;
525
+ public Grad3(double dx, double dy, double dz) {
526
+ this.dx = dx; this.dy = dy; this.dz = dz;
527
+ }
528
+ }
529
+
530
+ private static class Grad4 {
531
+ double dx, dy, dz, dw;
532
+ public Grad4(double dx, double dy, double dz, double dw) {
533
+ this.dx = dx; this.dy = dy; this.dz = dz; this.dw = dw;
534
+ }
535
+ }
536
+
537
+ private static final double N2 = 0.01001634121365712;
538
+ private static final double N3 = 0.030485933181293584;
539
+ private static final double N4 = 0.009202377986303158;
540
+ private static final Grad2[] GRADIENTS_2D;
541
+ private static final Grad3[] GRADIENTS_3D;
542
+ private static final Grad4[] GRADIENTS_4D;
543
+ static {
544
+
545
+ GRADIENTS_2D = new Grad2[PSIZE];
546
+ Grad2[] grad2 = {
547
+ new Grad2( 0.130526192220052, 0.99144486137381),
548
+ new Grad2( 0.38268343236509, 0.923879532511287),
549
+ new Grad2( 0.608761429008721, 0.793353340291235),
550
+ new Grad2( 0.793353340291235, 0.608761429008721),
551
+ new Grad2( 0.923879532511287, 0.38268343236509),
552
+ new Grad2( 0.99144486137381, 0.130526192220051),
553
+ new Grad2( 0.99144486137381, -0.130526192220051),
554
+ new Grad2( 0.923879532511287, -0.38268343236509),
555
+ new Grad2( 0.793353340291235, -0.60876142900872),
556
+ new Grad2( 0.608761429008721, -0.793353340291235),
557
+ new Grad2( 0.38268343236509, -0.923879532511287),
558
+ new Grad2( 0.130526192220052, -0.99144486137381),
559
+ new Grad2(-0.130526192220052, -0.99144486137381),
560
+ new Grad2(-0.38268343236509, -0.923879532511287),
561
+ new Grad2(-0.608761429008721, -0.793353340291235),
562
+ new Grad2(-0.793353340291235, -0.608761429008721),
563
+ new Grad2(-0.923879532511287, -0.38268343236509),
564
+ new Grad2(-0.99144486137381, -0.130526192220052),
565
+ new Grad2(-0.99144486137381, 0.130526192220051),
566
+ new Grad2(-0.923879532511287, 0.38268343236509),
567
+ new Grad2(-0.793353340291235, 0.608761429008721),
568
+ new Grad2(-0.608761429008721, 0.793353340291235),
569
+ new Grad2(-0.38268343236509, 0.923879532511287),
570
+ new Grad2(-0.130526192220052, 0.99144486137381)
571
+ };
572
+ for (Grad2 grad21 : grad2) {
573
+ grad21.dx /= N2;
574
+ grad21.dy /= N2;
355
575
  }
356
- }
357
-
358
- // Now flip back if we're actually in the lower half.
359
- if (inLowerHalf) {
360
- xsi = 1 - xsi;
361
- ysi = 1 - ysi;
362
- zsi = 1 - zsi;
363
- wsi = 1 - wsi;
364
- vertexIndex ^= 0b1111;
365
- }
366
-
367
- // Five points to add, total, from five copies of the A4 lattice.
368
- for (int i = 0; i < 5; i++) {
369
-
370
- // Update xsb/etc. and add the lattice point's contribution.
371
- LatticePoint4D c = VERTICES_4D[vertexIndex];
372
- xsb += c.xsv;
373
- ysb += c.ysv;
374
- zsb += c.zsv;
375
- wsb += c.wsv;
376
- double xi = xsi + ssi, yi = ysi + ssi, zi = zsi + ssi, wi = wsi + ssi;
377
- double dx = xi + c.dx, dy = yi + c.dy, dz = zi + c.dz, dw = wi + c.dw;
378
- double attn = 0.5 - dx * dx - dy * dy - dz * dz - dw * dw;
379
- if (attn > 0) {
380
- int pxm = xsb & PMASK, pym = ysb & PMASK, pzm = zsb & PMASK, pwm = wsb & PMASK;
381
- Grad4 grad = permGrad4[perm[perm[perm[pxm] ^ pym] ^ pzm] ^ pwm];
382
- double ramped = grad.dx * dx + grad.dy * dy + grad.dz * dz + grad.dw * dw;
383
-
384
- attn *= attn;
385
- value += attn * attn * ramped;
576
+ for (int i = 0; i < PSIZE; i++) {
577
+ GRADIENTS_2D[i] = grad2[i % grad2.length];
578
+ }
579
+
580
+ GRADIENTS_3D = new Grad3[PSIZE];
581
+ Grad3[] grad3 = {
582
+ new Grad3(-2.22474487139, -2.22474487139, -1.0),
583
+ new Grad3(-2.22474487139, -2.22474487139, 1.0),
584
+ new Grad3(-3.0862664687972017, -1.1721513422464978, 0.0),
585
+ new Grad3(-1.1721513422464978, -3.0862664687972017, 0.0),
586
+ new Grad3(-2.22474487139, -1.0, -2.22474487139),
587
+ new Grad3(-2.22474487139, 1.0, -2.22474487139),
588
+ new Grad3(-1.1721513422464978, 0.0, -3.0862664687972017),
589
+ new Grad3(-3.0862664687972017, 0.0, -1.1721513422464978),
590
+ new Grad3(-2.22474487139, -1.0, 2.22474487139),
591
+ new Grad3(-2.22474487139, 1.0, 2.22474487139),
592
+ new Grad3(-3.0862664687972017, 0.0, 1.1721513422464978),
593
+ new Grad3(-1.1721513422464978, 0.0, 3.0862664687972017),
594
+ new Grad3(-2.22474487139, 2.22474487139, -1.0),
595
+ new Grad3(-2.22474487139, 2.22474487139, 1.0),
596
+ new Grad3(-1.1721513422464978, 3.0862664687972017, 0.0),
597
+ new Grad3(-3.0862664687972017, 1.1721513422464978, 0.0),
598
+ new Grad3(-1.0, -2.22474487139, -2.22474487139),
599
+ new Grad3( 1.0, -2.22474487139, -2.22474487139),
600
+ new Grad3( 0.0, -3.0862664687972017, -1.1721513422464978),
601
+ new Grad3( 0.0, -1.1721513422464978, -3.0862664687972017),
602
+ new Grad3(-1.0, -2.22474487139, 2.22474487139),
603
+ new Grad3( 1.0, -2.22474487139, 2.22474487139),
604
+ new Grad3( 0.0, -1.1721513422464978, 3.0862664687972017),
605
+ new Grad3( 0.0, -3.0862664687972017, 1.1721513422464978),
606
+ new Grad3(-1.0, 2.22474487139, -2.22474487139),
607
+ new Grad3( 1.0, 2.22474487139, -2.22474487139),
608
+ new Grad3( 0.0, 1.1721513422464978, -3.0862664687972017),
609
+ new Grad3( 0.0, 3.0862664687972017, -1.1721513422464978),
610
+ new Grad3(-1.0, 2.22474487139, 2.22474487139),
611
+ new Grad3( 1.0, 2.22474487139, 2.22474487139),
612
+ new Grad3( 0.0, 3.0862664687972017, 1.1721513422464978),
613
+ new Grad3( 0.0, 1.1721513422464978, 3.0862664687972017),
614
+ new Grad3( 2.22474487139, -2.22474487139, -1.0),
615
+ new Grad3( 2.22474487139, -2.22474487139, 1.0),
616
+ new Grad3( 1.1721513422464978, -3.0862664687972017, 0.0),
617
+ new Grad3( 3.0862664687972017, -1.1721513422464978, 0.0),
618
+ new Grad3( 2.22474487139, -1.0, -2.22474487139),
619
+ new Grad3( 2.22474487139, 1.0, -2.22474487139),
620
+ new Grad3( 3.0862664687972017, 0.0, -1.1721513422464978),
621
+ new Grad3( 1.1721513422464978, 0.0, -3.0862664687972017),
622
+ new Grad3( 2.22474487139, -1.0, 2.22474487139),
623
+ new Grad3( 2.22474487139, 1.0, 2.22474487139),
624
+ new Grad3( 1.1721513422464978, 0.0, 3.0862664687972017),
625
+ new Grad3( 3.0862664687972017, 0.0, 1.1721513422464978),
626
+ new Grad3( 2.22474487139, 2.22474487139, -1.0),
627
+ new Grad3( 2.22474487139, 2.22474487139, 1.0),
628
+ new Grad3( 3.0862664687972017, 1.1721513422464978, 0.0),
629
+ new Grad3( 1.1721513422464978, 3.0862664687972017, 0.0)
630
+ };
631
+ for (Grad3 grad31 : grad3) {
632
+ grad31.dx /= N3;
633
+ grad31.dy /= N3;
634
+ grad31.dz /= N3;
386
635
  }
387
-
388
- // Maybe this helps the compiler/JVM/LLVM/etc. know we can end the loop here. Maybe not.
389
- if (i == 4) {
390
- break;
391
- }
392
-
393
- // Update the relative skewed coordinates to reference the vertex we just added.
394
- // Rather, reference its counterpart on the lattice copy that is shifted down by
395
- // the vector <-0.2, -0.2, -0.2, -0.2>
396
- xsi += c.xsi;
397
- ysi += c.ysi;
398
- zsi += c.zsi;
399
- wsi += c.wsi;
400
- ssi += c.ssiDelta;
401
-
402
- // Next point is the closest vertex on the 4-simplex whose base vertex is the aforementioned vertex.
403
- double score0 = 1.0 + ssi * (-1.0 / 0.309016994374947); // Seems slightly faster than 1.0-xsi-ysi-zsi-wsi
404
- vertexIndex = 0b0000;
405
- if (xsi >= ysi && xsi >= zsi && xsi >= wsi && xsi >= score0) {
406
- vertexIndex = 0b0001;
407
- } else if (ysi > xsi && ysi >= zsi && ysi >= wsi && ysi >= score0) {
408
- vertexIndex = 0b0010;
409
- } else if (zsi > xsi && zsi > ysi && zsi >= wsi && zsi >= score0) {
410
- vertexIndex = 0b0100;
411
- } else if (wsi > xsi && wsi > ysi && wsi > zsi && wsi >= score0) {
412
- vertexIndex = 0b1000;
636
+ for (int i = 0; i < PSIZE; i++) {
637
+ GRADIENTS_3D[i] = grad3[i % grad3.length];
638
+ }
639
+
640
+ GRADIENTS_4D = new Grad4[PSIZE];
641
+ Grad4[] grad4 = {
642
+ new Grad4(-0.753341017856078, -0.37968289875261624, -0.37968289875261624, -0.37968289875261624),
643
+ new Grad4(-0.7821684431180708, -0.4321472685365301, -0.4321472685365301, 0.12128480194602098),
644
+ new Grad4(-0.7821684431180708, -0.4321472685365301, 0.12128480194602098, -0.4321472685365301),
645
+ new Grad4(-0.7821684431180708, 0.12128480194602098, -0.4321472685365301, -0.4321472685365301),
646
+ new Grad4(-0.8586508742123365, -0.508629699630796, 0.044802370851755174, 0.044802370851755174),
647
+ new Grad4(-0.8586508742123365, 0.044802370851755174, -0.508629699630796, 0.044802370851755174),
648
+ new Grad4(-0.8586508742123365, 0.044802370851755174, 0.044802370851755174, -0.508629699630796),
649
+ new Grad4(-0.9982828964265062, -0.03381941603233842, -0.03381941603233842, -0.03381941603233842),
650
+ new Grad4(-0.37968289875261624, -0.753341017856078, -0.37968289875261624, -0.37968289875261624),
651
+ new Grad4(-0.4321472685365301, -0.7821684431180708, -0.4321472685365301, 0.12128480194602098),
652
+ new Grad4(-0.4321472685365301, -0.7821684431180708, 0.12128480194602098, -0.4321472685365301),
653
+ new Grad4( 0.12128480194602098, -0.7821684431180708, -0.4321472685365301, -0.4321472685365301),
654
+ new Grad4(-0.508629699630796, -0.8586508742123365, 0.044802370851755174, 0.044802370851755174),
655
+ new Grad4( 0.044802370851755174, -0.8586508742123365, -0.508629699630796, 0.044802370851755174),
656
+ new Grad4( 0.044802370851755174, -0.8586508742123365, 0.044802370851755174, -0.508629699630796),
657
+ new Grad4(-0.03381941603233842, -0.9982828964265062, -0.03381941603233842, -0.03381941603233842),
658
+ new Grad4(-0.37968289875261624, -0.37968289875261624, -0.753341017856078, -0.37968289875261624),
659
+ new Grad4(-0.4321472685365301, -0.4321472685365301, -0.7821684431180708, 0.12128480194602098),
660
+ new Grad4(-0.4321472685365301, 0.12128480194602098, -0.7821684431180708, -0.4321472685365301),
661
+ new Grad4( 0.12128480194602098, -0.4321472685365301, -0.7821684431180708, -0.4321472685365301),
662
+ new Grad4(-0.508629699630796, 0.044802370851755174, -0.8586508742123365, 0.044802370851755174),
663
+ new Grad4( 0.044802370851755174, -0.508629699630796, -0.8586508742123365, 0.044802370851755174),
664
+ new Grad4( 0.044802370851755174, 0.044802370851755174, -0.8586508742123365, -0.508629699630796),
665
+ new Grad4(-0.03381941603233842, -0.03381941603233842, -0.9982828964265062, -0.03381941603233842),
666
+ new Grad4(-0.37968289875261624, -0.37968289875261624, -0.37968289875261624, -0.753341017856078),
667
+ new Grad4(-0.4321472685365301, -0.4321472685365301, 0.12128480194602098, -0.7821684431180708),
668
+ new Grad4(-0.4321472685365301, 0.12128480194602098, -0.4321472685365301, -0.7821684431180708),
669
+ new Grad4( 0.12128480194602098, -0.4321472685365301, -0.4321472685365301, -0.7821684431180708),
670
+ new Grad4(-0.508629699630796, 0.044802370851755174, 0.044802370851755174, -0.8586508742123365),
671
+ new Grad4( 0.044802370851755174, -0.508629699630796, 0.044802370851755174, -0.8586508742123365),
672
+ new Grad4( 0.044802370851755174, 0.044802370851755174, -0.508629699630796, -0.8586508742123365),
673
+ new Grad4(-0.03381941603233842, -0.03381941603233842, -0.03381941603233842, -0.9982828964265062),
674
+ new Grad4(-0.6740059517812944, -0.3239847771997537, -0.3239847771997537, 0.5794684678643381),
675
+ new Grad4(-0.7504883828755602, -0.4004672082940195, 0.15296486218853164, 0.5029860367700724),
676
+ new Grad4(-0.7504883828755602, 0.15296486218853164, -0.4004672082940195, 0.5029860367700724),
677
+ new Grad4(-0.8828161875373585, 0.08164729285680945, 0.08164729285680945, 0.4553054119602712),
678
+ new Grad4(-0.4553054119602712, -0.08164729285680945, -0.08164729285680945, 0.8828161875373585),
679
+ new Grad4(-0.5029860367700724, -0.15296486218853164, 0.4004672082940195, 0.7504883828755602),
680
+ new Grad4(-0.5029860367700724, 0.4004672082940195, -0.15296486218853164, 0.7504883828755602),
681
+ new Grad4(-0.5794684678643381, 0.3239847771997537, 0.3239847771997537, 0.6740059517812944),
682
+ new Grad4(-0.3239847771997537, -0.6740059517812944, -0.3239847771997537, 0.5794684678643381),
683
+ new Grad4(-0.4004672082940195, -0.7504883828755602, 0.15296486218853164, 0.5029860367700724),
684
+ new Grad4( 0.15296486218853164, -0.7504883828755602, -0.4004672082940195, 0.5029860367700724),
685
+ new Grad4( 0.08164729285680945, -0.8828161875373585, 0.08164729285680945, 0.4553054119602712),
686
+ new Grad4(-0.08164729285680945, -0.4553054119602712, -0.08164729285680945, 0.8828161875373585),
687
+ new Grad4(-0.15296486218853164, -0.5029860367700724, 0.4004672082940195, 0.7504883828755602),
688
+ new Grad4( 0.4004672082940195, -0.5029860367700724, -0.15296486218853164, 0.7504883828755602),
689
+ new Grad4( 0.3239847771997537, -0.5794684678643381, 0.3239847771997537, 0.6740059517812944),
690
+ new Grad4(-0.3239847771997537, -0.3239847771997537, -0.6740059517812944, 0.5794684678643381),
691
+ new Grad4(-0.4004672082940195, 0.15296486218853164, -0.7504883828755602, 0.5029860367700724),
692
+ new Grad4( 0.15296486218853164, -0.4004672082940195, -0.7504883828755602, 0.5029860367700724),
693
+ new Grad4( 0.08164729285680945, 0.08164729285680945, -0.8828161875373585, 0.4553054119602712),
694
+ new Grad4(-0.08164729285680945, -0.08164729285680945, -0.4553054119602712, 0.8828161875373585),
695
+ new Grad4(-0.15296486218853164, 0.4004672082940195, -0.5029860367700724, 0.7504883828755602),
696
+ new Grad4( 0.4004672082940195, -0.15296486218853164, -0.5029860367700724, 0.7504883828755602),
697
+ new Grad4( 0.3239847771997537, 0.3239847771997537, -0.5794684678643381, 0.6740059517812944),
698
+ new Grad4(-0.6740059517812944, -0.3239847771997537, 0.5794684678643381, -0.3239847771997537),
699
+ new Grad4(-0.7504883828755602, -0.4004672082940195, 0.5029860367700724, 0.15296486218853164),
700
+ new Grad4(-0.7504883828755602, 0.15296486218853164, 0.5029860367700724, -0.4004672082940195),
701
+ new Grad4(-0.8828161875373585, 0.08164729285680945, 0.4553054119602712, 0.08164729285680945),
702
+ new Grad4(-0.4553054119602712, -0.08164729285680945, 0.8828161875373585, -0.08164729285680945),
703
+ new Grad4(-0.5029860367700724, -0.15296486218853164, 0.7504883828755602, 0.4004672082940195),
704
+ new Grad4(-0.5029860367700724, 0.4004672082940195, 0.7504883828755602, -0.15296486218853164),
705
+ new Grad4(-0.5794684678643381, 0.3239847771997537, 0.6740059517812944, 0.3239847771997537),
706
+ new Grad4(-0.3239847771997537, -0.6740059517812944, 0.5794684678643381, -0.3239847771997537),
707
+ new Grad4(-0.4004672082940195, -0.7504883828755602, 0.5029860367700724, 0.15296486218853164),
708
+ new Grad4( 0.15296486218853164, -0.7504883828755602, 0.5029860367700724, -0.4004672082940195),
709
+ new Grad4( 0.08164729285680945, -0.8828161875373585, 0.4553054119602712, 0.08164729285680945),
710
+ new Grad4(-0.08164729285680945, -0.4553054119602712, 0.8828161875373585, -0.08164729285680945),
711
+ new Grad4(-0.15296486218853164, -0.5029860367700724, 0.7504883828755602, 0.4004672082940195),
712
+ new Grad4( 0.4004672082940195, -0.5029860367700724, 0.7504883828755602, -0.15296486218853164),
713
+ new Grad4( 0.3239847771997537, -0.5794684678643381, 0.6740059517812944, 0.3239847771997537),
714
+ new Grad4(-0.3239847771997537, -0.3239847771997537, 0.5794684678643381, -0.6740059517812944),
715
+ new Grad4(-0.4004672082940195, 0.15296486218853164, 0.5029860367700724, -0.7504883828755602),
716
+ new Grad4( 0.15296486218853164, -0.4004672082940195, 0.5029860367700724, -0.7504883828755602),
717
+ new Grad4( 0.08164729285680945, 0.08164729285680945, 0.4553054119602712, -0.8828161875373585),
718
+ new Grad4(-0.08164729285680945, -0.08164729285680945, 0.8828161875373585, -0.4553054119602712),
719
+ new Grad4(-0.15296486218853164, 0.4004672082940195, 0.7504883828755602, -0.5029860367700724),
720
+ new Grad4( 0.4004672082940195, -0.15296486218853164, 0.7504883828755602, -0.5029860367700724),
721
+ new Grad4( 0.3239847771997537, 0.3239847771997537, 0.6740059517812944, -0.5794684678643381),
722
+ new Grad4(-0.6740059517812944, 0.5794684678643381, -0.3239847771997537, -0.3239847771997537),
723
+ new Grad4(-0.7504883828755602, 0.5029860367700724, -0.4004672082940195, 0.15296486218853164),
724
+ new Grad4(-0.7504883828755602, 0.5029860367700724, 0.15296486218853164, -0.4004672082940195),
725
+ new Grad4(-0.8828161875373585, 0.4553054119602712, 0.08164729285680945, 0.08164729285680945),
726
+ new Grad4(-0.4553054119602712, 0.8828161875373585, -0.08164729285680945, -0.08164729285680945),
727
+ new Grad4(-0.5029860367700724, 0.7504883828755602, -0.15296486218853164, 0.4004672082940195),
728
+ new Grad4(-0.5029860367700724, 0.7504883828755602, 0.4004672082940195, -0.15296486218853164),
729
+ new Grad4(-0.5794684678643381, 0.6740059517812944, 0.3239847771997537, 0.3239847771997537),
730
+ new Grad4(-0.3239847771997537, 0.5794684678643381, -0.6740059517812944, -0.3239847771997537),
731
+ new Grad4(-0.4004672082940195, 0.5029860367700724, -0.7504883828755602, 0.15296486218853164),
732
+ new Grad4( 0.15296486218853164, 0.5029860367700724, -0.7504883828755602, -0.4004672082940195),
733
+ new Grad4( 0.08164729285680945, 0.4553054119602712, -0.8828161875373585, 0.08164729285680945),
734
+ new Grad4(-0.08164729285680945, 0.8828161875373585, -0.4553054119602712, -0.08164729285680945),
735
+ new Grad4(-0.15296486218853164, 0.7504883828755602, -0.5029860367700724, 0.4004672082940195),
736
+ new Grad4( 0.4004672082940195, 0.7504883828755602, -0.5029860367700724, -0.15296486218853164),
737
+ new Grad4( 0.3239847771997537, 0.6740059517812944, -0.5794684678643381, 0.3239847771997537),
738
+ new Grad4(-0.3239847771997537, 0.5794684678643381, -0.3239847771997537, -0.6740059517812944),
739
+ new Grad4(-0.4004672082940195, 0.5029860367700724, 0.15296486218853164, -0.7504883828755602),
740
+ new Grad4( 0.15296486218853164, 0.5029860367700724, -0.4004672082940195, -0.7504883828755602),
741
+ new Grad4( 0.08164729285680945, 0.4553054119602712, 0.08164729285680945, -0.8828161875373585),
742
+ new Grad4(-0.08164729285680945, 0.8828161875373585, -0.08164729285680945, -0.4553054119602712),
743
+ new Grad4(-0.15296486218853164, 0.7504883828755602, 0.4004672082940195, -0.5029860367700724),
744
+ new Grad4( 0.4004672082940195, 0.7504883828755602, -0.15296486218853164, -0.5029860367700724),
745
+ new Grad4( 0.3239847771997537, 0.6740059517812944, 0.3239847771997537, -0.5794684678643381),
746
+ new Grad4( 0.5794684678643381, -0.6740059517812944, -0.3239847771997537, -0.3239847771997537),
747
+ new Grad4( 0.5029860367700724, -0.7504883828755602, -0.4004672082940195, 0.15296486218853164),
748
+ new Grad4( 0.5029860367700724, -0.7504883828755602, 0.15296486218853164, -0.4004672082940195),
749
+ new Grad4( 0.4553054119602712, -0.8828161875373585, 0.08164729285680945, 0.08164729285680945),
750
+ new Grad4( 0.8828161875373585, -0.4553054119602712, -0.08164729285680945, -0.08164729285680945),
751
+ new Grad4( 0.7504883828755602, -0.5029860367700724, -0.15296486218853164, 0.4004672082940195),
752
+ new Grad4( 0.7504883828755602, -0.5029860367700724, 0.4004672082940195, -0.15296486218853164),
753
+ new Grad4( 0.6740059517812944, -0.5794684678643381, 0.3239847771997537, 0.3239847771997537),
754
+ new Grad4( 0.5794684678643381, -0.3239847771997537, -0.6740059517812944, -0.3239847771997537),
755
+ new Grad4( 0.5029860367700724, -0.4004672082940195, -0.7504883828755602, 0.15296486218853164),
756
+ new Grad4( 0.5029860367700724, 0.15296486218853164, -0.7504883828755602, -0.4004672082940195),
757
+ new Grad4( 0.4553054119602712, 0.08164729285680945, -0.8828161875373585, 0.08164729285680945),
758
+ new Grad4( 0.8828161875373585, -0.08164729285680945, -0.4553054119602712, -0.08164729285680945),
759
+ new Grad4( 0.7504883828755602, -0.15296486218853164, -0.5029860367700724, 0.4004672082940195),
760
+ new Grad4( 0.7504883828755602, 0.4004672082940195, -0.5029860367700724, -0.15296486218853164),
761
+ new Grad4( 0.6740059517812944, 0.3239847771997537, -0.5794684678643381, 0.3239847771997537),
762
+ new Grad4( 0.5794684678643381, -0.3239847771997537, -0.3239847771997537, -0.6740059517812944),
763
+ new Grad4( 0.5029860367700724, -0.4004672082940195, 0.15296486218853164, -0.7504883828755602),
764
+ new Grad4( 0.5029860367700724, 0.15296486218853164, -0.4004672082940195, -0.7504883828755602),
765
+ new Grad4( 0.4553054119602712, 0.08164729285680945, 0.08164729285680945, -0.8828161875373585),
766
+ new Grad4( 0.8828161875373585, -0.08164729285680945, -0.08164729285680945, -0.4553054119602712),
767
+ new Grad4( 0.7504883828755602, -0.15296486218853164, 0.4004672082940195, -0.5029860367700724),
768
+ new Grad4( 0.7504883828755602, 0.4004672082940195, -0.15296486218853164, -0.5029860367700724),
769
+ new Grad4( 0.6740059517812944, 0.3239847771997537, 0.3239847771997537, -0.5794684678643381),
770
+ new Grad4( 0.03381941603233842, 0.03381941603233842, 0.03381941603233842, 0.9982828964265062),
771
+ new Grad4(-0.044802370851755174, -0.044802370851755174, 0.508629699630796, 0.8586508742123365),
772
+ new Grad4(-0.044802370851755174, 0.508629699630796, -0.044802370851755174, 0.8586508742123365),
773
+ new Grad4(-0.12128480194602098, 0.4321472685365301, 0.4321472685365301, 0.7821684431180708),
774
+ new Grad4( 0.508629699630796, -0.044802370851755174, -0.044802370851755174, 0.8586508742123365),
775
+ new Grad4( 0.4321472685365301, -0.12128480194602098, 0.4321472685365301, 0.7821684431180708),
776
+ new Grad4( 0.4321472685365301, 0.4321472685365301, -0.12128480194602098, 0.7821684431180708),
777
+ new Grad4( 0.37968289875261624, 0.37968289875261624, 0.37968289875261624, 0.753341017856078),
778
+ new Grad4( 0.03381941603233842, 0.03381941603233842, 0.9982828964265062, 0.03381941603233842),
779
+ new Grad4(-0.044802370851755174, 0.044802370851755174, 0.8586508742123365, 0.508629699630796),
780
+ new Grad4(-0.044802370851755174, 0.508629699630796, 0.8586508742123365, -0.044802370851755174),
781
+ new Grad4(-0.12128480194602098, 0.4321472685365301, 0.7821684431180708, 0.4321472685365301),
782
+ new Grad4( 0.508629699630796, -0.044802370851755174, 0.8586508742123365, -0.044802370851755174),
783
+ new Grad4( 0.4321472685365301, -0.12128480194602098, 0.7821684431180708, 0.4321472685365301),
784
+ new Grad4( 0.4321472685365301, 0.4321472685365301, 0.7821684431180708, -0.12128480194602098),
785
+ new Grad4( 0.37968289875261624, 0.37968289875261624, 0.753341017856078, 0.37968289875261624),
786
+ new Grad4( 0.03381941603233842, 0.9982828964265062, 0.03381941603233842, 0.03381941603233842),
787
+ new Grad4(-0.044802370851755174, 0.8586508742123365, -0.044802370851755174, 0.508629699630796),
788
+ new Grad4(-0.044802370851755174, 0.8586508742123365, 0.508629699630796, -0.044802370851755174),
789
+ new Grad4(-0.12128480194602098, 0.7821684431180708, 0.4321472685365301, 0.4321472685365301),
790
+ new Grad4( 0.508629699630796, 0.8586508742123365, -0.044802370851755174, -0.044802370851755174),
791
+ new Grad4( 0.4321472685365301, 0.7821684431180708, -0.12128480194602098, 0.4321472685365301),
792
+ new Grad4( 0.4321472685365301, 0.7821684431180708, 0.4321472685365301, -0.12128480194602098),
793
+ new Grad4( 0.37968289875261624, 0.753341017856078, 0.37968289875261624, 0.37968289875261624),
794
+ new Grad4( 0.9982828964265062, 0.03381941603233842, 0.03381941603233842, 0.03381941603233842),
795
+ new Grad4( 0.8586508742123365, -0.044802370851755174, -0.044802370851755174, 0.508629699630796),
796
+ new Grad4( 0.8586508742123365, -0.044802370851755174, 0.508629699630796, -0.044802370851755174),
797
+ new Grad4( 0.7821684431180708, -0.12128480194602098, 0.4321472685365301, 0.4321472685365301),
798
+ new Grad4( 0.8586508742123365, 0.508629699630796, -0.044802370851755174, -0.044802370851755174),
799
+ new Grad4( 0.7821684431180708, 0.4321472685365301, -0.12128480194602098, 0.4321472685365301),
800
+ new Grad4( 0.7821684431180708, 0.4321472685365301, 0.4321472685365301, -0.12128480194602098),
801
+ new Grad4( 0.753341017856078, 0.37968289875261624, 0.37968289875261624, 0.37968289875261624)
802
+ };
803
+ for (Grad4 grad41 : grad4) {
804
+ grad41.dx /= N4;
805
+ grad41.dy /= N4;
806
+ grad41.dz /= N4;
807
+ grad41.dw /= N4;
413
808
  }
414
- }
415
-
416
- return value;
417
- }
418
-
419
- /*
420
- * Utility
421
- */
422
- private static int fastFloor(double x) {
423
- int xi = (int) x;
424
- return x < xi ? xi - 1 : xi;
425
- }
426
-
427
- /*
428
- * Definitions
429
- */
430
- private static final LatticePoint2D[] LOOKUP_2D;
431
- private static final LatticePoint3D[] LOOKUP_3D;
432
- private static final LatticePoint4D[] VERTICES_4D;
433
-
434
- static {
435
- LOOKUP_2D = new LatticePoint2D[4];
436
- LOOKUP_3D = new LatticePoint3D[8];
437
- VERTICES_4D = new LatticePoint4D[16];
438
-
439
- LOOKUP_2D[0] = new LatticePoint2D(1, 0);
440
- LOOKUP_2D[1] = new LatticePoint2D(0, 0);
441
- LOOKUP_2D[2] = new LatticePoint2D(1, 1);
442
- LOOKUP_2D[3] = new LatticePoint2D(0, 1);
443
-
444
- for (int i = 0; i < 8; i++) {
445
- int i1, j1, k1, i2, j2, k2;
446
- i1 = (i) & 1;
447
- j1 = (i >> 1) & 1;
448
- k1 = (i >> 2) & 1;
449
- i2 = i1 ^ 1;
450
- j2 = j1 ^ 1;
451
- k2 = k1 ^ 1;
452
-
453
- // The two points within this octant, one from each of the two cubic half-lattices.
454
- LatticePoint3D c0 = new LatticePoint3D(i1, j1, k1, 0);
455
- LatticePoint3D c1 = new LatticePoint3D(i1 + i2, j1 + j2, k1 + k2, 1);
456
-
457
- // Each single step away on the first half-lattice.
458
- LatticePoint3D c2 = new LatticePoint3D(i1 ^ 1, j1, k1, 0);
459
- LatticePoint3D c3 = new LatticePoint3D(i1, j1 ^ 1, k1, 0);
460
- LatticePoint3D c4 = new LatticePoint3D(i1, j1, k1 ^ 1, 0);
461
-
462
- // Each single step away on the second half-lattice.
463
- LatticePoint3D c5 = new LatticePoint3D(i1 + (i2 ^ 1), j1 + j2, k1 + k2, 1);
464
- LatticePoint3D c6 = new LatticePoint3D(i1 + i2, j1 + (j2 ^ 1), k1 + k2, 1);
465
- LatticePoint3D c7 = new LatticePoint3D(i1 + i2, j1 + j2, k1 + (k2 ^ 1), 1);
466
-
467
- // First two are guaranteed.
468
- c0.nextOnFailure = c0.nextOnSuccess = c1;
469
- c1.nextOnFailure = c1.nextOnSuccess = c2;
470
-
471
- // Once we find one on the first half-lattice, the rest are out.
472
- // In addition, knowing c2 rules out c5.
473
- c2.nextOnFailure = c3;
474
- c2.nextOnSuccess = c6;
475
- c3.nextOnFailure = c4;
476
- c3.nextOnSuccess = c5;
477
- c4.nextOnFailure = c4.nextOnSuccess = c5;
478
-
479
- // Once we find one on the second half-lattice, the rest are out.
480
- c5.nextOnFailure = c6;
481
- c5.nextOnSuccess = null;
482
- c6.nextOnFailure = c7;
483
- c6.nextOnSuccess = null;
484
- c7.nextOnFailure = c7.nextOnSuccess = null;
485
-
486
- LOOKUP_3D[i] = c0;
487
- }
488
-
489
- for (int i = 0; i < 16; i++) {
490
- VERTICES_4D[i] = new LatticePoint4D((i) & 1, (i >> 1) & 1, (i >> 2) & 1, (i >> 3) & 1);
491
- }
492
- }
493
-
494
- @Override
495
- public float noise(float x, float y, float z) {
496
- return (float)noise3_Classic(x, y, z);
497
- }
498
-
499
- @Override
500
- public float noise(float x, float y, float z, float w) {
501
- return (float)noise4_Classic(x, y, z, w);
502
- }
503
-
504
- @Override
505
- public void noiseMode(NoiseMode mode) {
506
-
507
- }
508
-
509
- @Override
510
- public void noiseSeed(long seed) {
511
- }
512
-
513
- private static class LatticePoint2D {
514
-
515
- int xsv, ysv;
516
- double dx, dy;
517
-
518
- public LatticePoint2D(int xsv, int ysv) {
519
- this.xsv = xsv;
520
- this.ysv = ysv;
521
- double ssv = (xsv + ysv) * -0.211324865405187;
522
- this.dx = -xsv - ssv;
523
- this.dy = -ysv - ssv;
524
- }
525
- }
526
-
527
- private static class LatticePoint3D {
528
-
529
- public double dxr, dyr, dzr;
530
- public int xrv, yrv, zrv;
531
- LatticePoint3D nextOnFailure, nextOnSuccess;
532
-
533
- public LatticePoint3D(int xrv, int yrv, int zrv, int lattice) {
534
- this.dxr = -xrv + lattice * 0.5;
535
- this.dyr = -yrv + lattice * 0.5;
536
- this.dzr = -zrv + lattice * 0.5;
537
- this.xrv = xrv + lattice * 1024;
538
- this.yrv = yrv + lattice * 1024;
539
- this.zrv = zrv + lattice * 1024;
540
- }
541
- }
542
-
543
- private static class LatticePoint4D {
544
-
545
- int xsv, ysv, zsv, wsv;
546
- double dx, dy, dz, dw;
547
- double xsi, ysi, zsi, wsi;
548
- double ssiDelta;
549
-
550
- public LatticePoint4D(int xsv, int ysv, int zsv, int wsv) {
551
- this.xsv = xsv + 409;
552
- this.ysv = ysv + 409;
553
- this.zsv = zsv + 409;
554
- this.wsv = wsv + 409;
555
- double ssv = (xsv + ysv + zsv + wsv) * 0.309016994374947;
556
- this.dx = -xsv - ssv;
557
- this.dy = -ysv - ssv;
558
- this.dz = -zsv - ssv;
559
- this.dw = -wsv - ssv;
560
- this.xsi = xsi = 0.2 - xsv;
561
- this.ysi = ysi = 0.2 - ysv;
562
- this.zsi = zsi = 0.2 - zsv;
563
- this.wsi = wsi = 0.2 - wsv;
564
- this.ssiDelta = (0.8 - xsv - ysv - zsv - wsv) * 0.309016994374947;
565
- }
566
- }
567
-
568
- /*
569
- * Gradients
570
- */
571
- private static class Grad2 {
572
-
573
- double dx, dy;
574
-
575
- public Grad2(double dx, double dy) {
576
- this.dx = dx;
577
- this.dy = dy;
578
- }
579
- }
580
-
581
- private static class Grad3 {
582
-
583
- double dx, dy, dz;
584
-
585
- public Grad3(double dx, double dy, double dz) {
586
- this.dx = dx;
587
- this.dy = dy;
588
- this.dz = dz;
589
- }
590
- }
591
-
592
- private static class Grad4 {
593
-
594
- double dx, dy, dz, dw;
595
-
596
- public Grad4(double dx, double dy, double dz, double dw) {
597
- this.dx = dx;
598
- this.dy = dy;
599
- this.dz = dz;
600
- this.dw = dw;
601
- }
602
- }
603
-
604
- private static final double N2 = 0.01001634121365712;
605
- private static final double N3 = 0.030485933181293584;
606
- private static final double N4 = 0.009202377986303158;
607
- private static final Grad2[] GRADIENTS_2D;
608
- private static final Grad3[] GRADIENTS_3D;
609
- private static final Grad4[] GRADIENTS_4D;
610
-
611
- static {
612
-
613
- GRADIENTS_2D = new Grad2[PSIZE];
614
- Grad2[] grad2 = {
615
- new Grad2(0.130526192220052, 0.99144486137381),
616
- new Grad2(0.38268343236509, 0.923879532511287),
617
- new Grad2(0.608761429008721, 0.793353340291235),
618
- new Grad2(0.793353340291235, 0.608761429008721),
619
- new Grad2(0.923879532511287, 0.38268343236509),
620
- new Grad2(0.99144486137381, 0.130526192220051),
621
- new Grad2(0.99144486137381, -0.130526192220051),
622
- new Grad2(0.923879532511287, -0.38268343236509),
623
- new Grad2(0.793353340291235, -0.60876142900872),
624
- new Grad2(0.608761429008721, -0.793353340291235),
625
- new Grad2(0.38268343236509, -0.923879532511287),
626
- new Grad2(0.130526192220052, -0.99144486137381),
627
- new Grad2(-0.130526192220052, -0.99144486137381),
628
- new Grad2(-0.38268343236509, -0.923879532511287),
629
- new Grad2(-0.608761429008721, -0.793353340291235),
630
- new Grad2(-0.793353340291235, -0.608761429008721),
631
- new Grad2(-0.923879532511287, -0.38268343236509),
632
- new Grad2(-0.99144486137381, -0.130526192220052),
633
- new Grad2(-0.99144486137381, 0.130526192220051),
634
- new Grad2(-0.923879532511287, 0.38268343236509),
635
- new Grad2(-0.793353340291235, 0.608761429008721),
636
- new Grad2(-0.608761429008721, 0.793353340291235),
637
- new Grad2(-0.38268343236509, 0.923879532511287),
638
- new Grad2(-0.130526192220052, 0.99144486137381)
639
- };
640
- for (Grad2 grad21 : grad2) {
641
- grad21.dx /= N2;
642
- grad21.dy /= N2;
643
- }
644
- for (int i = 0; i < PSIZE; i++) {
645
- GRADIENTS_2D[i] = grad2[i % grad2.length];
646
- }
647
-
648
- GRADIENTS_3D = new Grad3[PSIZE];
649
- Grad3[] grad3 = {
650
- new Grad3(-2.22474487139, -2.22474487139, -1.0),
651
- new Grad3(-2.22474487139, -2.22474487139, 1.0),
652
- new Grad3(-3.0862664687972017, -1.1721513422464978, 0.0),
653
- new Grad3(-1.1721513422464978, -3.0862664687972017, 0.0),
654
- new Grad3(-2.22474487139, -1.0, -2.22474487139),
655
- new Grad3(-2.22474487139, 1.0, -2.22474487139),
656
- new Grad3(-1.1721513422464978, 0.0, -3.0862664687972017),
657
- new Grad3(-3.0862664687972017, 0.0, -1.1721513422464978),
658
- new Grad3(-2.22474487139, -1.0, 2.22474487139),
659
- new Grad3(-2.22474487139, 1.0, 2.22474487139),
660
- new Grad3(-3.0862664687972017, 0.0, 1.1721513422464978),
661
- new Grad3(-1.1721513422464978, 0.0, 3.0862664687972017),
662
- new Grad3(-2.22474487139, 2.22474487139, -1.0),
663
- new Grad3(-2.22474487139, 2.22474487139, 1.0),
664
- new Grad3(-1.1721513422464978, 3.0862664687972017, 0.0),
665
- new Grad3(-3.0862664687972017, 1.1721513422464978, 0.0),
666
- new Grad3(-1.0, -2.22474487139, -2.22474487139),
667
- new Grad3(1.0, -2.22474487139, -2.22474487139),
668
- new Grad3(0.0, -3.0862664687972017, -1.1721513422464978),
669
- new Grad3(0.0, -1.1721513422464978, -3.0862664687972017),
670
- new Grad3(-1.0, -2.22474487139, 2.22474487139),
671
- new Grad3(1.0, -2.22474487139, 2.22474487139),
672
- new Grad3(0.0, -1.1721513422464978, 3.0862664687972017),
673
- new Grad3(0.0, -3.0862664687972017, 1.1721513422464978),
674
- new Grad3(-1.0, 2.22474487139, -2.22474487139),
675
- new Grad3(1.0, 2.22474487139, -2.22474487139),
676
- new Grad3(0.0, 1.1721513422464978, -3.0862664687972017),
677
- new Grad3(0.0, 3.0862664687972017, -1.1721513422464978),
678
- new Grad3(-1.0, 2.22474487139, 2.22474487139),
679
- new Grad3(1.0, 2.22474487139, 2.22474487139),
680
- new Grad3(0.0, 3.0862664687972017, 1.1721513422464978),
681
- new Grad3(0.0, 1.1721513422464978, 3.0862664687972017),
682
- new Grad3(2.22474487139, -2.22474487139, -1.0),
683
- new Grad3(2.22474487139, -2.22474487139, 1.0),
684
- new Grad3(1.1721513422464978, -3.0862664687972017, 0.0),
685
- new Grad3(3.0862664687972017, -1.1721513422464978, 0.0),
686
- new Grad3(2.22474487139, -1.0, -2.22474487139),
687
- new Grad3(2.22474487139, 1.0, -2.22474487139),
688
- new Grad3(3.0862664687972017, 0.0, -1.1721513422464978),
689
- new Grad3(1.1721513422464978, 0.0, -3.0862664687972017),
690
- new Grad3(2.22474487139, -1.0, 2.22474487139),
691
- new Grad3(2.22474487139, 1.0, 2.22474487139),
692
- new Grad3(1.1721513422464978, 0.0, 3.0862664687972017),
693
- new Grad3(3.0862664687972017, 0.0, 1.1721513422464978),
694
- new Grad3(2.22474487139, 2.22474487139, -1.0),
695
- new Grad3(2.22474487139, 2.22474487139, 1.0),
696
- new Grad3(3.0862664687972017, 1.1721513422464978, 0.0),
697
- new Grad3(1.1721513422464978, 3.0862664687972017, 0.0)
698
- };
699
- for (Grad3 grad31 : grad3) {
700
- grad31.dx /= N3;
701
- grad31.dy /= N3;
702
- grad31.dz /= N3;
703
- }
704
- for (int i = 0; i < PSIZE; i++) {
705
- GRADIENTS_3D[i] = grad3[i % grad3.length];
706
- }
707
-
708
- GRADIENTS_4D = new Grad4[PSIZE];
709
- Grad4[] grad4 = {
710
- new Grad4(-0.753341017856078, -0.37968289875261624, -0.37968289875261624, -0.37968289875261624),
711
- new Grad4(-0.7821684431180708, -0.4321472685365301, -0.4321472685365301, 0.12128480194602098),
712
- new Grad4(-0.7821684431180708, -0.4321472685365301, 0.12128480194602098, -0.4321472685365301),
713
- new Grad4(-0.7821684431180708, 0.12128480194602098, -0.4321472685365301, -0.4321472685365301),
714
- new Grad4(-0.8586508742123365, -0.508629699630796, 0.044802370851755174, 0.044802370851755174),
715
- new Grad4(-0.8586508742123365, 0.044802370851755174, -0.508629699630796, 0.044802370851755174),
716
- new Grad4(-0.8586508742123365, 0.044802370851755174, 0.044802370851755174, -0.508629699630796),
717
- new Grad4(-0.9982828964265062, -0.03381941603233842, -0.03381941603233842, -0.03381941603233842),
718
- new Grad4(-0.37968289875261624, -0.753341017856078, -0.37968289875261624, -0.37968289875261624),
719
- new Grad4(-0.4321472685365301, -0.7821684431180708, -0.4321472685365301, 0.12128480194602098),
720
- new Grad4(-0.4321472685365301, -0.7821684431180708, 0.12128480194602098, -0.4321472685365301),
721
- new Grad4(0.12128480194602098, -0.7821684431180708, -0.4321472685365301, -0.4321472685365301),
722
- new Grad4(-0.508629699630796, -0.8586508742123365, 0.044802370851755174, 0.044802370851755174),
723
- new Grad4(0.044802370851755174, -0.8586508742123365, -0.508629699630796, 0.044802370851755174),
724
- new Grad4(0.044802370851755174, -0.8586508742123365, 0.044802370851755174, -0.508629699630796),
725
- new Grad4(-0.03381941603233842, -0.9982828964265062, -0.03381941603233842, -0.03381941603233842),
726
- new Grad4(-0.37968289875261624, -0.37968289875261624, -0.753341017856078, -0.37968289875261624),
727
- new Grad4(-0.4321472685365301, -0.4321472685365301, -0.7821684431180708, 0.12128480194602098),
728
- new Grad4(-0.4321472685365301, 0.12128480194602098, -0.7821684431180708, -0.4321472685365301),
729
- new Grad4(0.12128480194602098, -0.4321472685365301, -0.7821684431180708, -0.4321472685365301),
730
- new Grad4(-0.508629699630796, 0.044802370851755174, -0.8586508742123365, 0.044802370851755174),
731
- new Grad4(0.044802370851755174, -0.508629699630796, -0.8586508742123365, 0.044802370851755174),
732
- new Grad4(0.044802370851755174, 0.044802370851755174, -0.8586508742123365, -0.508629699630796),
733
- new Grad4(-0.03381941603233842, -0.03381941603233842, -0.9982828964265062, -0.03381941603233842),
734
- new Grad4(-0.37968289875261624, -0.37968289875261624, -0.37968289875261624, -0.753341017856078),
735
- new Grad4(-0.4321472685365301, -0.4321472685365301, 0.12128480194602098, -0.7821684431180708),
736
- new Grad4(-0.4321472685365301, 0.12128480194602098, -0.4321472685365301, -0.7821684431180708),
737
- new Grad4(0.12128480194602098, -0.4321472685365301, -0.4321472685365301, -0.7821684431180708),
738
- new Grad4(-0.508629699630796, 0.044802370851755174, 0.044802370851755174, -0.8586508742123365),
739
- new Grad4(0.044802370851755174, -0.508629699630796, 0.044802370851755174, -0.8586508742123365),
740
- new Grad4(0.044802370851755174, 0.044802370851755174, -0.508629699630796, -0.8586508742123365),
741
- new Grad4(-0.03381941603233842, -0.03381941603233842, -0.03381941603233842, -0.9982828964265062),
742
- new Grad4(-0.6740059517812944, -0.3239847771997537, -0.3239847771997537, 0.5794684678643381),
743
- new Grad4(-0.7504883828755602, -0.4004672082940195, 0.15296486218853164, 0.5029860367700724),
744
- new Grad4(-0.7504883828755602, 0.15296486218853164, -0.4004672082940195, 0.5029860367700724),
745
- new Grad4(-0.8828161875373585, 0.08164729285680945, 0.08164729285680945, 0.4553054119602712),
746
- new Grad4(-0.4553054119602712, -0.08164729285680945, -0.08164729285680945, 0.8828161875373585),
747
- new Grad4(-0.5029860367700724, -0.15296486218853164, 0.4004672082940195, 0.7504883828755602),
748
- new Grad4(-0.5029860367700724, 0.4004672082940195, -0.15296486218853164, 0.7504883828755602),
749
- new Grad4(-0.5794684678643381, 0.3239847771997537, 0.3239847771997537, 0.6740059517812944),
750
- new Grad4(-0.3239847771997537, -0.6740059517812944, -0.3239847771997537, 0.5794684678643381),
751
- new Grad4(-0.4004672082940195, -0.7504883828755602, 0.15296486218853164, 0.5029860367700724),
752
- new Grad4(0.15296486218853164, -0.7504883828755602, -0.4004672082940195, 0.5029860367700724),
753
- new Grad4(0.08164729285680945, -0.8828161875373585, 0.08164729285680945, 0.4553054119602712),
754
- new Grad4(-0.08164729285680945, -0.4553054119602712, -0.08164729285680945, 0.8828161875373585),
755
- new Grad4(-0.15296486218853164, -0.5029860367700724, 0.4004672082940195, 0.7504883828755602),
756
- new Grad4(0.4004672082940195, -0.5029860367700724, -0.15296486218853164, 0.7504883828755602),
757
- new Grad4(0.3239847771997537, -0.5794684678643381, 0.3239847771997537, 0.6740059517812944),
758
- new Grad4(-0.3239847771997537, -0.3239847771997537, -0.6740059517812944, 0.5794684678643381),
759
- new Grad4(-0.4004672082940195, 0.15296486218853164, -0.7504883828755602, 0.5029860367700724),
760
- new Grad4(0.15296486218853164, -0.4004672082940195, -0.7504883828755602, 0.5029860367700724),
761
- new Grad4(0.08164729285680945, 0.08164729285680945, -0.8828161875373585, 0.4553054119602712),
762
- new Grad4(-0.08164729285680945, -0.08164729285680945, -0.4553054119602712, 0.8828161875373585),
763
- new Grad4(-0.15296486218853164, 0.4004672082940195, -0.5029860367700724, 0.7504883828755602),
764
- new Grad4(0.4004672082940195, -0.15296486218853164, -0.5029860367700724, 0.7504883828755602),
765
- new Grad4(0.3239847771997537, 0.3239847771997537, -0.5794684678643381, 0.6740059517812944),
766
- new Grad4(-0.6740059517812944, -0.3239847771997537, 0.5794684678643381, -0.3239847771997537),
767
- new Grad4(-0.7504883828755602, -0.4004672082940195, 0.5029860367700724, 0.15296486218853164),
768
- new Grad4(-0.7504883828755602, 0.15296486218853164, 0.5029860367700724, -0.4004672082940195),
769
- new Grad4(-0.8828161875373585, 0.08164729285680945, 0.4553054119602712, 0.08164729285680945),
770
- new Grad4(-0.4553054119602712, -0.08164729285680945, 0.8828161875373585, -0.08164729285680945),
771
- new Grad4(-0.5029860367700724, -0.15296486218853164, 0.7504883828755602, 0.4004672082940195),
772
- new Grad4(-0.5029860367700724, 0.4004672082940195, 0.7504883828755602, -0.15296486218853164),
773
- new Grad4(-0.5794684678643381, 0.3239847771997537, 0.6740059517812944, 0.3239847771997537),
774
- new Grad4(-0.3239847771997537, -0.6740059517812944, 0.5794684678643381, -0.3239847771997537),
775
- new Grad4(-0.4004672082940195, -0.7504883828755602, 0.5029860367700724, 0.15296486218853164),
776
- new Grad4(0.15296486218853164, -0.7504883828755602, 0.5029860367700724, -0.4004672082940195),
777
- new Grad4(0.08164729285680945, -0.8828161875373585, 0.4553054119602712, 0.08164729285680945),
778
- new Grad4(-0.08164729285680945, -0.4553054119602712, 0.8828161875373585, -0.08164729285680945),
779
- new Grad4(-0.15296486218853164, -0.5029860367700724, 0.7504883828755602, 0.4004672082940195),
780
- new Grad4(0.4004672082940195, -0.5029860367700724, 0.7504883828755602, -0.15296486218853164),
781
- new Grad4(0.3239847771997537, -0.5794684678643381, 0.6740059517812944, 0.3239847771997537),
782
- new Grad4(-0.3239847771997537, -0.3239847771997537, 0.5794684678643381, -0.6740059517812944),
783
- new Grad4(-0.4004672082940195, 0.15296486218853164, 0.5029860367700724, -0.7504883828755602),
784
- new Grad4(0.15296486218853164, -0.4004672082940195, 0.5029860367700724, -0.7504883828755602),
785
- new Grad4(0.08164729285680945, 0.08164729285680945, 0.4553054119602712, -0.8828161875373585),
786
- new Grad4(-0.08164729285680945, -0.08164729285680945, 0.8828161875373585, -0.4553054119602712),
787
- new Grad4(-0.15296486218853164, 0.4004672082940195, 0.7504883828755602, -0.5029860367700724),
788
- new Grad4(0.4004672082940195, -0.15296486218853164, 0.7504883828755602, -0.5029860367700724),
789
- new Grad4(0.3239847771997537, 0.3239847771997537, 0.6740059517812944, -0.5794684678643381),
790
- new Grad4(-0.6740059517812944, 0.5794684678643381, -0.3239847771997537, -0.3239847771997537),
791
- new Grad4(-0.7504883828755602, 0.5029860367700724, -0.4004672082940195, 0.15296486218853164),
792
- new Grad4(-0.7504883828755602, 0.5029860367700724, 0.15296486218853164, -0.4004672082940195),
793
- new Grad4(-0.8828161875373585, 0.4553054119602712, 0.08164729285680945, 0.08164729285680945),
794
- new Grad4(-0.4553054119602712, 0.8828161875373585, -0.08164729285680945, -0.08164729285680945),
795
- new Grad4(-0.5029860367700724, 0.7504883828755602, -0.15296486218853164, 0.4004672082940195),
796
- new Grad4(-0.5029860367700724, 0.7504883828755602, 0.4004672082940195, -0.15296486218853164),
797
- new Grad4(-0.5794684678643381, 0.6740059517812944, 0.3239847771997537, 0.3239847771997537),
798
- new Grad4(-0.3239847771997537, 0.5794684678643381, -0.6740059517812944, -0.3239847771997537),
799
- new Grad4(-0.4004672082940195, 0.5029860367700724, -0.7504883828755602, 0.15296486218853164),
800
- new Grad4(0.15296486218853164, 0.5029860367700724, -0.7504883828755602, -0.4004672082940195),
801
- new Grad4(0.08164729285680945, 0.4553054119602712, -0.8828161875373585, 0.08164729285680945),
802
- new Grad4(-0.08164729285680945, 0.8828161875373585, -0.4553054119602712, -0.08164729285680945),
803
- new Grad4(-0.15296486218853164, 0.7504883828755602, -0.5029860367700724, 0.4004672082940195),
804
- new Grad4(0.4004672082940195, 0.7504883828755602, -0.5029860367700724, -0.15296486218853164),
805
- new Grad4(0.3239847771997537, 0.6740059517812944, -0.5794684678643381, 0.3239847771997537),
806
- new Grad4(-0.3239847771997537, 0.5794684678643381, -0.3239847771997537, -0.6740059517812944),
807
- new Grad4(-0.4004672082940195, 0.5029860367700724, 0.15296486218853164, -0.7504883828755602),
808
- new Grad4(0.15296486218853164, 0.5029860367700724, -0.4004672082940195, -0.7504883828755602),
809
- new Grad4(0.08164729285680945, 0.4553054119602712, 0.08164729285680945, -0.8828161875373585),
810
- new Grad4(-0.08164729285680945, 0.8828161875373585, -0.08164729285680945, -0.4553054119602712),
811
- new Grad4(-0.15296486218853164, 0.7504883828755602, 0.4004672082940195, -0.5029860367700724),
812
- new Grad4(0.4004672082940195, 0.7504883828755602, -0.15296486218853164, -0.5029860367700724),
813
- new Grad4(0.3239847771997537, 0.6740059517812944, 0.3239847771997537, -0.5794684678643381),
814
- new Grad4(0.5794684678643381, -0.6740059517812944, -0.3239847771997537, -0.3239847771997537),
815
- new Grad4(0.5029860367700724, -0.7504883828755602, -0.4004672082940195, 0.15296486218853164),
816
- new Grad4(0.5029860367700724, -0.7504883828755602, 0.15296486218853164, -0.4004672082940195),
817
- new Grad4(0.4553054119602712, -0.8828161875373585, 0.08164729285680945, 0.08164729285680945),
818
- new Grad4(0.8828161875373585, -0.4553054119602712, -0.08164729285680945, -0.08164729285680945),
819
- new Grad4(0.7504883828755602, -0.5029860367700724, -0.15296486218853164, 0.4004672082940195),
820
- new Grad4(0.7504883828755602, -0.5029860367700724, 0.4004672082940195, -0.15296486218853164),
821
- new Grad4(0.6740059517812944, -0.5794684678643381, 0.3239847771997537, 0.3239847771997537),
822
- new Grad4(0.5794684678643381, -0.3239847771997537, -0.6740059517812944, -0.3239847771997537),
823
- new Grad4(0.5029860367700724, -0.4004672082940195, -0.7504883828755602, 0.15296486218853164),
824
- new Grad4(0.5029860367700724, 0.15296486218853164, -0.7504883828755602, -0.4004672082940195),
825
- new Grad4(0.4553054119602712, 0.08164729285680945, -0.8828161875373585, 0.08164729285680945),
826
- new Grad4(0.8828161875373585, -0.08164729285680945, -0.4553054119602712, -0.08164729285680945),
827
- new Grad4(0.7504883828755602, -0.15296486218853164, -0.5029860367700724, 0.4004672082940195),
828
- new Grad4(0.7504883828755602, 0.4004672082940195, -0.5029860367700724, -0.15296486218853164),
829
- new Grad4(0.6740059517812944, 0.3239847771997537, -0.5794684678643381, 0.3239847771997537),
830
- new Grad4(0.5794684678643381, -0.3239847771997537, -0.3239847771997537, -0.6740059517812944),
831
- new Grad4(0.5029860367700724, -0.4004672082940195, 0.15296486218853164, -0.7504883828755602),
832
- new Grad4(0.5029860367700724, 0.15296486218853164, -0.4004672082940195, -0.7504883828755602),
833
- new Grad4(0.4553054119602712, 0.08164729285680945, 0.08164729285680945, -0.8828161875373585),
834
- new Grad4(0.8828161875373585, -0.08164729285680945, -0.08164729285680945, -0.4553054119602712),
835
- new Grad4(0.7504883828755602, -0.15296486218853164, 0.4004672082940195, -0.5029860367700724),
836
- new Grad4(0.7504883828755602, 0.4004672082940195, -0.15296486218853164, -0.5029860367700724),
837
- new Grad4(0.6740059517812944, 0.3239847771997537, 0.3239847771997537, -0.5794684678643381),
838
- new Grad4(0.03381941603233842, 0.03381941603233842, 0.03381941603233842, 0.9982828964265062),
839
- new Grad4(-0.044802370851755174, -0.044802370851755174, 0.508629699630796, 0.8586508742123365),
840
- new Grad4(-0.044802370851755174, 0.508629699630796, -0.044802370851755174, 0.8586508742123365),
841
- new Grad4(-0.12128480194602098, 0.4321472685365301, 0.4321472685365301, 0.7821684431180708),
842
- new Grad4(0.508629699630796, -0.044802370851755174, -0.044802370851755174, 0.8586508742123365),
843
- new Grad4(0.4321472685365301, -0.12128480194602098, 0.4321472685365301, 0.7821684431180708),
844
- new Grad4(0.4321472685365301, 0.4321472685365301, -0.12128480194602098, 0.7821684431180708),
845
- new Grad4(0.37968289875261624, 0.37968289875261624, 0.37968289875261624, 0.753341017856078),
846
- new Grad4(0.03381941603233842, 0.03381941603233842, 0.9982828964265062, 0.03381941603233842),
847
- new Grad4(-0.044802370851755174, 0.044802370851755174, 0.8586508742123365, 0.508629699630796),
848
- new Grad4(-0.044802370851755174, 0.508629699630796, 0.8586508742123365, -0.044802370851755174),
849
- new Grad4(-0.12128480194602098, 0.4321472685365301, 0.7821684431180708, 0.4321472685365301),
850
- new Grad4(0.508629699630796, -0.044802370851755174, 0.8586508742123365, -0.044802370851755174),
851
- new Grad4(0.4321472685365301, -0.12128480194602098, 0.7821684431180708, 0.4321472685365301),
852
- new Grad4(0.4321472685365301, 0.4321472685365301, 0.7821684431180708, -0.12128480194602098),
853
- new Grad4(0.37968289875261624, 0.37968289875261624, 0.753341017856078, 0.37968289875261624),
854
- new Grad4(0.03381941603233842, 0.9982828964265062, 0.03381941603233842, 0.03381941603233842),
855
- new Grad4(-0.044802370851755174, 0.8586508742123365, -0.044802370851755174, 0.508629699630796),
856
- new Grad4(-0.044802370851755174, 0.8586508742123365, 0.508629699630796, -0.044802370851755174),
857
- new Grad4(-0.12128480194602098, 0.7821684431180708, 0.4321472685365301, 0.4321472685365301),
858
- new Grad4(0.508629699630796, 0.8586508742123365, -0.044802370851755174, -0.044802370851755174),
859
- new Grad4(0.4321472685365301, 0.7821684431180708, -0.12128480194602098, 0.4321472685365301),
860
- new Grad4(0.4321472685365301, 0.7821684431180708, 0.4321472685365301, -0.12128480194602098),
861
- new Grad4(0.37968289875261624, 0.753341017856078, 0.37968289875261624, 0.37968289875261624),
862
- new Grad4(0.9982828964265062, 0.03381941603233842, 0.03381941603233842, 0.03381941603233842),
863
- new Grad4(0.8586508742123365, -0.044802370851755174, -0.044802370851755174, 0.508629699630796),
864
- new Grad4(0.8586508742123365, -0.044802370851755174, 0.508629699630796, -0.044802370851755174),
865
- new Grad4(0.7821684431180708, -0.12128480194602098, 0.4321472685365301, 0.4321472685365301),
866
- new Grad4(0.8586508742123365, 0.508629699630796, -0.044802370851755174, -0.044802370851755174),
867
- new Grad4(0.7821684431180708, 0.4321472685365301, -0.12128480194602098, 0.4321472685365301),
868
- new Grad4(0.7821684431180708, 0.4321472685365301, 0.4321472685365301, -0.12128480194602098),
869
- new Grad4(0.753341017856078, 0.37968289875261624, 0.37968289875261624, 0.37968289875261624)
870
- };
871
- for (Grad4 grad41 : grad4) {
872
- grad41.dx /= N4;
873
- grad41.dy /= N4;
874
- grad41.dz /= N4;
875
- grad41.dw /= N4;
876
- }
877
- for (int i = 0; i < PSIZE; i++) {
878
- GRADIENTS_4D[i] = grad4[i % grad4.length];
879
- }
880
- }
809
+ for (int i = 0; i < PSIZE; i++) {
810
+ GRADIENTS_4D[i] = grad4[i % grad4.length];
811
+ }
812
+ }
881
813
  }