propane 3.10.0-java → 3.11.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/wrapper/maven-wrapper.properties +1 -1
  3. data/CHANGELOG.md +2 -0
  4. data/README.md +7 -7
  5. data/lib/propane/app.rb +2 -5
  6. data/lib/propane/helper_methods.rb +6 -6
  7. data/lib/propane/version.rb +1 -1
  8. data/lib/{propane-3.10.0.jar → propane-3.11.0.jar} +0 -0
  9. data/pom.rb +6 -6
  10. data/pom.xml +6 -6
  11. data/propane.gemspec +3 -3
  12. data/src/main/java/monkstone/noise/OpenSimplex2F.java +838 -737
  13. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +8 -13
  14. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +14 -28
  15. data/src/main/java/processing/awt/PImageAWT.java +6 -4
  16. data/src/main/java/processing/core/PApplet.java +71 -59
  17. data/src/main/java/processing/core/PImage.java +14 -14
  18. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13 -13
  19. data/src/main/java/processing/opengl/PShader.java +1 -6
  20. data/src/main/java/processing/opengl/PSurfaceJOGL.java +6 -6
  21. data/{lib/java/processing/opengl → src/main/resources}/cursors/arrow.png +0 -0
  22. data/{lib/java/processing/opengl → src/main/resources}/cursors/cross.png +0 -0
  23. data/{lib/java/processing/opengl → src/main/resources}/cursors/hand.png +0 -0
  24. data/{lib/java/processing/opengl → src/main/resources}/cursors/license.txt +0 -0
  25. data/{lib/java/processing/opengl → src/main/resources}/cursors/move.png +0 -0
  26. data/{lib/java/processing/opengl → src/main/resources}/cursors/text.png +0 -0
  27. data/{lib/java/processing/opengl → src/main/resources}/cursors/wait.png +0 -0
  28. data/{lib/java/processing/opengl → src/main/resources}/shaders/ColorFrag.glsl +0 -0
  29. data/{lib/java/processing/opengl → src/main/resources}/shaders/ColorVert.glsl +0 -0
  30. data/{lib/java/processing/opengl → src/main/resources}/shaders/LightFrag.glsl +0 -0
  31. data/{lib/java/processing/opengl → src/main/resources}/shaders/LightVert.glsl +0 -0
  32. data/{lib/java/processing/opengl → src/main/resources}/shaders/LineFrag.glsl +0 -0
  33. data/{lib/java/processing/opengl → src/main/resources}/shaders/LineVert.glsl +0 -0
  34. data/{lib/java/processing/opengl → src/main/resources}/shaders/MaskFrag.glsl +0 -0
  35. data/{lib/java/processing/opengl → src/main/resources}/shaders/PointFrag.glsl +0 -0
  36. data/{lib/java/processing/opengl → src/main/resources}/shaders/PointVert.glsl +0 -0
  37. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexFrag.glsl +0 -0
  38. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexLightFrag.glsl +0 -0
  39. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexLightVert.glsl +0 -0
  40. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexVert.glsl +0 -0
  41. data/test/test_helper.rb +1 -0
  42. data/vendors/Rakefile +1 -1
  43. metadata +29 -155
  44. data/lib/java/japplemenubar/JAppleMenuBar.java +0 -88
  45. data/lib/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  46. data/lib/java/monkstone/ColorUtil.java +0 -127
  47. data/lib/java/monkstone/MathToolModule.java +0 -287
  48. data/lib/java/monkstone/PropaneLibrary.java +0 -46
  49. data/lib/java/monkstone/core/LibraryProxy.java +0 -136
  50. data/lib/java/monkstone/fastmath/DegLutTables.java +0 -111
  51. data/lib/java/monkstone/fastmath/Deglut.java +0 -71
  52. data/lib/java/monkstone/fastmath/package-info.java +0 -6
  53. data/lib/java/monkstone/filechooser/Chooser.java +0 -39
  54. data/lib/java/monkstone/noise/FastTerrain.java +0 -874
  55. data/lib/java/monkstone/noise/Noise.java +0 -90
  56. data/lib/java/monkstone/noise/NoiseGenerator.java +0 -75
  57. data/lib/java/monkstone/noise/NoiseMode.java +0 -28
  58. data/lib/java/monkstone/noise/OpenSimplex2F.java +0 -881
  59. data/lib/java/monkstone/noise/OpenSimplex2S.java +0 -1106
  60. data/lib/java/monkstone/noise/SmoothTerrain.java +0 -1099
  61. data/lib/java/monkstone/slider/CustomHorizontalSlider.java +0 -164
  62. data/lib/java/monkstone/slider/CustomVerticalSlider.java +0 -178
  63. data/lib/java/monkstone/slider/SimpleHorizontalSlider.java +0 -145
  64. data/lib/java/monkstone/slider/SimpleSlider.java +0 -166
  65. data/lib/java/monkstone/slider/SimpleVerticalSlider.java +0 -157
  66. data/lib/java/monkstone/slider/Slider.java +0 -61
  67. data/lib/java/monkstone/slider/SliderBar.java +0 -245
  68. data/lib/java/monkstone/slider/SliderGroup.java +0 -56
  69. data/lib/java/monkstone/slider/WheelHandler.java +0 -35
  70. data/lib/java/monkstone/vecmath/GfxRender.java +0 -86
  71. data/lib/java/monkstone/vecmath/JRender.java +0 -56
  72. data/lib/java/monkstone/vecmath/ShapeRender.java +0 -87
  73. data/lib/java/monkstone/vecmath/package-info.java +0 -20
  74. data/lib/java/monkstone/vecmath/vec2/Vec2.java +0 -802
  75. data/lib/java/monkstone/vecmath/vec2/package-info.java +0 -6
  76. data/lib/java/monkstone/vecmath/vec3/Vec3.java +0 -727
  77. data/lib/java/monkstone/vecmath/vec3/package-info.java +0 -6
  78. data/lib/java/monkstone/videoevent/CaptureEvent.java +0 -27
  79. data/lib/java/monkstone/videoevent/MovieEvent.java +0 -32
  80. data/lib/java/monkstone/videoevent/package-info.java +0 -20
  81. data/lib/java/processing/awt/PGraphicsJava2D.java +0 -3040
  82. data/lib/java/processing/awt/PImageAWT.java +0 -377
  83. data/lib/java/processing/awt/PShapeJava2D.java +0 -387
  84. data/lib/java/processing/awt/PSurfaceAWT.java +0 -1581
  85. data/lib/java/processing/awt/ShimAWT.java +0 -581
  86. data/lib/java/processing/core/PApplet.java +0 -15156
  87. data/lib/java/processing/core/PConstants.java +0 -523
  88. data/lib/java/processing/core/PFont.java +0 -1126
  89. data/lib/java/processing/core/PGraphics.java +0 -8600
  90. data/lib/java/processing/core/PImage.java +0 -3377
  91. data/lib/java/processing/core/PMatrix.java +0 -208
  92. data/lib/java/processing/core/PMatrix2D.java +0 -562
  93. data/lib/java/processing/core/PMatrix3D.java +0 -890
  94. data/lib/java/processing/core/PShape.java +0 -3561
  95. data/lib/java/processing/core/PShapeOBJ.java +0 -483
  96. data/lib/java/processing/core/PShapeSVG.java +0 -2016
  97. data/lib/java/processing/core/PStyle.java +0 -63
  98. data/lib/java/processing/core/PSurface.java +0 -198
  99. data/lib/java/processing/core/PSurfaceNone.java +0 -431
  100. data/lib/java/processing/core/PVector.java +0 -1066
  101. data/lib/java/processing/core/ThinkDifferent.java +0 -115
  102. data/lib/java/processing/data/DoubleDict.java +0 -850
  103. data/lib/java/processing/data/DoubleList.java +0 -928
  104. data/lib/java/processing/data/FloatDict.java +0 -847
  105. data/lib/java/processing/data/FloatList.java +0 -936
  106. data/lib/java/processing/data/IntDict.java +0 -807
  107. data/lib/java/processing/data/IntList.java +0 -936
  108. data/lib/java/processing/data/JSONArray.java +0 -1260
  109. data/lib/java/processing/data/JSONObject.java +0 -2282
  110. data/lib/java/processing/data/JSONTokener.java +0 -435
  111. data/lib/java/processing/data/LongDict.java +0 -802
  112. data/lib/java/processing/data/LongList.java +0 -937
  113. data/lib/java/processing/data/Sort.java +0 -46
  114. data/lib/java/processing/data/StringDict.java +0 -613
  115. data/lib/java/processing/data/StringList.java +0 -800
  116. data/lib/java/processing/data/Table.java +0 -4936
  117. data/lib/java/processing/data/TableRow.java +0 -198
  118. data/lib/java/processing/data/XML.java +0 -1156
  119. data/lib/java/processing/dxf/RawDXF.java +0 -404
  120. data/lib/java/processing/event/Event.java +0 -125
  121. data/lib/java/processing/event/KeyEvent.java +0 -70
  122. data/lib/java/processing/event/MouseEvent.java +0 -114
  123. data/lib/java/processing/event/TouchEvent.java +0 -57
  124. data/lib/java/processing/javafx/PGraphicsFX2D.java +0 -32
  125. data/lib/java/processing/javafx/PSurfaceFX.java +0 -173
  126. data/lib/java/processing/net/Client.java +0 -744
  127. data/lib/java/processing/net/Server.java +0 -388
  128. data/lib/java/processing/opengl/FontTexture.java +0 -378
  129. data/lib/java/processing/opengl/FrameBuffer.java +0 -513
  130. data/lib/java/processing/opengl/LinePath.java +0 -627
  131. data/lib/java/processing/opengl/LineStroker.java +0 -681
  132. data/lib/java/processing/opengl/PGL.java +0 -3483
  133. data/lib/java/processing/opengl/PGraphics2D.java +0 -615
  134. data/lib/java/processing/opengl/PGraphics3D.java +0 -281
  135. data/lib/java/processing/opengl/PGraphicsOpenGL.java +0 -13753
  136. data/lib/java/processing/opengl/PJOGL.java +0 -2008
  137. data/lib/java/processing/opengl/PShader.java +0 -1484
  138. data/lib/java/processing/opengl/PShapeOpenGL.java +0 -5269
  139. data/lib/java/processing/opengl/PSurfaceJOGL.java +0 -1385
  140. data/lib/java/processing/opengl/Texture.java +0 -1696
  141. data/lib/java/processing/opengl/VertexBuffer.java +0 -88
  142. data/lib/java/processing/pdf/PGraphicsPDF.java +0 -581
  143. data/lib/java/processing/svg/PGraphicsSVG.java +0 -378
  144. data/src/main/java/processing/opengl/cursors/arrow.png +0 -0
  145. data/src/main/java/processing/opengl/cursors/cross.png +0 -0
  146. data/src/main/java/processing/opengl/cursors/hand.png +0 -0
  147. data/src/main/java/processing/opengl/cursors/license.txt +0 -27
  148. data/src/main/java/processing/opengl/cursors/move.png +0 -0
  149. data/src/main/java/processing/opengl/cursors/text.png +0 -0
  150. data/src/main/java/processing/opengl/cursors/wait.png +0 -0
  151. data/src/main/java/processing/opengl/shaders/ColorFrag.glsl +0 -32
  152. data/src/main/java/processing/opengl/shaders/ColorVert.glsl +0 -34
  153. data/src/main/java/processing/opengl/shaders/LightFrag.glsl +0 -33
  154. data/src/main/java/processing/opengl/shaders/LightVert.glsl +0 -151
  155. data/src/main/java/processing/opengl/shaders/LineFrag.glsl +0 -32
  156. data/src/main/java/processing/opengl/shaders/LineVert.glsl +0 -100
  157. data/src/main/java/processing/opengl/shaders/MaskFrag.glsl +0 -40
  158. data/src/main/java/processing/opengl/shaders/PointFrag.glsl +0 -32
  159. data/src/main/java/processing/opengl/shaders/PointVert.glsl +0 -56
  160. data/src/main/java/processing/opengl/shaders/TexFrag.glsl +0 -37
  161. data/src/main/java/processing/opengl/shaders/TexLightFrag.glsl +0 -37
  162. data/src/main/java/processing/opengl/shaders/TexLightVert.glsl +0 -157
  163. data/src/main/java/processing/opengl/shaders/TexVert.glsl +0 -38
@@ -1,1066 +0,0 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
- /*
4
- Part of the Processing project - http://processing.org
5
-
6
- Copyright (c) 2012-17 The Processing Foundation
7
- Copyright (c) 2008-12 Ben Fry and Casey Reas
8
- Copyright (c) 2008 Dan Shiffman
9
-
10
- This library is free software; you can redistribute it and/or
11
- modify it under the terms of the GNU Lesser General Public
12
- License version 2.1 as published by the Free Software Foundation.
13
-
14
- This library is distributed in the hope that it will be useful,
15
- but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- Lesser General Public License for more details.
18
-
19
- You should have received a copy of the GNU Lesser General
20
- Public License along with this library; if not, write to the
21
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
- Boston, MA 02111-1307 USA
23
- */
24
-
25
- package processing.core;
26
-
27
- import java.io.Serializable;
28
-
29
-
30
- /**
31
- * ( begin auto-generated from PVector.xml )
32
- *
33
- * A class to describe a two or three dimensional vector. This datatype
34
- * stores two or three variables that are commonly used as a position,
35
- * velocity, and/or acceleration. Technically, <em>position</em> is a point
36
- * and <em>velocity</em> and <em>acceleration</em> are vectors, but this is
37
- * often simplified to consider all three as vectors. For example, if you
38
- * consider a rectangle moving across the screen, at any given instant it
39
- * has a position (the object's location, expressed as a point.), a
40
- * velocity (the rate at which the object's position changes per time unit,
41
- * expressed as a vector), and acceleration (the rate at which the object's
42
- * velocity changes per time unit, expressed as a vector). Since vectors
43
- * represent groupings of values, we cannot simply use traditional
44
- * addition/multiplication/etc. Instead, we'll need to do some "vector"
45
- * math, which is made easy by the methods inside the <b>PVector</b>
46
- * class.
47
- *
48
- * The methods for this class are extensive. For a complete list, visit the
49
- * <a
50
- * href="http://processing.googlecode.com/svn/trunk/processing/build/javadoc/core/">developer's reference.</a>
51
- *
52
- * ( end auto-generated )
53
- *
54
- * A class to describe a two or three dimensional vector.
55
- * <p>
56
- * The result of all functions are applied to the vector itself, with the
57
- * exception of cross(), which returns a new PVector (or writes to a specified
58
- * 'target' PVector). That is, add() will add the contents of one vector to
59
- * this one. Using add() with additional parameters allows you to put the
60
- * result into a new PVector. Functions that act on multiple vectors also
61
- * include static versions. Because creating new objects can be computationally
62
- * expensive, most functions include an optional 'target' PVector, so that a
63
- * new PVector object is not created with each operation.
64
- * <p>
65
- * Initially based on the Vector3D class by <a href="http://www.shiffman.net">Dan Shiffman</a>.
66
- *
67
- * @webref math
68
- */
69
- public class PVector implements Serializable {
70
- /**
71
- * ( begin auto-generated from PVector_x.xml )
72
- *
73
- * The x component of the vector. This field (variable) can be used to both
74
- * get and set the value (see above example.)
75
- *
76
- * ( end auto-generated )
77
- *
78
- * @webref pvector:field
79
- * @usage web_application
80
- * @brief The x component of the vector
81
- */
82
- public float x;
83
-
84
- /**
85
- * ( begin auto-generated from PVector_y.xml )
86
- *
87
- * The y component of the vector. This field (variable) can be used to both
88
- * get and set the value (see above example.)
89
- *
90
- * ( end auto-generated )
91
- *
92
- * @webref pvector:field
93
- * @usage web_application
94
- * @brief The y component of the vector
95
- */
96
- public float y;
97
-
98
- /**
99
- * ( begin auto-generated from PVector_z.xml )
100
- *
101
- * The z component of the vector. This field (variable) can be used to both
102
- * get and set the value (see above example.)
103
- *
104
- * ( end auto-generated )
105
- *
106
- * @webref pvector:field
107
- * @usage web_application
108
- * @brief The z component of the vector
109
- */
110
- public float z;
111
-
112
- /** Array so that this can be temporarily used in an array context */
113
- transient protected float[] array;
114
-
115
-
116
- /**
117
- * Constructor for an empty vector: x, y, and z are set to 0.
118
- */
119
- public PVector() {
120
- }
121
-
122
-
123
- /**
124
- * Constructor for a 3D vector.
125
- *
126
- * @param x the x coordinate.
127
- * @param y the y coordinate.
128
- * @param z the z coordinate.
129
- */
130
- public PVector(float x, float y, float z) {
131
- this.x = x;
132
- this.y = y;
133
- this.z = z;
134
- }
135
-
136
-
137
- /**
138
- * Constructor for a 2D vector: z coordinate is set to 0.
139
- */
140
- public PVector(float x, float y) {
141
- this.x = x;
142
- this.y = y;
143
- }
144
-
145
-
146
- /**
147
- * ( begin auto-generated from PVector_set.xml )
148
- *
149
- * Sets the x, y, and z component of the vector using two or three separate
150
- * variables, the data from a PVector, or the values from a float array.
151
- *
152
- * ( end auto-generated )
153
- *
154
- * @webref pvector:method
155
- * @param x the x component of the vector
156
- * @param y the y component of the vector
157
- * @param z the z component of the vector
158
- * @brief Set the components of the vector
159
- */
160
- public PVector set(float x, float y, float z) {
161
- this.x = x;
162
- this.y = y;
163
- this.z = z;
164
- return this;
165
- }
166
-
167
-
168
- /**
169
- * @param x the x component of the vector
170
- * @param y the y component of the vector
171
- */
172
- public PVector set(float x, float y) {
173
- this.x = x;
174
- this.y = y;
175
- this.z = 0;
176
- return this;
177
- }
178
-
179
-
180
- /**
181
- * @param v any variable of type PVector
182
- */
183
- public PVector set(PVector v) {
184
- x = v.x;
185
- y = v.y;
186
- z = v.z;
187
- return this;
188
- }
189
-
190
-
191
- /**
192
- * Set the x, y (and maybe z) coordinates using a float[] array as the source.
193
- * @param source array to copy from
194
- */
195
- public PVector set(float[] source) {
196
- if (source.length >= 2) {
197
- x = source[0];
198
- y = source[1];
199
- }
200
- if (source.length >= 3) {
201
- z = source[2];
202
- } else {
203
- z = 0;
204
- }
205
- return this;
206
- }
207
-
208
-
209
- /**
210
- * ( begin auto-generated from PVector_random2D.xml )
211
- *
212
- * Make a new 2D unit vector with a random direction. If you pass in "this"
213
- * as an argument, it will use the PApplet's random number generator. You can
214
- * also pass in a target PVector to fill.
215
- *
216
- * @webref pvector:method
217
- * @usage web_application
218
- * @return the random PVector
219
- * @brief Make a new 2D unit vector with a random direction.
220
- * @see PVector#random3D()
221
- */
222
- static public PVector random2D() {
223
- return random2D(null, null);
224
- }
225
-
226
-
227
- /**
228
- * Make a new 2D unit vector with a random direction
229
- * using Processing's current random number generator
230
- * @param parent current PApplet instance
231
- * @return the random PVector
232
- */
233
- static public PVector random2D(PApplet parent) {
234
- return random2D(null, parent);
235
- }
236
-
237
- /**
238
- * Set a 2D vector to a random unit vector with a random direction
239
- * @param target the target vector (if null, a new vector will be created)
240
- * @return the random PVector
241
- */
242
- static public PVector random2D(PVector target) {
243
- return random2D(target, null);
244
- }
245
-
246
-
247
- /**
248
- * Make a new 2D unit vector with a random direction. Pass in the parent
249
- * PApplet if you want randomSeed() to work (and be predictable). Or leave
250
- * it null and be... random.
251
- * @return the random PVector
252
- */
253
- static public PVector random2D(PVector target, PApplet parent) {
254
- return (parent == null) ?
255
- fromAngle((float) (Math.random() * Math.PI*2), target) :
256
- fromAngle(parent.random(PConstants.TAU), target);
257
- }
258
-
259
-
260
- /**
261
- * ( begin auto-generated from PVector_random3D.xml )
262
- *
263
- * Make a new 3D unit vector with a random direction. If you pass in "this"
264
- * as an argument, it will use the PApplet's random number generator. You can
265
- * also pass in a target PVector to fill.
266
- *
267
- * @webref pvector:method
268
- * @usage web_application
269
- * @return the random PVector
270
- * @brief Make a new 3D unit vector with a random direction.
271
- * @see PVector#random2D()
272
- */
273
- static public PVector random3D() {
274
- return random3D(null, null);
275
- }
276
-
277
-
278
- /**
279
- * Make a new 3D unit vector with a random direction
280
- * using Processing's current random number generator
281
- * @param parent current PApplet instance
282
- * @return the random PVector
283
- */
284
- static public PVector random3D(PApplet parent) {
285
- return random3D(null, parent);
286
- }
287
-
288
-
289
- /**
290
- * Set a 3D vector to a random unit vector with a random direction
291
- * @param target the target vector (if null, a new vector will be created)
292
- * @return the random PVector
293
- */
294
- static public PVector random3D(PVector target) {
295
- return random3D(target, null);
296
- }
297
-
298
-
299
- /**
300
- * Make a new 3D unit vector with a random direction
301
- * @return the random PVector
302
- */
303
- static public PVector random3D(PVector target, PApplet parent) {
304
- float angle;
305
- float vz;
306
- if (parent == null) {
307
- angle = (float) (Math.random()*Math.PI*2);
308
- vz = (float) (Math.random()*2-1);
309
- } else {
310
- angle = parent.random(PConstants.TWO_PI);
311
- vz = parent.random(-1,1);
312
- }
313
- float vx = (float) (Math.sqrt(1-vz*vz)*Math.cos(angle));
314
- float vy = (float) (Math.sqrt(1-vz*vz)*Math.sin(angle));
315
- if (target == null) {
316
- target = new PVector(vx, vy, vz);
317
- //target.normalize(); // Should be unnecessary
318
- } else {
319
- target.set(vx,vy,vz);
320
- }
321
- return target;
322
- }
323
-
324
-
325
- /**
326
- * ( begin auto-generated from PVector_sub.xml )
327
- *
328
- * Make a new 2D unit vector from an angle.
329
- *
330
- * ( end auto-generated )
331
- *
332
- * @webref pvector:method
333
- * @usage web_application
334
- * @brief Make a new 2D unit vector from an angle
335
- * @param angle the angle in radians
336
- * @return the new unit PVector
337
- */
338
- static public PVector fromAngle(float angle) {
339
- return fromAngle(angle,null);
340
- }
341
-
342
-
343
- /**
344
- * Make a new 2D unit vector from an angle
345
- *
346
- * @param target the target vector (if null, a new vector will be created)
347
- * @return the PVector
348
- */
349
- static public PVector fromAngle(float angle, PVector target) {
350
- if (target == null) {
351
- target = new PVector((float)Math.cos(angle),(float)Math.sin(angle),0);
352
- } else {
353
- target.set((float)Math.cos(angle),(float)Math.sin(angle),0);
354
- }
355
- return target;
356
- }
357
-
358
-
359
- /**
360
- * ( begin auto-generated from PVector_copy.xml )
361
- *
362
- * Gets a copy of the vector, returns a PVector object.
363
- *
364
- * ( end auto-generated )
365
- *
366
- * @webref pvector:method
367
- * @usage web_application
368
- * @brief Get a copy of the vector
369
- */
370
- public PVector copy() {
371
- return new PVector(x, y, z);
372
- }
373
-
374
-
375
- @Deprecated
376
- public PVector get() {
377
- return copy();
378
- }
379
-
380
-
381
- /**
382
- * @param target
383
- */
384
- public float[] get(float[] target) {
385
- if (target == null) {
386
- return new float[] { x, y, z };
387
- }
388
- if (target.length >= 2) {
389
- target[0] = x;
390
- target[1] = y;
391
- }
392
- if (target.length >= 3) {
393
- target[2] = z;
394
- }
395
- return target;
396
- }
397
-
398
-
399
- /**
400
- * ( begin auto-generated from PVector_mag.xml )
401
- *
402
- * Calculates the magnitude (length) of the vector and returns the result
403
- * as a float (this is simply the equation <em>sqrt(x*x + y*y + z*z)</em>.)
404
- *
405
- * ( end auto-generated )
406
- *
407
- * @webref pvector:method
408
- * @usage web_application
409
- * @brief Calculate the magnitude of the vector
410
- * @return magnitude (length) of the vector
411
- * @see PVector#magSq()
412
- */
413
- public float mag() {
414
- return (float) Math.sqrt(x*x + y*y + z*z);
415
- }
416
-
417
-
418
- /**
419
- * ( begin auto-generated from PVector_mag.xml )
420
- *
421
- * Calculates the squared magnitude of the vector and returns the result
422
- * as a float (this is simply the equation <em>(x*x + y*y + z*z)</em>.)
423
- * Faster if the real length is not required in the
424
- * case of comparing vectors, etc.
425
- *
426
- * ( end auto-generated )
427
- *
428
- * @webref pvector:method
429
- * @usage web_application
430
- * @brief Calculate the magnitude of the vector, squared
431
- * @return squared magnitude of the vector
432
- * @see PVector#mag()
433
- */
434
- public float magSq() {
435
- return (x*x + y*y + z*z);
436
- }
437
-
438
-
439
- /**
440
- * ( begin auto-generated from PVector_add.xml )
441
- *
442
- * Adds x, y, and z components to a vector, adds one vector to another, or
443
- * adds two independent vectors together. The version of the method that
444
- * adds two vectors together is a static method and returns a PVector, the
445
- * others have no return value -- they act directly on the vector. See the
446
- * examples for more context.
447
- *
448
- * ( end auto-generated )
449
- *
450
- * @webref pvector:method
451
- * @usage web_application
452
- * @param v the vector to be added
453
- * @brief Adds x, y, and z components to a vector, one vector to another, or two independent vectors
454
- */
455
- public PVector add(PVector v) {
456
- x += v.x;
457
- y += v.y;
458
- z += v.z;
459
- return this;
460
- }
461
-
462
-
463
- /**
464
- * @param x x component of the vector
465
- * @param y y component of the vector
466
- */
467
- public PVector add(float x, float y) {
468
- this.x += x;
469
- this.y += y;
470
- return this;
471
- }
472
-
473
-
474
- /**
475
- * @param z z component of the vector
476
- */
477
- public PVector add(float x, float y, float z) {
478
- this.x += x;
479
- this.y += y;
480
- this.z += z;
481
- return this;
482
- }
483
-
484
-
485
- /**
486
- * Add two vectors
487
- * @param v1 a vector
488
- * @param v2 another vector
489
- */
490
- static public PVector add(PVector v1, PVector v2) {
491
- return add(v1, v2, null);
492
- }
493
-
494
-
495
- /**
496
- * Add two vectors into a target vector
497
- * @param target the target vector (if null, a new vector will be created)
498
- */
499
- static public PVector add(PVector v1, PVector v2, PVector target) {
500
- if (target == null) {
501
- target = new PVector(v1.x + v2.x,v1.y + v2.y, v1.z + v2.z);
502
- } else {
503
- target.set(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
504
- }
505
- return target;
506
- }
507
-
508
-
509
- /**
510
- * ( begin auto-generated from PVector_sub.xml )
511
- *
512
- * Subtracts x, y, and z components from a vector, subtracts one vector
513
- * from another, or subtracts two independent vectors. The version of the
514
- * method that subtracts two vectors is a static method and returns a
515
- * PVector, the others have no return value -- they act directly on the
516
- * vector. See the examples for more context.
517
- *
518
- * ( end auto-generated )
519
- *
520
- * @webref pvector:method
521
- * @usage web_application
522
- * @param v any variable of type PVector
523
- * @brief Subtract x, y, and z components from a vector, one vector from another, or two independent vectors
524
- */
525
- public PVector sub(PVector v) {
526
- x -= v.x;
527
- y -= v.y;
528
- z -= v.z;
529
- return this;
530
- }
531
-
532
-
533
- /**
534
- * @param x the x component of the vector
535
- * @param y the y component of the vector
536
- */
537
- public PVector sub(float x, float y) {
538
- this.x -= x;
539
- this.y -= y;
540
- return this;
541
- }
542
-
543
-
544
- /**
545
- * @param z the z component of the vector
546
- */
547
- public PVector sub(float x, float y, float z) {
548
- this.x -= x;
549
- this.y -= y;
550
- this.z -= z;
551
- return this;
552
- }
553
-
554
-
555
- /**
556
- * Subtract one vector from another
557
- * @param v1 the x, y, and z components of a PVector object
558
- * @param v2 the x, y, and z components of a PVector object
559
- */
560
- static public PVector sub(PVector v1, PVector v2) {
561
- return sub(v1, v2, null);
562
- }
563
-
564
-
565
- /**
566
- * Subtract one vector from another and store in another vector
567
- * @param target PVector in which to store the result
568
- */
569
- static public PVector sub(PVector v1, PVector v2, PVector target) {
570
- if (target == null) {
571
- target = new PVector(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
572
- } else {
573
- target.set(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
574
- }
575
- return target;
576
- }
577
-
578
-
579
- /**
580
- * ( begin auto-generated from PVector_mult.xml )
581
- *
582
- * Multiplies a vector by a scalar or multiplies one vector by another.
583
- *
584
- * ( end auto-generated )
585
- *
586
- * @webref pvector:method
587
- * @usage web_application
588
- * @brief Multiply a vector by a scalar
589
- * @param n the number to multiply with the vector
590
- */
591
- public PVector mult(float n) {
592
- x *= n;
593
- y *= n;
594
- z *= n;
595
- return this;
596
- }
597
-
598
-
599
- /**
600
- * @param v the vector to multiply by the scalar
601
- */
602
- static public PVector mult(PVector v, float n) {
603
- return mult(v, n, null);
604
- }
605
-
606
-
607
- /**
608
- * Multiply a vector by a scalar, and write the result into a target PVector.
609
- * @param target PVector in which to store the result
610
- */
611
- static public PVector mult(PVector v, float n, PVector target) {
612
- if (target == null) {
613
- target = new PVector(v.x*n, v.y*n, v.z*n);
614
- } else {
615
- target.set(v.x*n, v.y*n, v.z*n);
616
- }
617
- return target;
618
- }
619
-
620
-
621
- /**
622
- * ( begin auto-generated from PVector_div.xml )
623
- *
624
- * Divides a vector by a scalar or divides one vector by another.
625
- *
626
- * ( end auto-generated )
627
- *
628
- * @webref pvector:method
629
- * @usage web_application
630
- * @brief Divide a vector by a scalar
631
- * @param n the number by which to divide the vector
632
- */
633
- public PVector div(float n) {
634
- x /= n;
635
- y /= n;
636
- z /= n;
637
- return this;
638
- }
639
-
640
-
641
- /**
642
- * Divide a vector by a scalar and return the result in a new vector.
643
- * @param v the vector to divide by the scalar
644
- * @return a new vector that is v1 / n
645
- */
646
- static public PVector div(PVector v, float n) {
647
- return div(v, n, null);
648
- }
649
-
650
-
651
- /**
652
- * Divide a vector by a scalar and store the result in another vector.
653
- * @param target PVector in which to store the result
654
- */
655
- static public PVector div(PVector v, float n, PVector target) {
656
- if (target == null) {
657
- target = new PVector(v.x/n, v.y/n, v.z/n);
658
- } else {
659
- target.set(v.x/n, v.y/n, v.z/n);
660
- }
661
- return target;
662
- }
663
-
664
-
665
- /**
666
- * ( begin auto-generated from PVector_dist.xml )
667
- *
668
- * Calculates the Euclidean distance between two points (considering a
669
- * point as a vector object).
670
- *
671
- * ( end auto-generated )
672
- *
673
- * @webref pvector:method
674
- * @usage web_application
675
- * @param v the x, y, and z coordinates of a PVector
676
- * @brief Calculate the distance between two points
677
- */
678
- public float dist(PVector v) {
679
- float dx = x - v.x;
680
- float dy = y - v.y;
681
- float dz = z - v.z;
682
- return (float) Math.sqrt(dx*dx + dy*dy + dz*dz);
683
- }
684
-
685
-
686
- /**
687
- * @param v1 any variable of type PVector
688
- * @param v2 any variable of type PVector
689
- * @return the Euclidean distance between v1 and v2
690
- */
691
- static public float dist(PVector v1, PVector v2) {
692
- float dx = v1.x - v2.x;
693
- float dy = v1.y - v2.y;
694
- float dz = v1.z - v2.z;
695
- return (float) Math.sqrt(dx*dx + dy*dy + dz*dz);
696
- }
697
-
698
-
699
- /**
700
- * ( begin auto-generated from PVector_dot.xml )
701
- *
702
- * Calculates the dot product of two vectors.
703
- *
704
- * ( end auto-generated )
705
- *
706
- * @webref pvector:method
707
- * @usage web_application
708
- * @param v any variable of type PVector
709
- * @return the dot product
710
- * @brief Calculate the dot product of two vectors
711
- */
712
- public float dot(PVector v) {
713
- return x*v.x + y*v.y + z*v.z;
714
- }
715
-
716
-
717
- /**
718
- * @param x x component of the vector
719
- * @param y y component of the vector
720
- * @param z z component of the vector
721
- */
722
- public float dot(float x, float y, float z) {
723
- return this.x*x + this.y*y + this.z*z;
724
- }
725
-
726
-
727
- /**
728
- * @param v1 any variable of type PVector
729
- * @param v2 any variable of type PVector
730
- */
731
- static public float dot(PVector v1, PVector v2) {
732
- return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
733
- }
734
-
735
-
736
- /**
737
- * ( begin auto-generated from PVector_cross.xml )
738
- *
739
- * Calculates and returns a vector composed of the cross product between
740
- * two vectors.
741
- *
742
- * ( end auto-generated )
743
- *
744
- * @webref pvector:method
745
- * @param v the vector to calculate the cross product
746
- * @brief Calculate and return the cross product
747
- */
748
- public PVector cross(PVector v) {
749
- return cross(v, null);
750
- }
751
-
752
-
753
- /**
754
- * @param v any variable of type PVector
755
- * @param target PVector to store the result
756
- */
757
- public PVector cross(PVector v, PVector target) {
758
- float crossX = y * v.z - v.y * z;
759
- float crossY = z * v.x - v.z * x;
760
- float crossZ = x * v.y - v.x * y;
761
-
762
- if (target == null) {
763
- target = new PVector(crossX, crossY, crossZ);
764
- } else {
765
- target.set(crossX, crossY, crossZ);
766
- }
767
- return target;
768
- }
769
-
770
-
771
- /**
772
- * @param v1 any variable of type PVector
773
- * @param v2 any variable of type PVector
774
- * @param target PVector to store the result
775
- */
776
- static public PVector cross(PVector v1, PVector v2, PVector target) {
777
- float crossX = v1.y * v2.z - v2.y * v1.z;
778
- float crossY = v1.z * v2.x - v2.z * v1.x;
779
- float crossZ = v1.x * v2.y - v2.x * v1.y;
780
-
781
- if (target == null) {
782
- target = new PVector(crossX, crossY, crossZ);
783
- } else {
784
- target.set(crossX, crossY, crossZ);
785
- }
786
- return target;
787
- }
788
-
789
-
790
- /**
791
- * ( begin auto-generated from PVector_normalize.xml )
792
- *
793
- * Normalize the vector to length 1 (make it a unit vector).
794
- *
795
- * ( end auto-generated )
796
- *
797
- * @webref pvector:method
798
- * @usage web_application
799
- * @brief Normalize the vector to a length of 1
800
- */
801
- public PVector normalize() {
802
- float m = mag();
803
- if (m != 0 && m != 1) {
804
- div(m);
805
- }
806
- return this;
807
- }
808
-
809
-
810
- /**
811
- * @param target Set to null to create a new vector
812
- * @return a new vector (if target was null), or target
813
- */
814
- public PVector normalize(PVector target) {
815
- if (target == null) {
816
- target = new PVector();
817
- }
818
- float m = mag();
819
- if (m > 0) {
820
- target.set(x/m, y/m, z/m);
821
- } else {
822
- target.set(x, y, z);
823
- }
824
- return target;
825
- }
826
-
827
-
828
- /**
829
- * ( begin auto-generated from PVector_limit.xml )
830
- *
831
- * Limit the magnitude of this vector to the value used for the <b>max</b> parameter.
832
- *
833
- * ( end auto-generated )
834
- *
835
- * @webref pvector:method
836
- * @usage web_application
837
- * @param max the maximum magnitude for the vector
838
- * @brief Limit the magnitude of the vector
839
- */
840
- public PVector limit(float max) {
841
- if (magSq() > max*max) {
842
- normalize();
843
- mult(max);
844
- }
845
- return this;
846
- }
847
-
848
-
849
- /**
850
- * ( begin auto-generated from PVector_setMag.xml )
851
- *
852
- * Set the magnitude of this vector to the value used for the <b>len</b> parameter.
853
- *
854
- * ( end auto-generated )
855
- *
856
- * @webref pvector:method
857
- * @usage web_application
858
- * @param len the new length for this vector
859
- * @brief Set the magnitude of the vector
860
- */
861
- public PVector setMag(float len) {
862
- normalize();
863
- mult(len);
864
- return this;
865
- }
866
-
867
-
868
- /**
869
- * Sets the magnitude of this vector, storing the result in another vector.
870
- * @param target Set to null to create a new vector
871
- * @param len the new length for the new vector
872
- * @return a new vector (if target was null), or target
873
- */
874
- public PVector setMag(PVector target, float len) {
875
- target = normalize(target);
876
- target.mult(len);
877
- return target;
878
- }
879
-
880
-
881
- /**
882
- * ( begin auto-generated from PVector_setMag.xml )
883
- *
884
- * Calculate the angle of rotation for this vector (only 2D vectors)
885
- *
886
- * ( end auto-generated )
887
- *
888
- * @webref pvector:method
889
- * @usage web_application
890
- * @return the angle of rotation
891
- * @brief Calculate the angle of rotation for this vector
892
- */
893
- public float heading() {
894
- float angle = (float) Math.atan2(y, x);
895
- return angle;
896
- }
897
-
898
-
899
- @Deprecated
900
- public float heading2D() {
901
- return heading();
902
- }
903
-
904
-
905
- /**
906
- * ( begin auto-generated from PVector_rotate.xml )
907
- *
908
- * Rotate the vector by an angle (only 2D vectors), magnitude remains the same
909
- *
910
- * ( end auto-generated )
911
- *
912
- * @webref pvector:method
913
- * @usage web_application
914
- * @brief Rotate the vector by an angle (2D only)
915
- * @param theta the angle of rotation
916
- */
917
- public PVector rotate(float theta) {
918
- float temp = x;
919
- // Might need to check for rounding errors like with angleBetween function?
920
- x = x*PApplet.cos(theta) - y*PApplet.sin(theta);
921
- y = temp*PApplet.sin(theta) + y*PApplet.cos(theta);
922
- return this;
923
- }
924
-
925
-
926
- /**
927
- * ( begin auto-generated from PVector_rotate.xml )
928
- *
929
- * Linear interpolate the vector to another vector
930
- *
931
- * ( end auto-generated )
932
- *
933
- * @webref pvector:method
934
- * @usage web_application
935
- * @brief Linear interpolate the vector to another vector
936
- * @param v the vector to lerp to
937
- * @param amt The amount of interpolation; some value between 0.0 (old vector) and 1.0 (new vector). 0.1 is very near the old vector; 0.5 is halfway in between.
938
- * @see PApplet#lerp(float, float, float)
939
- */
940
- public PVector lerp(PVector v, float amt) {
941
- x = PApplet.lerp(x, v.x, amt);
942
- y = PApplet.lerp(y, v.y, amt);
943
- z = PApplet.lerp(z, v.z, amt);
944
- return this;
945
- }
946
-
947
-
948
- /**
949
- * Linear interpolate between two vectors (returns a new PVector object)
950
- * @param v1 the vector to start from
951
- * @param v2 the vector to lerp to
952
- * @param amt
953
- * @return
954
- */
955
- public static PVector lerp(PVector v1, PVector v2, float amt) {
956
- PVector v = v1.copy();
957
- v.lerp(v2, amt);
958
- return v;
959
- }
960
-
961
-
962
- /**
963
- * Linear interpolate the vector to x,y,z values
964
- * @param x the x component to lerp to
965
- * @param y the y component to lerp to
966
- * @param z the z component to lerp to
967
- * @param amt
968
- * @return
969
- */
970
- public PVector lerp(float x, float y, float z, float amt) {
971
- this.x = PApplet.lerp(this.x, x, amt);
972
- this.y = PApplet.lerp(this.y, y, amt);
973
- this.z = PApplet.lerp(this.z, z, amt);
974
- return this;
975
- }
976
-
977
-
978
- /**
979
- * ( begin auto-generated from PVector_angleBetween.xml )
980
- *
981
- * Calculates and returns the angle (in radians) between two vectors.( end auto-generated )
982
- *
983
- *
984
- * @return
985
- * @webref pvector:method
986
- * @usage web_application
987
- * @param v1 the x, y, and z components of a PVector
988
- * @param v2 the x, y, and z components of a PVector
989
- * @brief Calculate and return the angle between two vectors
990
- */
991
- static public float angleBetween(PVector v1, PVector v2) {
992
-
993
- // We get NaN if we pass in a zero vector which can cause problems
994
- // Zero seems like a reasonable angle between a (0,0,0) vector and something else
995
- if (v1.x == 0 && v1.y == 0 && v1.z == 0 ) return 0.0f;
996
- if (v2.x == 0 && v2.y == 0 && v2.z == 0 ) return 0.0f;
997
-
998
- double dot = v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
999
- double v1mag = Math.sqrt(v1.x * v1.x + v1.y * v1.y + v1.z * v1.z);
1000
- double v2mag = Math.sqrt(v2.x * v2.x + v2.y * v2.y + v2.z * v2.z);
1001
- // This should be a number between -1 and 1, since it's "normalized"
1002
- double amt = dot / (v1mag * v2mag);
1003
- // But if it's not due to rounding error, then we need to fix it
1004
- // http://code.google.com/p/processing/issues/detail?id=340
1005
- // Otherwise if outside the range, acos() will return NaN
1006
- // http://www.cppreference.com/wiki/c/math/acos
1007
- if (amt <= -1) {
1008
- return PConstants.PI;
1009
- } else if (amt >= 1) {
1010
- // http://code.google.com/p/processing/issues/detail?id=435
1011
- return 0;
1012
- }
1013
- return (float) Math.acos(amt);
1014
- }
1015
-
1016
-
1017
- @Override
1018
- public String toString() {
1019
- return "[ " + x + ", " + y + ", " + z + " ]";
1020
- }
1021
-
1022
-
1023
- /**
1024
- * ( begin auto-generated from PVector_array.xml )
1025
- *
1026
- * Return a representation of this vector as a float array.This is only
1027
- for temporary use. If used in any other fashion, the contents should be
1028
- copied by using the <b>PVector.get()</b> method to copy into your own array.
1029
- *
1030
- * ( end auto-generated )
1031
- *
1032
- * @return
1033
- * @webref pvector:method
1034
- * @usage: web_application
1035
- * @brief Return a representation of the vector as a float array
1036
- */
1037
- public float[] array() {
1038
- if (array == null) {
1039
- array = new float[3];
1040
- }
1041
- array[0] = x;
1042
- array[1] = y;
1043
- array[2] = z;
1044
- return array;
1045
- }
1046
-
1047
-
1048
- @Override
1049
- public boolean equals(Object obj) {
1050
- if (!(obj instanceof PVector)) {
1051
- return false;
1052
- }
1053
- final PVector p = (PVector) obj;
1054
- return x == p.x && y == p.y && z == p.z;
1055
- }
1056
-
1057
-
1058
- @Override
1059
- public int hashCode() {
1060
- int result = 1;
1061
- result = 31 * result + Float.floatToIntBits(x);
1062
- result = 31 * result + Float.floatToIntBits(y);
1063
- result = 31 * result + Float.floatToIntBits(z);
1064
- return result;
1065
- }
1066
- }