propane 2.6.3-java → 2.6.4-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +3 -1
- data/README.md +2 -2
- data/lib/propane/version.rb +1 -1
- data/library/vector_utils/vector_utils.rb +69 -0
- data/pom.rb +2 -2
- data/pom.xml +2 -2
- data/propane.gemspec +3 -4
- data/src/monkstone/vecmath/vec2/Vec2.java +20 -12
- data/src/monkstone/vecmath/vec3/Vec3.java +15 -25
- data/test/vecmath_spec_test.rb +84 -39
- data/vendors/Rakefile +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7f3de4bd8418392ef49868c1b9d4bd2e168244755252d6394fb189993839b2a
|
4
|
+
data.tar.gz: 9f80f038be43becd118acf8eddc35a5bec22d6e5a17cfcf63d2c6d0815db154d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bd4abb66d417dcc612ddf4a90bb99bf55a21ddd68bac3c548706254128bb077b667e6e89c4ef1c11e83041cf4b0019259539af402a371ddf9802b282f214272
|
7
|
+
data.tar.gz: 2d9ed609a98abf21129dbeb9cc1d1e69e707e1fbb86343daf02d2a4e345d4f3573b4d4aa5187074b89edb4f402b52be3b4c7afc958031899c8ebde17be0f3a5f
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
**v2.6.
|
1
|
+
**v2.6.4** Vec2D and Vec3D now support `copy` constructor where the original can be a duck-type. Further the only requirement is that the duck-type responds to `:x`, and `:y` by returning a `float` or `fixnum` thus Vec2D can be promoted to Vec3D (where `z = 0`), or more usually some other Vector or Point class can be used as the original. A VectorUtils library has been implemented, see examples for usage.
|
2
|
+
|
3
|
+
**v2.6.3** Bump recommended upgrade to jruby-9.1.16.0, possibly the last in 9.1 series?
|
2
4
|
|
3
5
|
**v2.6.2** Features example sketches using the PixelFlow library by Thomas Diewald
|
4
6
|
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ adjust above for your OS/distro setup.
|
|
13
13
|
## Requirements
|
14
14
|
|
15
15
|
- jdk8+
|
16
|
-
- jruby-9.1.
|
16
|
+
- jruby-9.1.16.0
|
17
17
|
- mvn-3.5.0+
|
18
18
|
- core.jar processing-3.3.6 (_build only_)
|
19
19
|
|
@@ -28,7 +28,7 @@ rake javadoc
|
|
28
28
|
## Installation
|
29
29
|
```bash
|
30
30
|
jgem install propane # from rubygems
|
31
|
-
jgem install propane-2.6.
|
31
|
+
jgem install propane-2.6.4-java.gem # for local install
|
32
32
|
```
|
33
33
|
|
34
34
|
## Usage
|
data/lib/propane/version.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
PHI ||= (1 + Math.sqrt(5)) / 2 # golden ratio
|
2
|
+
GA = PHI * 2 * Math::PI # golden angle
|
3
|
+
|
4
|
+
# Useful Vector Utiliies
|
5
|
+
module VectorUtil
|
6
|
+
def self.rotate_vec2d(vectors: [], angle: 0)
|
7
|
+
vectors.map { |vector| vector.rotate(angle) }
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.vogel_layout(number:, node_size:)
|
11
|
+
(0..number).map do |i|
|
12
|
+
r = Math.sqrt(i)
|
13
|
+
theta = i * ((2 * Math::PI) / (PHI * PHI))
|
14
|
+
x = Math.cos(theta) * r * node_size
|
15
|
+
y = Math.sin(theta) * r * node_size
|
16
|
+
Vec2D.new(x, y)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.fibonacci_sphere(number:, radius:)
|
21
|
+
(0..number).map do |i|
|
22
|
+
lon = GA * i
|
23
|
+
lon /= 2 * Math::PI
|
24
|
+
lon -= lon.floor
|
25
|
+
lon *= 2 * Math::PI
|
26
|
+
lon -= 2 * Math::PI if lon > Math::PI
|
27
|
+
lat = Math.asin(-1 + 2 * i / number.to_f)
|
28
|
+
x = radius * Math.cos(lat) * Math.cos(lon)
|
29
|
+
y = radius * Math.cos(lat) * Math.sin(lon)
|
30
|
+
z = radius * Math.sin(lat)
|
31
|
+
Vec3D.new(x, y, z)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.spiral_layout(number:, radius:, resolution:, spacing:, inc:)
|
36
|
+
n = 0
|
37
|
+
angle = nil
|
38
|
+
(0..number).map do
|
39
|
+
angle = n * resolution
|
40
|
+
n += inc
|
41
|
+
radius -= angle * spacing
|
42
|
+
x = Math.cos(angle) * radius
|
43
|
+
y = Math.sin(angle) * radius
|
44
|
+
Vec2D.new(x, y)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.cartesian_to_polar(vec:)
|
49
|
+
res = Vec3D.new(vec.mag, 0, 0)
|
50
|
+
return Vec3D.new unless res.x > 0
|
51
|
+
res.y = -Math.atan2(vec.z, vec.x)
|
52
|
+
res.z = Math.asin(vec.y / res.x)
|
53
|
+
res
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.to_cartesian(lat:, long:, radius:)
|
57
|
+
latitude = lat
|
58
|
+
longitude = long
|
59
|
+
x = radius * Math.cos(latitude) * Math.cos(longitude)
|
60
|
+
y = radius * Math.cos(latitude) * Math.sin(longitude)
|
61
|
+
z = radius * Math.sin(latitude)
|
62
|
+
Vec3D.new(x, y, z)
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.polar_to_cartesian(vec:)
|
66
|
+
return Vec3D.new if vec.mag <= 0
|
67
|
+
Vec3D.new(Math.asin(vec.y / vec.mag), vec.mag, -Math.atan2(vec.z, vec.x))
|
68
|
+
end
|
69
|
+
end
|
data/pom.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
project 'rp5extras', 'https://github.com/monkstone/propane' do
|
3
3
|
model_version '4.0.0'
|
4
|
-
id 'propane:propane', '2.6.
|
4
|
+
id 'propane:propane', '2.6.4'
|
5
5
|
packaging 'jar'
|
6
6
|
description 'rp5extras for propane'
|
7
7
|
organization 'ruby-processing', 'https://ruby-processing.github.io'
|
@@ -32,7 +32,7 @@ project 'rp5extras', 'https://github.com/monkstone/propane' do
|
|
32
32
|
'jogl.version' => '2.3.2'
|
33
33
|
)
|
34
34
|
|
35
|
-
pom 'org.jruby:jruby:9.1.
|
35
|
+
pom 'org.jruby:jruby:9.1.16.0'
|
36
36
|
jar 'org.processing:core:3.3.6'
|
37
37
|
jar 'org.processing:video:3.0.2'
|
38
38
|
jar('org.jogamp.jogl:jogl-all:${jogl.version}')
|
data/pom.xml
CHANGED
@@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
11
11
|
<modelVersion>4.0.0</modelVersion>
|
12
12
|
<groupId>propane</groupId>
|
13
13
|
<artifactId>propane</artifactId>
|
14
|
-
<version>2.6.
|
14
|
+
<version>2.6.4</version>
|
15
15
|
<name>rp5extras</name>
|
16
16
|
<description>rp5extras for propane</description>
|
17
17
|
<url>https://github.com/monkstone/propane</url>
|
@@ -58,7 +58,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
58
58
|
<dependency>
|
59
59
|
<groupId>org.jruby</groupId>
|
60
60
|
<artifactId>jruby</artifactId>
|
61
|
-
<version>9.1.
|
61
|
+
<version>9.1.16.0</version>
|
62
62
|
<type>pom</type>
|
63
63
|
</dependency>
|
64
64
|
<dependency>
|
data/propane.gemspec
CHANGED
@@ -10,9 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ['mamba2928@yahoo.co.uk']
|
11
11
|
gem.licenses = %w(GPL-3.0 LGPL-2.0)
|
12
12
|
gem.description = <<-EOS
|
13
|
-
A batteries included version of processing in ruby, for MacOS and linux64.
|
14
|
-
current release features several PixelFlow glsl library examples, including a
|
15
|
-
few shadertoy demos as sketches.
|
13
|
+
A batteries included version of processing in ruby, for MacOS and linux64.
|
16
14
|
EOS
|
17
15
|
gem.summary = %q{ruby wrapper for processing-3.3.6 on MacOS and linux64 bit only for opengl}
|
18
16
|
gem.homepage = 'https://ruby-processing.github.io/propane/'
|
@@ -27,9 +25,10 @@ Gem::Specification.new do |gem|
|
|
27
25
|
gem.files << 'lib/jogl-all-2.3.2-natives-macosx-universal.jar'
|
28
26
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
29
27
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
30
|
-
gem.add_development_dependency 'rake', '~> 12'
|
28
|
+
gem.add_development_dependency 'rake', '~> 12.3'
|
31
29
|
gem.add_development_dependency 'minitest', '~> 5.10'
|
32
30
|
gem.add_runtime_dependency 'arcball', '~> 1.0', '>= 1.0.0'
|
33
31
|
gem.require_paths = ['lib']
|
34
32
|
gem.platform = 'java'
|
33
|
+
gem.requirements << 'java runtime >= 1.8.0_151+'
|
35
34
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
package monkstone.vecmath.vec2;
|
2
2
|
|
3
|
-
/*
|
3
|
+
/*
|
4
4
|
* Copyright (c) 2015-17 Martin Prout
|
5
|
-
*
|
5
|
+
*
|
6
6
|
* This library is free software; you can redistribute it and/or
|
7
7
|
* modify it under the terms of the GNU Lesser General Public
|
8
8
|
* License as published by the Free Software Foundation; either
|
9
9
|
* version 2.1 of the License, or (at your option) any later version.
|
10
|
-
*
|
10
|
+
*
|
11
11
|
* http://creativecommons.org/licenses/LGPL/2.1/
|
12
|
-
*
|
12
|
+
*
|
13
13
|
* This library is distributed in the hope that it will be useful,
|
14
14
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
15
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
16
16
|
* Lesser General Public License for more details.
|
17
|
-
*
|
17
|
+
*
|
18
18
|
* You should have received a copy of the GNU Lesser General Public
|
19
19
|
* License along with this library; if not, write to the Free Software
|
20
20
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
@@ -88,11 +88,17 @@ public class Vec2 extends RubyObject {
|
|
88
88
|
}
|
89
89
|
|
90
90
|
void init(ThreadContext context, IRubyObject[] args) {
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
jy = (args[1] instanceof RubyFloat)
|
95
|
-
|
91
|
+
int count = Arity.checkArgumentCount(context.runtime, args, Arity.OPTIONAL.getValue(), 2);
|
92
|
+
if (count == 2) {
|
93
|
+
jx = (args[0] instanceof RubyFloat) ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
94
|
+
jy = (args[1] instanceof RubyFloat) ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
95
|
+
} // allow ruby ducktyping in constructor
|
96
|
+
if (count == 1) {
|
97
|
+
if (!(args[0].respondsTo("x"))) {throw context.runtime.newTypeError(args[0].getType() + " doesn't respond_to :x & :y");}
|
98
|
+
jx = ((args[0].callMethod(context, "x")) instanceof RubyFloat)
|
99
|
+
? ((RubyFloat) args[0].callMethod(context, "x")).getValue() : ((RubyFixnum) args[0].callMethod(context, "x")).getDoubleValue();
|
100
|
+
jy = ((args[0].callMethod(context, "y")) instanceof RubyFloat)
|
101
|
+
? ((RubyFloat) args[0].callMethod(context, "y")).getValue() : ((RubyFixnum) args[0].callMethod(context, "y")).getDoubleValue();
|
96
102
|
}
|
97
103
|
}
|
98
104
|
|
@@ -153,9 +159,11 @@ public class Vec2 extends RubyObject {
|
|
153
159
|
Ruby runtime = context.runtime;
|
154
160
|
if (key instanceof RubySymbol) {
|
155
161
|
if (key == RubySymbol.newSymbol(runtime, "x")) {
|
156
|
-
|
162
|
+
jx = (value instanceof RubyFloat)
|
163
|
+
? ((RubyFloat) value).getValue() : ((RubyFixnum) value).getDoubleValue();
|
157
164
|
} else if (key == RubySymbol.newSymbol(runtime, "y")) {
|
158
|
-
|
165
|
+
jy = (value instanceof RubyFloat)
|
166
|
+
? ((RubyFloat) value).getValue() : ((RubyFixnum) value).getDoubleValue();
|
159
167
|
}
|
160
168
|
} else {
|
161
169
|
throw runtime.newIndexError("invalid key");
|
@@ -92,6 +92,19 @@ public final class Vec3 extends RubyObject {
|
|
92
92
|
if (count == 3) {
|
93
93
|
jz = (args[2] instanceof RubyFloat)
|
94
94
|
? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
|
95
|
+
} // allow ruby ducktyping in constructor
|
96
|
+
if (count == 1) {
|
97
|
+
if (!(args[0].respondsTo("x"))) {
|
98
|
+
throw context.runtime.newTypeError(args[0].getType() + " doesn't respond_to :x & :y");
|
99
|
+
}
|
100
|
+
jx = ((args[0].callMethod(context, "x")) instanceof RubyFloat)
|
101
|
+
? ((RubyFloat) args[0].callMethod(context, "x")).getValue() : ((RubyFixnum) args[0].callMethod(context, "x")).getDoubleValue();
|
102
|
+
jy = ((args[0].callMethod(context, "y")) instanceof RubyFloat)
|
103
|
+
? ((RubyFloat) args[0].callMethod(context, "y")).getValue() : ((RubyFixnum) args[0].callMethod(context, "y")).getDoubleValue();
|
104
|
+
if (!(args[0].respondsTo("z"))) {
|
105
|
+
return;
|
106
|
+
} // allow promotion from 2D to 3D, sets jz = 0
|
107
|
+
jz = ((args[0].callMethod(context, "z")) instanceof RubyFloat) ? ((RubyFloat) args[0].callMethod(context, "z")).getValue() : ((RubyFixnum) args[0].callMethod(context, "z")).getDoubleValue();
|
95
108
|
}
|
96
109
|
}
|
97
110
|
|
@@ -112,7 +125,6 @@ public final class Vec3 extends RubyObject {
|
|
112
125
|
* @return y IRubyObject
|
113
126
|
*/
|
114
127
|
@JRubyMethod(name = "y")
|
115
|
-
|
116
128
|
public IRubyObject getY(ThreadContext context) {
|
117
129
|
return context.runtime.newFloat(jy);
|
118
130
|
}
|
@@ -123,7 +135,8 @@ public final class Vec3 extends RubyObject {
|
|
123
135
|
* @return z IRubyObject
|
124
136
|
*/
|
125
137
|
@JRubyMethod(name = "z")
|
126
|
-
public IRubyObject getZ(ThreadContext context
|
138
|
+
public IRubyObject getZ(ThreadContext context
|
139
|
+
) {
|
127
140
|
return context.runtime.newFloat(jz);
|
128
141
|
}
|
129
142
|
|
@@ -134,7 +147,6 @@ public final class Vec3 extends RubyObject {
|
|
134
147
|
* @return x IRubyObject
|
135
148
|
*/
|
136
149
|
@JRubyMethod(name = "x=")
|
137
|
-
|
138
150
|
public IRubyObject setX(ThreadContext context, IRubyObject other) {
|
139
151
|
if (other instanceof RubyFloat) {
|
140
152
|
jx = ((RubyFloat) other).getValue();
|
@@ -151,7 +163,6 @@ public final class Vec3 extends RubyObject {
|
|
151
163
|
* @return y IRubyObject
|
152
164
|
*/
|
153
165
|
@JRubyMethod(name = "y=")
|
154
|
-
|
155
166
|
public IRubyObject setY(ThreadContext context, IRubyObject other) {
|
156
167
|
if (other instanceof RubyFloat) {
|
157
168
|
jy = ((RubyFloat) other).getValue();
|
@@ -184,7 +195,6 @@ public final class Vec3 extends RubyObject {
|
|
184
195
|
* @return value float
|
185
196
|
*/
|
186
197
|
@JRubyMethod(name = "[]", required = 1)
|
187
|
-
|
188
198
|
public IRubyObject aref(ThreadContext context, IRubyObject key) {
|
189
199
|
Ruby runtime = context.runtime;
|
190
200
|
if (key instanceof RubySymbol) {
|
@@ -209,7 +219,6 @@ public final class Vec3 extends RubyObject {
|
|
209
219
|
* @return value float
|
210
220
|
*/
|
211
221
|
@JRubyMethod(name = "[]=")
|
212
|
-
|
213
222
|
public IRubyObject aset(ThreadContext context, IRubyObject key, IRubyObject value) {
|
214
223
|
Ruby runtime = context.runtime;
|
215
224
|
if (key instanceof RubySymbol) {
|
@@ -337,7 +346,6 @@ public final class Vec3 extends RubyObject {
|
|
337
346
|
* @return new Vec3 object (ruby)
|
338
347
|
*/
|
339
348
|
@JRubyMethod(name = "-")
|
340
|
-
|
341
349
|
public IRubyObject op_sub(ThreadContext context, IRubyObject other) {
|
342
350
|
Ruby runtime = context.runtime;
|
343
351
|
Vec3 b = null;
|
@@ -359,7 +367,6 @@ public final class Vec3 extends RubyObject {
|
|
359
367
|
* @return new Vec3 object (ruby)
|
360
368
|
*/
|
361
369
|
@JRubyMethod(name = "*", required = 1)
|
362
|
-
|
363
370
|
public IRubyObject op_mul(ThreadContext context, IRubyObject scalar) {
|
364
371
|
Ruby runtime = context.runtime;
|
365
372
|
double multi = (scalar instanceof RubyFloat)
|
@@ -377,7 +384,6 @@ public final class Vec3 extends RubyObject {
|
|
377
384
|
* @return new Vec3 object (ruby)
|
378
385
|
*/
|
379
386
|
@JRubyMethod(name = "/", required = 1)
|
380
|
-
|
381
387
|
public IRubyObject op_div(ThreadContext context, IRubyObject scalar) {
|
382
388
|
Ruby runtime = context.runtime;
|
383
389
|
double divisor = (scalar instanceof RubyFloat)
|
@@ -397,7 +403,6 @@ public final class Vec3 extends RubyObject {
|
|
397
403
|
* @return magnitude squared IRubyObject
|
398
404
|
*/
|
399
405
|
@JRubyMethod(name = "mag_squared")
|
400
|
-
|
401
406
|
public IRubyObject mag_squared(ThreadContext context) {
|
402
407
|
return context.runtime.newFloat(jx * jx + jy * jy + jz * jz);
|
403
408
|
}
|
@@ -408,7 +413,6 @@ public final class Vec3 extends RubyObject {
|
|
408
413
|
* @return magnitude IRubyObject
|
409
414
|
*/
|
410
415
|
@JRubyMethod(name = "mag")
|
411
|
-
|
412
416
|
public IRubyObject mag(ThreadContext context) {
|
413
417
|
return context.runtime.newFloat(Math.sqrt(jx * jx + jy * jy + jz * jz));
|
414
418
|
}
|
@@ -423,7 +427,6 @@ public final class Vec3 extends RubyObject {
|
|
423
427
|
* @return magnitude IRubyObject
|
424
428
|
*/
|
425
429
|
@JRubyMethod(name = "set_mag")
|
426
|
-
|
427
430
|
public IRubyObject set_mag(ThreadContext context, IRubyObject scalar, Block block) {
|
428
431
|
if (block.isGiven()) {
|
429
432
|
if (!(boolean) block.yield(context, scalar).toJava(Boolean.class)) {
|
@@ -447,7 +450,6 @@ public final class Vec3 extends RubyObject {
|
|
447
450
|
* @return this as a ruby object
|
448
451
|
*/
|
449
452
|
@JRubyMethod(name = "normalize!")
|
450
|
-
|
451
453
|
public IRubyObject normalize_bang(ThreadContext context) {
|
452
454
|
if (Math.abs(jx) < EPSILON && Math.abs(jy) < EPSILON && Math.abs(jz) < EPSILON) {
|
453
455
|
return this;
|
@@ -465,7 +467,6 @@ public final class Vec3 extends RubyObject {
|
|
465
467
|
* @return new normalized Vec3D object (ruby)
|
466
468
|
*/
|
467
469
|
@JRubyMethod(name = "normalize")
|
468
|
-
|
469
470
|
public IRubyObject normalize(ThreadContext context) {
|
470
471
|
Ruby runtime = context.runtime;
|
471
472
|
double mag = Math.sqrt(jx * jx + jy * jy + jz * jz);
|
@@ -489,7 +490,6 @@ public final class Vec3 extends RubyObject {
|
|
489
490
|
* @return new random Vec3D object (ruby)
|
490
491
|
*/
|
491
492
|
@JRubyMethod(name = "random", meta = true)
|
492
|
-
|
493
493
|
public static IRubyObject random_direction(ThreadContext context, IRubyObject klazz) {
|
494
494
|
Ruby runtime = context.runtime;
|
495
495
|
double angle = Math.random() * Math.PI * 2;
|
@@ -510,7 +510,6 @@ public final class Vec3 extends RubyObject {
|
|
510
510
|
* @return angle IRubyObject in radians
|
511
511
|
*/
|
512
512
|
@JRubyMethod(name = "angle_between")
|
513
|
-
|
514
513
|
public IRubyObject angleBetween(ThreadContext context, IRubyObject other) {
|
515
514
|
Ruby runtime = context.runtime;
|
516
515
|
Vec3 vec = (Vec3) other.toJava(Vec3.class);
|
@@ -542,7 +541,6 @@ public final class Vec3 extends RubyObject {
|
|
542
541
|
* @return IRubyObject copy
|
543
542
|
*/
|
544
543
|
@JRubyMethod(name = {"copy", "dup"})
|
545
|
-
|
546
544
|
public IRubyObject copy(ThreadContext context) {
|
547
545
|
Ruby runtime = context.runtime;
|
548
546
|
return Vec3.rbNew(context, this.getMetaClass(), new IRubyObject[]{
|
@@ -557,7 +555,6 @@ public final class Vec3 extends RubyObject {
|
|
557
555
|
* @return IRubyObject array of float
|
558
556
|
*/
|
559
557
|
@JRubyMethod(name = "to_a")
|
560
|
-
|
561
558
|
public IRubyObject toArray(ThreadContext context) {
|
562
559
|
Ruby runtime = context.runtime;
|
563
560
|
return RubyArray.newArray(context.runtime, new IRubyObject[]{
|
@@ -573,7 +570,6 @@ public final class Vec3 extends RubyObject {
|
|
573
570
|
* @param object IRubyObject vertex renderer
|
574
571
|
*/
|
575
572
|
@JRubyMethod(name = "to_vertex")
|
576
|
-
|
577
573
|
public void toVertex(ThreadContext context, IRubyObject object) {
|
578
574
|
JRender renderer = (JRender) object.toJava(JRender.class);
|
579
575
|
renderer.vertex(jx, jy, jz);
|
@@ -586,7 +582,6 @@ public final class Vec3 extends RubyObject {
|
|
586
582
|
* @param object IRubyObject vertex renderer
|
587
583
|
*/
|
588
584
|
@JRubyMethod(name = "to_curve_vertex")
|
589
|
-
|
590
585
|
public void toCurveVertex(ThreadContext context, IRubyObject object) {
|
591
586
|
JRender renderer = (JRender) object.toJava(JRender.class);
|
592
587
|
renderer.curveVertex(jx, jy, jz);
|
@@ -599,7 +594,6 @@ public final class Vec3 extends RubyObject {
|
|
599
594
|
* @param args IRubyObject[]
|
600
595
|
*/
|
601
596
|
@JRubyMethod(name = "to_vertex_uv", rest = true)
|
602
|
-
|
603
597
|
public void toVertexUV(ThreadContext context, IRubyObject[] args) {
|
604
598
|
int count = Arity.checkArgumentCount(context.runtime, args, Arity.OPTIONAL.getValue(), 3);
|
605
599
|
double u = 0;
|
@@ -626,7 +620,6 @@ public final class Vec3 extends RubyObject {
|
|
626
620
|
* @param object IRubyObject vertex renderer
|
627
621
|
*/
|
628
622
|
@JRubyMethod(name = "to_normal")
|
629
|
-
|
630
623
|
public void toNormal(ThreadContext context, IRubyObject object) {
|
631
624
|
JRender renderer = (JRender) object.toJava(JRender.class);
|
632
625
|
renderer.normal(jx, jy, jz);
|
@@ -639,7 +632,6 @@ public final class Vec3 extends RubyObject {
|
|
639
632
|
* @return IRubyObject to_s
|
640
633
|
*/
|
641
634
|
@JRubyMethod(name = {"to_s", "inspect"})
|
642
|
-
|
643
635
|
public IRubyObject to_s(ThreadContext context) {
|
644
636
|
return context.runtime.newString(String.format("Vec3D(x = %4.4f, y = %4.4f, z = %4.4f)", jx, jy, jz));
|
645
637
|
}
|
@@ -688,7 +680,6 @@ public final class Vec3 extends RubyObject {
|
|
688
680
|
* @return result IRubyObject as boolean
|
689
681
|
*/
|
690
682
|
@JRubyMethod(name = "eql?", required = 1)
|
691
|
-
|
692
683
|
public IRubyObject eql_p(ThreadContext context, IRubyObject other) {
|
693
684
|
Ruby runtime = context.runtime;
|
694
685
|
if (other == this) {
|
@@ -713,7 +704,6 @@ public final class Vec3 extends RubyObject {
|
|
713
704
|
* @return result IRubyObject as boolean
|
714
705
|
*/
|
715
706
|
@JRubyMethod(name = "==", required = 1)
|
716
|
-
|
717
707
|
@Override
|
718
708
|
public IRubyObject op_equal(ThreadContext context, IRubyObject other) {
|
719
709
|
Ruby runtime = context.runtime;
|
data/test/vecmath_spec_test.rb
CHANGED
@@ -9,7 +9,14 @@ Dir.chdir(File.dirname(__FILE__))
|
|
9
9
|
|
10
10
|
class VecmathTest < Minitest::Test
|
11
11
|
|
12
|
-
|
12
|
+
# duck for Vec2D constructor
|
13
|
+
Point = Struct.new(:x, :y)
|
14
|
+
# duck for Vec3D constructor
|
15
|
+
Point3 = Struct.new(:x, :y, :z)
|
16
|
+
# non-duck to test fail
|
17
|
+
Pointless = Struct.new(:a, :b)
|
18
|
+
# non-duck to test fail
|
19
|
+
Pointless3 = Struct.new(:a, :b, :c)
|
13
20
|
def setup
|
14
21
|
|
15
22
|
end
|
@@ -17,7 +24,7 @@ class VecmathTest < Minitest::Test
|
|
17
24
|
def test_equals
|
18
25
|
x, y = 1.0000001, 1.01
|
19
26
|
a = Vec2D.new(x, y)
|
20
|
-
assert_equal(a.to_a, [x, y], 'Failed to return Vec2D as
|
27
|
+
assert_equal(a.to_a, [x, y], 'Failed to return Vec2D as an Array')
|
21
28
|
end
|
22
29
|
|
23
30
|
def test_not_equals
|
@@ -33,6 +40,25 @@ class VecmathTest < Minitest::Test
|
|
33
40
|
assert_equal(a.to_a, b.to_a, 'Failed deep copy')
|
34
41
|
end
|
35
42
|
|
43
|
+
def test_constructor_float
|
44
|
+
val = Point.new(1.0, 8.0) # duck type
|
45
|
+
expected = Vec2D.new(val)
|
46
|
+
assert_equal(expected, Vec2D.new(1.0, 8.0), 'Failed duck type constructor floats')
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_constructor_fixnum
|
50
|
+
val = Point.new(1, 8) # duck type fixnum
|
51
|
+
expected = Vec2D.new(val)
|
52
|
+
assert_equal(expected, Vec2D.new(1.0, 8.0), 'Failed duck type constructor fixnum')
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_failed_duck_type
|
56
|
+
val = Pointless.new(1.0, 8.0) # non duck type
|
57
|
+
assert_raises TypeError do
|
58
|
+
Vec2D.new(val)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
36
62
|
def test_copy_not_equals
|
37
63
|
x, y = 1.0000001, 1.01
|
38
64
|
a = Vec2D.new(x, y)
|
@@ -124,7 +150,7 @@ class VecmathTest < Minitest::Test
|
|
124
150
|
def test_dist
|
125
151
|
a = Vec2D.new(3, 5)
|
126
152
|
b = Vec2D.new(6, 7)
|
127
|
-
assert_in_epsilon(a.dist(b), Math.sqrt(3.0**2 + 2**2), 'Failed to return distance between two vectors')
|
153
|
+
assert_in_epsilon(a.dist(b), Math.sqrt(3.0**2 + 2**2), 0.001, 'Failed to return distance between two vectors')
|
128
154
|
end
|
129
155
|
|
130
156
|
def test_lerp
|
@@ -209,7 +235,7 @@ class VecmathTest < Minitest::Test
|
|
209
235
|
x = 10
|
210
236
|
b = Vec2D.new
|
211
237
|
b[:x] = x
|
212
|
-
assert_equal(
|
238
|
+
assert_equal(b, Vec2D.new(x, 0), 'Failed to hash assign')
|
213
239
|
end
|
214
240
|
|
215
241
|
def test_inspect
|
@@ -253,26 +279,45 @@ class VecmathTest < Minitest::Test
|
|
253
279
|
assert((a - b).cross(b - c).zero?, 'Failed collinearity test using 2D vector cross product')
|
254
280
|
end
|
255
281
|
|
256
|
-
def
|
282
|
+
def test_equals3
|
257
283
|
x, y, z = 1.0000001, 1.01, 0.0
|
258
284
|
a = Vec3D.new(x, y)
|
259
|
-
assert_equal(a.to_a, [x, y, z], 'Failed to return Vec3D as
|
285
|
+
assert_equal(a.to_a, [x, y, z], 'Failed to return Vec3D as an Array')
|
260
286
|
end
|
261
287
|
|
262
|
-
def
|
288
|
+
def test_constructor_float3
|
289
|
+
val = Point3.new(1.0, 8.0, 7.0) # duck type
|
290
|
+
expected = Vec3D.new(val)
|
291
|
+
assert_equal(expected, Vec3D.new(1.0, 8.0, 7.0), 'Failed duck type constructor floats')
|
292
|
+
end
|
293
|
+
|
294
|
+
def test_constructor_fixnum3
|
295
|
+
val = Point3.new(1, 8, 7) # duck type fixnum
|
296
|
+
expected = Vec3D.new(val)
|
297
|
+
assert_equal(expected, Vec3D.new(1.0, 8.0, 7.0), 'Failed duck type constructor fixnum')
|
298
|
+
end
|
299
|
+
|
300
|
+
def test_failed_duck_type3
|
301
|
+
val = Pointless3.new(1.0, 8.0, 7.0) # non duck type
|
302
|
+
assert_raises TypeError do
|
303
|
+
Vec3D.new(val)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
def test_not_equals3
|
263
308
|
a = Vec3D.new(3, 5, 1)
|
264
309
|
b = Vec3D.new(6, 7, 1)
|
265
310
|
refute_equal(a, b, 'Failed equals false')
|
266
311
|
end
|
267
312
|
|
268
|
-
def
|
313
|
+
def test_copy_equals3
|
269
314
|
x, y, z = 1.0000001, 1.01, 1
|
270
315
|
a = Vec3D.new(x, y, z)
|
271
316
|
b = a.copy
|
272
317
|
assert_equal(a.to_a, b.to_a, 'Failed deep copy')
|
273
318
|
end
|
274
319
|
|
275
|
-
def
|
320
|
+
def test_copy_not_equals3
|
276
321
|
x, y, z = 1.0000001, 1.01, 6.0
|
277
322
|
a = Vec3D.new(x, y, z)
|
278
323
|
b = a.copy
|
@@ -280,27 +325,27 @@ class VecmathTest < Minitest::Test
|
|
280
325
|
refute_equal(a.to_a, b.to_a, 'Failed deep copy')
|
281
326
|
end
|
282
327
|
|
283
|
-
def
|
328
|
+
def test_equals_when_close3
|
284
329
|
a = Vec3D.new(3.0000000, 5.00000, 2)
|
285
330
|
b = Vec3D.new(3.0000000, 5.000001, 2)
|
286
331
|
assert_equal(a, b, 'Failed to return equal when v. close')
|
287
332
|
end
|
288
333
|
|
289
|
-
def
|
334
|
+
def test_sum3
|
290
335
|
a = Vec3D.new(3, 5, 1)
|
291
336
|
b = Vec3D.new(6, 7, 1)
|
292
337
|
c = Vec3D.new(9, 12, 2)
|
293
338
|
assert_equal(a + b, c, 'Failed to sum vectors')
|
294
339
|
end
|
295
340
|
|
296
|
-
def
|
341
|
+
def test_subtract3
|
297
342
|
a = Vec3D.new(3, 5, 0)
|
298
343
|
b = Vec3D.new(6, 7, 1)
|
299
344
|
c = Vec3D.new(-3, -2, -1)
|
300
345
|
assert_equal(a - b, c, 'Failed to subtract vectors')
|
301
346
|
end
|
302
347
|
|
303
|
-
def
|
348
|
+
def test_multiply3
|
304
349
|
a = Vec3D.new(3, 5, 1)
|
305
350
|
b = 2
|
306
351
|
c = a * b
|
@@ -308,7 +353,7 @@ class VecmathTest < Minitest::Test
|
|
308
353
|
assert_equal(c, d, 'Failed to multiply vector by scalar')
|
309
354
|
end
|
310
355
|
|
311
|
-
def
|
356
|
+
def test_divide3
|
312
357
|
a = Vec3D.new(3, 5, 4)
|
313
358
|
b = 2
|
314
359
|
c = Vec3D.new(1.5, 2.5, 2)
|
@@ -316,112 +361,112 @@ class VecmathTest < Minitest::Test
|
|
316
361
|
assert_equal(c, d, 'Failed to divide vector by scalar')
|
317
362
|
end
|
318
363
|
|
319
|
-
def
|
364
|
+
def test_random3
|
320
365
|
a = Vec3D.random
|
321
366
|
assert a.kind_of? Vec3D
|
322
367
|
assert_in_epsilon(a.mag, 1.0)
|
323
368
|
end
|
324
369
|
|
325
|
-
def
|
370
|
+
def test_assign_value3
|
326
371
|
a = Vec3D.new(3, 5)
|
327
372
|
a.x=23
|
328
373
|
assert_equal(a.x, 23, 'Failed to assign x value')
|
329
374
|
end
|
330
375
|
|
331
|
-
def
|
376
|
+
def test_mag3
|
332
377
|
a = Vec3D.new(-3, -4)
|
333
378
|
assert_equal(a.mag, 5, 'Failed to return magnitude of vector')
|
334
379
|
end
|
335
380
|
|
336
|
-
def
|
381
|
+
def test_mag_variant3
|
337
382
|
a = Vec3D.new(3.0, 2)
|
338
383
|
b = Math.sqrt(3.0**2 + 2**2)
|
339
384
|
assert_in_epsilon(a.mag, b, 0.001, 'Failed to return magnitude of vector')
|
340
385
|
end
|
341
386
|
|
342
|
-
def
|
387
|
+
def test_mag_zero_one3
|
343
388
|
a = Vec3D.new(-1, 0)
|
344
389
|
assert_equal(a.mag, 1, 'Failed to return magnitude of vector')
|
345
390
|
end
|
346
391
|
|
347
|
-
def
|
392
|
+
def test_dist3
|
348
393
|
a = Vec3D.new(3, 5, 2)
|
349
394
|
b = Vec3D.new(6, 7, 1)
|
350
395
|
message = 'Failed to return distance between two vectors'
|
351
396
|
assert_equal(a.dist(b), Math.sqrt(3.0**2 + 2**2 + 1), message)
|
352
397
|
end
|
353
398
|
|
354
|
-
def
|
399
|
+
def test_dist_squared3
|
355
400
|
a = Vec3D.new(3, 5, 2)
|
356
401
|
b = Vec3D.new(6, 7, 1)
|
357
402
|
message = 'Failed to return distance squared between two vectors'
|
358
403
|
assert_equal(a.dist_squared(b), 3.0**2 + 2**2 + 1, message)
|
359
404
|
end
|
360
405
|
|
361
|
-
def
|
406
|
+
def test_dot3
|
362
407
|
a = Vec3D.new(10, 20, 0)
|
363
408
|
b = Vec3D.new(60, 80, 0)
|
364
409
|
assert_in_epsilon(a.dot(b), 2200.0, 0.001, 'Failed to dot product')
|
365
410
|
end
|
366
411
|
|
367
|
-
def
|
412
|
+
def test_self_dot3
|
368
413
|
a = Vec3D.new(10, 20, 4)
|
369
414
|
assert_in_epsilon(a.dot(a), 516.0, 0.001, 'Failed to self dot product')
|
370
415
|
end
|
371
416
|
|
372
|
-
def
|
417
|
+
def test_cross3
|
373
418
|
a = Vec3D.new(3, 5, 2)
|
374
419
|
b = Vec3D.new(6, 7, 1)
|
375
420
|
c = Vec3D.new(-9.0, 9.0, -9.0)
|
376
421
|
assert_equal(a.cross(b), c, 'Failed cross product')
|
377
422
|
end
|
378
423
|
|
379
|
-
def
|
424
|
+
def test_set_mag3
|
380
425
|
a = Vec3D.new(1, 1)
|
381
426
|
assert_equal(a.set_mag(Math.sqrt(32)), Vec3D.new(4, 4), 'Failed to set_mag vector')
|
382
427
|
end
|
383
428
|
|
384
|
-
def
|
429
|
+
def test_set_mag_block3
|
385
430
|
a = Vec3D.new(1, 1)
|
386
431
|
assert_equal(a.set_mag(Math.sqrt(32)) { true }, Vec3D.new(4, 4), 'Failed to set_mag_block true vector')
|
387
432
|
end
|
388
433
|
|
389
|
-
def
|
434
|
+
def test_set_mag_block_false3
|
390
435
|
a = Vec3D.new(1, 1)
|
391
436
|
assert_equal(a.set_mag(Math.sqrt(32)) { false }, Vec3D.new(1, 1), 'Failed to set_mag_block true vector')
|
392
437
|
end
|
393
438
|
|
394
|
-
def
|
439
|
+
def test_plus_assign3
|
395
440
|
a = Vec3D.new(3, 5)
|
396
441
|
b = Vec3D.new(6, 7)
|
397
442
|
a += b
|
398
443
|
assert_equal(a, Vec3D.new(9, 12), 'Failed to += assign')
|
399
444
|
end
|
400
445
|
|
401
|
-
def
|
446
|
+
def test_normalize3
|
402
447
|
a = Vec3D.new(3, 5)
|
403
448
|
b = a.normalize
|
404
449
|
assert_in_epsilon(b.mag, 1, 0.001, 'Failed to return a normalized vector')
|
405
450
|
end
|
406
451
|
|
407
|
-
def
|
452
|
+
def test_normalize3!
|
408
453
|
a = Vec3D.new(3, 5)
|
409
454
|
a.normalize!
|
410
455
|
assert_in_epsilon(a.mag, 1, 0.001, 'Failed to return a normalized! vector')
|
411
456
|
end
|
412
457
|
|
413
|
-
def
|
458
|
+
def test_inspect3
|
414
459
|
a = Vec3D.new(3, 2.000000000000001, 1)
|
415
460
|
assert_equal(a.inspect, 'Vec3D(x = 3.0000, y = 2.0000, z = 1.0000)')
|
416
461
|
end
|
417
462
|
|
418
|
-
def
|
463
|
+
def test_array_reduce3
|
419
464
|
array = [Vec3D.new(1, 2), Vec3D.new(10, 2), Vec3D.new(1, 2)]
|
420
465
|
sum = array.reduce(Vec3D.new) { |c, d| c + d }
|
421
466
|
assert_equal(sum, Vec3D.new(12, 6))
|
422
467
|
end
|
423
468
|
|
424
|
-
def
|
469
|
+
def test_array_zip3
|
425
470
|
one = [Vec3D.new(1, 2), Vec3D.new(10, 2), Vec3D.new(1, 2)]
|
426
471
|
two = [Vec3D.new(1, 2), Vec3D.new(10, 2), Vec3D.new(1, 2)]
|
427
472
|
zipped = one.zip(two).flatten
|
@@ -429,30 +474,30 @@ class VecmathTest < Minitest::Test
|
|
429
474
|
assert_equal(zipped, expected)
|
430
475
|
end
|
431
476
|
|
432
|
-
def
|
477
|
+
def test_eql3?
|
433
478
|
a = Vec3D.new(3.0, 5.0, 0)
|
434
479
|
b = Vec3D.new(3.0, 5.0, 0)
|
435
480
|
assert(a.eql?(b))
|
436
481
|
end
|
437
482
|
|
438
|
-
def
|
483
|
+
def test_not_eql3?
|
439
484
|
a = Vec3D.new(3.0, 5.0, 0)
|
440
485
|
b = Vec3D.new(3.0, 5.000001, 0)
|
441
486
|
refute(a.eql?(b))
|
442
487
|
end
|
443
488
|
|
444
|
-
def
|
489
|
+
def test_equal3?
|
445
490
|
a = Vec3D.new(3.0, 5.0, 0)
|
446
491
|
assert(a.equal?(a))
|
447
492
|
end
|
448
493
|
|
449
|
-
def
|
494
|
+
def test_not_equal3?
|
450
495
|
a = Vec3D.new(3.0, 5.0, 0)
|
451
496
|
b = Vec3D.new(3.0, 5.0, 0)
|
452
497
|
refute(a.equal?(b))
|
453
498
|
end
|
454
499
|
|
455
|
-
def
|
500
|
+
def test_hash_key3
|
456
501
|
x, y, z = 10, 20, 50
|
457
502
|
b = Vec3D.new(x, y, z)
|
458
503
|
assert_equal(b[:x], x, 'Failed hash key access')
|
@@ -460,7 +505,7 @@ class VecmathTest < Minitest::Test
|
|
460
505
|
assert_equal(b[:z], z, 'Failed hash key access')
|
461
506
|
end
|
462
507
|
|
463
|
-
def
|
508
|
+
def test_hash_set3
|
464
509
|
x = 10
|
465
510
|
b = Vec3D.new
|
466
511
|
b[:x] = x
|
data/vendors/Rakefile
CHANGED
@@ -10,7 +10,7 @@ SOUND_VERSION = 'v1.3.2' # version 1.3.2
|
|
10
10
|
GLVIDEO = 'processing-glvideo.zip'
|
11
11
|
VIDEO = 'video-2.zip'
|
12
12
|
VIDEO_VERSION = '2' # version 1.0.1
|
13
|
-
EXAMPLES = '1.
|
13
|
+
EXAMPLES = '1.9'.freeze
|
14
14
|
HOME_DIR = ENV['HOME']
|
15
15
|
MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig::CONFIG['host_os']
|
16
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: propane
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.4
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- monkstone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '12'
|
19
|
+
version: '12.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '12'
|
26
|
+
version: '12.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,10 +58,8 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 1.0.0
|
61
|
-
description:
|
62
|
-
|
63
|
-
current release features several PixelFlow glsl library examples, including a
|
64
|
-
few shadertoy demos as sketches.
|
61
|
+
description: " A batteries included version of processing in ruby, for MacOS and
|
62
|
+
linux64.\n"
|
65
63
|
email:
|
66
64
|
- mamba2928@yahoo.co.uk
|
67
65
|
executables:
|
@@ -113,6 +111,7 @@ files:
|
|
113
111
|
- library/library_proxy/library_proxy.rb
|
114
112
|
- library/simplex_noise/simplex_noise.rb
|
115
113
|
- library/slider/slider.rb
|
114
|
+
- library/vector_utils/vector_utils.rb
|
116
115
|
- library/video_event/video_event.rb
|
117
116
|
- pom.rb
|
118
117
|
- pom.xml
|
@@ -173,9 +172,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
172
|
- - ">="
|
174
173
|
- !ruby/object:Gem::Version
|
175
174
|
version: '0'
|
176
|
-
requirements:
|
175
|
+
requirements:
|
176
|
+
- java runtime >= 1.8.0_151+
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.7.
|
178
|
+
rubygems_version: 2.7.6
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: ruby wrapper for processing-3.3.6 on MacOS and linux64 bit only for opengl
|