propane 2.1.0-java → 2.1.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -12
- data/CHANGELOG.md +3 -1
- data/README.md +6 -6
- data/Rakefile +1 -0
- data/lib/propane/version.rb +1 -1
- data/pom.rb +6 -20
- data/pom.xml +6 -22
- data/propane.gemspec +5 -7
- data/test/test_create.rb +91 -0
- data/test/test_deglut_spec.rb +25 -0
- data/test/test_helper.rb +5 -0
- data/test/test_math_tool.rb +71 -0
- data/test/test_respond_to.rb +213 -0
- data/test/vecmath_spec_test.rb +472 -0
- data/vendors/Rakefile +1 -1
- metadata +20 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96c47e1ea96be925869f7a77d1a6753c24bc9b3b
|
4
|
+
data.tar.gz: 3485ff56e4408d1eda441481122c28ea7ddf5cfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1ddb3cdc5dbbb9023512732f5fbcd4c9453483ebd90ea002c72c995bba5043a6843dfa4938db4d224e49736fcb48649842a55ec7ec4cd842c4c29b3c73dc31d
|
7
|
+
data.tar.gz: 446e7701836640a03f992541e83bfe7d7265c0485d28fc8372fbdb28d184882700df0b7a537a40672011dd0d869b8950032ccce491e0a70db848ea8128e018b1
|
data/.travis.yml
CHANGED
@@ -1,21 +1,10 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
|
-
addons:
|
4
|
-
apt:
|
5
|
-
packages:
|
6
|
-
-oracle-java8-installer
|
7
|
-
-xvfb
|
8
|
-
-libxrender1
|
9
|
-
-libxtst6
|
10
|
-
-libxi6
|
11
3
|
|
12
4
|
rvm:
|
13
|
-
- jruby-9.1.
|
5
|
+
- jruby-9.1.6.0
|
14
6
|
jdk:
|
15
7
|
- oraclejdk8
|
16
8
|
os:
|
17
9
|
- linux
|
18
|
-
env:
|
19
|
-
- Xvfb :1 -screen 0 1024x768x24
|
20
|
-
- export DISPLAY=":1"
|
21
10
|
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
**v2.1.
|
1
|
+
**v2.1.1** Update to core processing-3.2.4 and JRuby-9.1.7.0
|
2
|
+
|
3
|
+
**v2.1.0** Add missing method to ColorUtil.java, `include HelperMethods, PConstants, Math, MathTool` in `Propane::Proxy`, it is just simpler that way. Mixin Renderer for AppRender and ShapeRender. Changes to `Propane::Proxy` are significant enough to warrant versioning bump, samples making use of new code will not be runable by earlier versions.
|
2
4
|
|
3
5
|
**v2.0.6** Update to core processing-3.2.3
|
4
6
|
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# Propane
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/propane.svg)](https://badge.fury.io/rb/propane)
|
3
3
|
|
4
|
-
A slim layer to communicate with Processing from JRuby, features a polyglot maven build. We have created a configuration free version of ruby processing, for processing-3.2.
|
4
|
+
A slim layer to communicate with Processing from JRuby, features a polyglot maven build. We have created a configuration free version of ruby processing, for processing-3.2.4, where we include processing core (from a local maven repository and opengl etc from maven central). These jars are small enough to include in a gem distribution, and hence we do not require configuration. This has created a scriptable version, ie files get run direct from jruby, but you could use jruby-complete if you used the propane script (avoids need to give the absolute data path for the data folder, but would also be needed for a watch mode). NB: for linux64 and macOS opengl binaries use latest relaease. See guide to [building ruby-processing projects][building].
|
5
5
|
|
6
6
|
## Requirements
|
7
7
|
|
8
|
-
- jdk8+
|
9
|
-
- jruby-9.1.
|
8
|
+
- jdk8+
|
9
|
+
- jruby-9.1.7.0+
|
10
10
|
- mvn-3.3.1+ (development only)
|
11
|
-
- core.jar processing-3.2.
|
11
|
+
- core.jar processing-3.2.4 (development only until processing.org is available at maven central)
|
12
12
|
|
13
13
|
## Building and testing
|
14
14
|
|
@@ -20,8 +20,8 @@ rake javadoc
|
|
20
20
|
|
21
21
|
## Installation
|
22
22
|
```bash
|
23
|
-
jgem install propane
|
24
|
-
jgem install propane #
|
23
|
+
jgem install propane # from rubygems
|
24
|
+
jgem install propane-2.1.1-java.gem # for local install
|
25
25
|
```
|
26
26
|
|
27
27
|
## Usage
|
data/Rakefile
CHANGED
data/lib/propane/version.rb
CHANGED
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.1.
|
4
|
+
id 'propane:propane', '2.1.1'
|
5
5
|
packaging 'jar'
|
6
6
|
description 'rp5extras for propane'
|
7
7
|
organization 'ruby-processing', 'https://ruby-processing.github.io'
|
@@ -32,8 +32,8 @@ 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.
|
36
|
-
jar 'org.processing:core:3.2.
|
35
|
+
pom 'org.jruby:jruby:9.1.7.0'
|
36
|
+
jar 'org.processing:core:3.2.4'
|
37
37
|
jar 'org.processing:video:3.0.2'
|
38
38
|
jar('org.jogamp.jogl:jogl-all:${jogl.version}')
|
39
39
|
jar('org.jogamp.gluegen:gluegen-rt-main:${jogl.version}')
|
@@ -44,7 +44,7 @@ project 'rp5extras', 'https://github.com/monkstone/propane' do
|
|
44
44
|
execute_goals( id: 'default-cli',
|
45
45
|
artifactItems: [ { groupId: 'org.processing',
|
46
46
|
artifactId: 'core',
|
47
|
-
version: '3.2.
|
47
|
+
version: '3.2.4',
|
48
48
|
type: 'jar',
|
49
49
|
outputDirectory: '${propane.basedir}/lib'
|
50
50
|
},
|
@@ -63,7 +63,7 @@ project 'rp5extras', 'https://github.com/monkstone/propane' do
|
|
63
63
|
{ groupId: 'org.jogamp.jogl',
|
64
64
|
artifactId: 'jogl-all',
|
65
65
|
version: '${jogl.version}',
|
66
|
-
classifier: 'natives-linux-
|
66
|
+
classifier: 'natives-linux-armv6hf',
|
67
67
|
type: 'jar',
|
68
68
|
outputDirectory: '${propane.basedir}/lib'
|
69
69
|
},
|
@@ -71,21 +71,7 @@ project 'rp5extras', 'https://github.com/monkstone/propane' do
|
|
71
71
|
artifactId: 'gluegen-rt',
|
72
72
|
version: '${jogl.version}',
|
73
73
|
type: 'jar',
|
74
|
-
classifier: 'natives-linux-
|
75
|
-
outputDirectory: '${propane.basedir}/lib'
|
76
|
-
},
|
77
|
-
{ groupId: 'org.jogamp.jogl',
|
78
|
-
artifactId: 'jogl-all',
|
79
|
-
version: '${jogl.version}',
|
80
|
-
classifier: 'natives-macosx-universal',
|
81
|
-
type: 'jar',
|
82
|
-
outputDirectory: '${propane.basedir}/lib'
|
83
|
-
},
|
84
|
-
{ groupId: 'org.jogamp.gluegen',
|
85
|
-
artifactId: 'gluegen-rt',
|
86
|
-
version: '${jogl.version}',
|
87
|
-
type: 'jar',
|
88
|
-
classifier: 'natives-macosx-universal',
|
74
|
+
classifier: 'natives-linux-armv6hf',
|
89
75
|
outputDirectory: '${propane.basedir}/lib'
|
90
76
|
}
|
91
77
|
]
|
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.1.
|
14
|
+
<version>2.1.1</version>
|
15
15
|
<name>rp5extras</name>
|
16
16
|
<description>rp5extras for propane</description>
|
17
17
|
<url>https://github.com/monkstone/propane</url>
|
@@ -58,13 +58,13 @@ 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.7.0</version>
|
62
62
|
<type>pom</type>
|
63
63
|
</dependency>
|
64
64
|
<dependency>
|
65
65
|
<groupId>org.processing</groupId>
|
66
66
|
<artifactId>core</artifactId>
|
67
|
-
<version>3.2.
|
67
|
+
<version>3.2.4</version>
|
68
68
|
</dependency>
|
69
69
|
<dependency>
|
70
70
|
<groupId>org.processing</groupId>
|
@@ -103,7 +103,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
103
103
|
<artifactItem>
|
104
104
|
<groupId>org.processing</groupId>
|
105
105
|
<artifactId>core</artifactId>
|
106
|
-
<version>3.2.
|
106
|
+
<version>3.2.4</version>
|
107
107
|
<type>jar</type>
|
108
108
|
<outputDirectory>${propane.basedir}/lib</outputDirectory>
|
109
109
|
</artifactItem>
|
@@ -125,7 +125,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
125
125
|
<groupId>org.jogamp.jogl</groupId>
|
126
126
|
<artifactId>jogl-all</artifactId>
|
127
127
|
<version>${jogl.version}</version>
|
128
|
-
<classifier>natives-linux-
|
128
|
+
<classifier>natives-linux-armv6hf</classifier>
|
129
129
|
<type>jar</type>
|
130
130
|
<outputDirectory>${propane.basedir}/lib</outputDirectory>
|
131
131
|
</artifactItem>
|
@@ -134,23 +134,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
134
134
|
<artifactId>gluegen-rt</artifactId>
|
135
135
|
<version>${jogl.version}</version>
|
136
136
|
<type>jar</type>
|
137
|
-
<classifier>natives-linux-
|
138
|
-
<outputDirectory>${propane.basedir}/lib</outputDirectory>
|
139
|
-
</artifactItem>
|
140
|
-
<artifactItem>
|
141
|
-
<groupId>org.jogamp.jogl</groupId>
|
142
|
-
<artifactId>jogl-all</artifactId>
|
143
|
-
<version>${jogl.version}</version>
|
144
|
-
<classifier>natives-macosx-universal</classifier>
|
145
|
-
<type>jar</type>
|
146
|
-
<outputDirectory>${propane.basedir}/lib</outputDirectory>
|
147
|
-
</artifactItem>
|
148
|
-
<artifactItem>
|
149
|
-
<groupId>org.jogamp.gluegen</groupId>
|
150
|
-
<artifactId>gluegen-rt</artifactId>
|
151
|
-
<version>${jogl.version}</version>
|
152
|
-
<type>jar</type>
|
153
|
-
<classifier>natives-macosx-universal</classifier>
|
137
|
+
<classifier>natives-linux-armv6hf</classifier>
|
154
138
|
<outputDirectory>${propane.basedir}/lib</outputDirectory>
|
155
139
|
</artifactItem>
|
156
140
|
</artifactItems>
|
data/propane.gemspec
CHANGED
@@ -9,18 +9,16 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.authors = ['monkstone']
|
10
10
|
gem.email = ['mamba2928@yahoo.co.uk']
|
11
11
|
gem.licenses = %w(GPL-3.0 LGPL-2.0)
|
12
|
-
gem.description = %q{A batteries included version of processing in ruby,
|
13
|
-
gem.summary = %q{
|
12
|
+
gem.description = %q{A batteries included version of processing in ruby, MacOS and linux64}
|
13
|
+
gem.summary = %q{ruby wrapper for processing-3.2.4 on MacOS and linux64 bit only for opengl}
|
14
14
|
gem.homepage = 'https://ruby-processing.github.io/propane/'
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.files << 'lib/propane.jar'
|
17
|
-
gem.files << 'lib/core-3.2.
|
17
|
+
gem.files << 'lib/core-3.2.4.jar'
|
18
18
|
gem.files << 'lib/gluegen-rt-2.3.2.jar'
|
19
19
|
gem.files << 'lib/jogl-all-2.3.2.jar'
|
20
|
-
gem.files << 'lib/gluegen-rt-2.3.2-natives-linux-
|
21
|
-
gem.files << 'lib/
|
22
|
-
gem.files << 'lib/jogl-all-2.3.2-natives-linux-amd64.jar'
|
23
|
-
gem.files << 'lib/jogl-all-2.3.2-natives-macosx-universal.jar'
|
20
|
+
gem.files << 'lib/gluegen-rt-2.3.2-natives-linux-armv6hf.jar'
|
21
|
+
gem.files << 'lib/jogl-all-2.3.2-natives-linux-armv6hf.jar'
|
24
22
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
25
23
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
26
24
|
gem.add_runtime_dependency 'arcball', '~> 0.0.3'
|
data/test/test_create.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'test_helper'
|
3
|
+
|
4
|
+
|
5
|
+
require_relative '../lib/propane/creators/sketch_class'
|
6
|
+
|
7
|
+
CLASS_SKETCH = <<~CODE
|
8
|
+
# frozen_string_literal: false
|
9
|
+
require 'propane'
|
10
|
+
|
11
|
+
class FredSketch < Propane::App
|
12
|
+
def settings
|
13
|
+
size 200, 200
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup
|
17
|
+
sketch_title 'Fred Sketch'
|
18
|
+
end
|
19
|
+
|
20
|
+
def draw
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
FredSketch.new
|
26
|
+
|
27
|
+
CODE
|
28
|
+
|
29
|
+
BARE_SKETCH = <<~CODE
|
30
|
+
def settings
|
31
|
+
size 200, 200, P2D
|
32
|
+
end
|
33
|
+
|
34
|
+
def setup
|
35
|
+
sketch_title 'Fred Sketch'
|
36
|
+
end
|
37
|
+
|
38
|
+
def draw
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
CODE
|
43
|
+
|
44
|
+
class SketchClassTest < Minitest::Test
|
45
|
+
|
46
|
+
def setup
|
47
|
+
@basic = SketchClass.new(name: 'fred_sketch', width: 200, height: 200)
|
48
|
+
@sketch = SketchClass.new(name: 'fred_sketch', width: 200, height: 200, mode: 'p2d')
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_class
|
52
|
+
result = CLASS_SKETCH.split(/\n/, -1)
|
53
|
+
class_lines = @sketch.lines
|
54
|
+
class_lines.each_with_index do |line, i|
|
55
|
+
assert_equal result[i], line
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_indent
|
60
|
+
assert_equal ' indent', @sketch.indent('indent')
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_size
|
64
|
+
assert_equal ' size 200, 200, P2D', @sketch.size
|
65
|
+
assert_equal ' size 200, 200', @basic.size
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_sketch_title
|
69
|
+
assert_equal " sketch_title 'Fred Sketch'", @sketch.sketch_title
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_class
|
73
|
+
assert_equal "FredSketch", @sketch.sketch_class
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_class_new
|
77
|
+
assert_equal "FredSketch.new", @sketch.sketch_new
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_method_lines
|
81
|
+
result = CLASS_SKETCH.split(/\n/, -1)
|
82
|
+
@basic.method_lines('settings', @basic.size).each_with_index do |line, i|
|
83
|
+
assert_equal result[i + 4], line
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def test_sketch_class
|
89
|
+
assert_equal "class FredSketch < Propane::App", @basic.class_sketch
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'test_helper'
|
3
|
+
|
4
|
+
Java::Monkstone::PropaneLibrary.load(JRuby.runtime)
|
5
|
+
|
6
|
+
Dir.chdir(File.dirname(__FILE__))
|
7
|
+
|
8
|
+
class DeglutTest < Minitest::Test
|
9
|
+
attr_reader :to_radian
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@to_radian = Math::PI / 180
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_cos_sin
|
16
|
+
(-720..720).step(1) do |deg|
|
17
|
+
sine = DegLut.sin(deg)
|
18
|
+
deg_sin = Math.sin(deg * to_radian)
|
19
|
+
assert_in_delta(sine, deg_sin, delta = 0.000001)
|
20
|
+
cosine = DegLut.cos(deg)
|
21
|
+
deg_cos = Math.cos(deg * to_radian)
|
22
|
+
assert_in_delta(cosine, deg_cos, delta = 0.000001)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'test_helper'
|
3
|
+
|
4
|
+
Java::Monkstone::PropaneLibrary.new.load(JRuby.runtime, false)
|
5
|
+
|
6
|
+
Dir.chdir(File.dirname(__FILE__))
|
7
|
+
|
8
|
+
class MathToolTest < Minitest::Test
|
9
|
+
include MathTool
|
10
|
+
def test_map1d
|
11
|
+
x = [0, 5, 7.5, 10]
|
12
|
+
range1 = (0..10)
|
13
|
+
range2 = (100..1)
|
14
|
+
range3 = (0..10)
|
15
|
+
range4 = (5..105)
|
16
|
+
assert_in_delta(map1d(x[0], range1, range2), 100, delta = 0.00001, msg = 'map to first')
|
17
|
+
assert_in_delta(map1d(x[1], range1, range2), 50.5, delta = 0.00001, msg = 'map to reversed intermediate')
|
18
|
+
assert_in_delta(map1d(x[2], range3, range4), 80.0, delta = 0.00001, msg = 'map to intermediate')
|
19
|
+
assert_in_delta(map1d(x[3], range1, range2), 1, delta = 0.00001, msg = 'map to last')
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_p5map # as map1d except not using range input
|
23
|
+
x = [0, 5, 7.5, 10]
|
24
|
+
range1 = (0..10)
|
25
|
+
range2 = (100..1)
|
26
|
+
range3 = (0..10)
|
27
|
+
range4 = (5..105)
|
28
|
+
assert_in_delta(p5map(x[0], range1.first, range1.last, range2.first, range2.last), 100, delta = 0.00001)
|
29
|
+
assert_in_delta(p5map(x[1], range1.first, range1.last, range2.first, range2.last), 50.5, delta = 0.00001)
|
30
|
+
assert_in_delta(p5map(x[2], range3.first, range3.last, range4.first, range4.last), 80.0, delta = 0.00001)
|
31
|
+
assert_in_delta(p5map(x[3], range1.first, range1.last, range2.first, range2.last), 1, delta = 0.00001)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_norm
|
35
|
+
x = [10, 140, 210]
|
36
|
+
start0, last0 = 30, 200
|
37
|
+
start_int, last_int = 0, 200
|
38
|
+
assert_in_delta(norm(x[0], start0, last0), -0.11764705882352941, delta = 0.00001, msg = 'unclamped map')
|
39
|
+
assert_in_delta(norm(x[1], start_int, last_int), 0.7, delta = 0.00001, msg = 'map to intermediate')
|
40
|
+
assert_in_delta(norm(x[2], start_int, last_int), 1.05, delta = 0.00001, msg = 'unclamped map')
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_norm_strict
|
44
|
+
x = [10, 140, 210]
|
45
|
+
assert_in_delta(norm_strict(x[2], x[0], x[1]), 1.0, delta = 0.00001, msg = 'clamped map to 0..1.0')
|
46
|
+
assert_in_delta(norm_strict(x[2], x[1], x[0]), 0.0, delta = 0.00001, msg = 'clamped map to 0..1.0')
|
47
|
+
assert_in_delta(norm_strict(x[1], x[0], x[2]), 0.65, delta = 0.00001, msg = 'clamped map to 0..1.0')
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_lerp # behaviour is deliberately different to processing which is unclamped
|
51
|
+
x = [0.5, 0.8, 2.0]
|
52
|
+
start0, last0 = 300, 200
|
53
|
+
start_int, last_int = 0, 200
|
54
|
+
assert_in_delta(lerp(start0, last0, x[0]), 250, delta = 0.00001, msg = 'produces a intermediate value of a reversed range')
|
55
|
+
assert_in_delta(lerp(start_int, last_int, x[1]), 160, delta = 0.00001, msg = 'lerps to an intermediate value')
|
56
|
+
assert_in_delta(lerp(start_int, last_int, x[2]), 200, delta = 0.00001, msg = 'lerps to the last value of a range')
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_constrain
|
60
|
+
x_int = [15, 2_500, -2_500]
|
61
|
+
start_int, last_int = 0, 200
|
62
|
+
assert_in_delta(constrain(x_int[0], start_int, last_int), 15, delta = 0.00001)
|
63
|
+
assert_in_delta(constrain(x_int[1], start_int, last_int), 200, delta = 0.00001)
|
64
|
+
assert_in_delta(constrain(x_int[2], start_int, last_int), 0, delta = 0.00001)
|
65
|
+
xf = [15.0, 2_500.0, -2_500.0]
|
66
|
+
startf, lastf = 0, 200.0
|
67
|
+
assert_in_delta(constrain(xf[0], startf, lastf), 15.0, delta = 0.00001, msg = 'constrain to 0..200')
|
68
|
+
assert_in_delta(constrain(xf[1], startf, lastf), 200.0, delta = 0.00001, msg = 'constrain to 0..200')
|
69
|
+
assert_in_delta(constrain(xf[2], startf, lastf), 0.0, delta = 0.00001, msg = 'constrain to 0..200')
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,213 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'test_helper'
|
3
|
+
|
4
|
+
METHODS = %i(
|
5
|
+
alpha
|
6
|
+
ambient
|
7
|
+
ambient_light
|
8
|
+
apply_matrix
|
9
|
+
arc
|
10
|
+
background
|
11
|
+
begin_camera
|
12
|
+
begin_contour
|
13
|
+
begin_raw
|
14
|
+
begin_record
|
15
|
+
begin_shape
|
16
|
+
bezier
|
17
|
+
bezier_detail
|
18
|
+
bezier_point
|
19
|
+
bezier_tangent
|
20
|
+
bezier_vertex
|
21
|
+
blend
|
22
|
+
blend_mode
|
23
|
+
blue
|
24
|
+
box
|
25
|
+
brightness
|
26
|
+
camera
|
27
|
+
color
|
28
|
+
color_mode
|
29
|
+
copy
|
30
|
+
create_font
|
31
|
+
create_graphics
|
32
|
+
create_image
|
33
|
+
create_input
|
34
|
+
create_output
|
35
|
+
create_reader
|
36
|
+
create_shape
|
37
|
+
create_writer
|
38
|
+
cursor
|
39
|
+
curve
|
40
|
+
curve_detail
|
41
|
+
curve_point
|
42
|
+
curve_tangent
|
43
|
+
curve_tightness
|
44
|
+
curve_vertex
|
45
|
+
directional_light
|
46
|
+
ellipse
|
47
|
+
ellipse_mode
|
48
|
+
emissive
|
49
|
+
end_camera
|
50
|
+
end_contour
|
51
|
+
end_raw
|
52
|
+
end_record
|
53
|
+
end_shape
|
54
|
+
fill
|
55
|
+
filter
|
56
|
+
focused
|
57
|
+
frame_count
|
58
|
+
frame_rate
|
59
|
+
frame_rate
|
60
|
+
frustum
|
61
|
+
get
|
62
|
+
green
|
63
|
+
height
|
64
|
+
hue
|
65
|
+
image
|
66
|
+
image_mode
|
67
|
+
key
|
68
|
+
key_code
|
69
|
+
key_pressed
|
70
|
+
key_pressed?
|
71
|
+
key_released
|
72
|
+
key_typed
|
73
|
+
lerp_color
|
74
|
+
light_falloff
|
75
|
+
light_specular
|
76
|
+
lights
|
77
|
+
line
|
78
|
+
load_bytes
|
79
|
+
load_font
|
80
|
+
load_image
|
81
|
+
load_pixels
|
82
|
+
load_shader
|
83
|
+
load_shape
|
84
|
+
load_strings
|
85
|
+
load_table
|
86
|
+
load_xml
|
87
|
+
model_x
|
88
|
+
model_y
|
89
|
+
model_z
|
90
|
+
mouse_button
|
91
|
+
mouse_clicked
|
92
|
+
mouse_dragged
|
93
|
+
mouse_moved
|
94
|
+
mouse_pressed
|
95
|
+
mouse_pressed?
|
96
|
+
mouse_released
|
97
|
+
mouse_x
|
98
|
+
mouse_y
|
99
|
+
no_cursor
|
100
|
+
no_fill
|
101
|
+
no_lights
|
102
|
+
no_smooth
|
103
|
+
no_stroke
|
104
|
+
no_tint
|
105
|
+
noise
|
106
|
+
noise_detail
|
107
|
+
noise_seed
|
108
|
+
normal
|
109
|
+
ortho
|
110
|
+
perspective
|
111
|
+
pixels
|
112
|
+
pmouse_x
|
113
|
+
pmouse_y
|
114
|
+
point
|
115
|
+
point_light
|
116
|
+
pop_matrix
|
117
|
+
print_camera
|
118
|
+
print_matrix
|
119
|
+
print_projection
|
120
|
+
push_matrix
|
121
|
+
quad
|
122
|
+
quadratic_vertex
|
123
|
+
random
|
124
|
+
random_seed
|
125
|
+
rect
|
126
|
+
rect_mode
|
127
|
+
red
|
128
|
+
request_image
|
129
|
+
reset_matrix
|
130
|
+
reset_shader
|
131
|
+
rotate
|
132
|
+
rotate_x
|
133
|
+
rotate_y
|
134
|
+
rotate_z
|
135
|
+
saturation
|
136
|
+
save
|
137
|
+
save_bytes
|
138
|
+
save_frame
|
139
|
+
save_stream
|
140
|
+
save_strings
|
141
|
+
scale
|
142
|
+
screen_x
|
143
|
+
screen_y
|
144
|
+
screen_z
|
145
|
+
select_folder
|
146
|
+
select_input
|
147
|
+
select_output
|
148
|
+
set
|
149
|
+
shader
|
150
|
+
shape
|
151
|
+
shape_mode
|
152
|
+
shear_x
|
153
|
+
shear_y
|
154
|
+
shininess
|
155
|
+
sketch_title
|
156
|
+
size
|
157
|
+
smooth
|
158
|
+
specular
|
159
|
+
sphere
|
160
|
+
sphere_detail
|
161
|
+
spot_light
|
162
|
+
stroke
|
163
|
+
stroke_cap
|
164
|
+
stroke_join
|
165
|
+
stroke_weight
|
166
|
+
text_align
|
167
|
+
text_ascent
|
168
|
+
text_descent
|
169
|
+
text_font
|
170
|
+
text_leading
|
171
|
+
text_mode
|
172
|
+
text_size
|
173
|
+
text_width
|
174
|
+
texture
|
175
|
+
texture_mode
|
176
|
+
texture_wrap
|
177
|
+
tint
|
178
|
+
translate
|
179
|
+
triangle
|
180
|
+
update_pixels
|
181
|
+
vertex
|
182
|
+
width
|
183
|
+
)
|
184
|
+
|
185
|
+
class TestSketch < Propane::App
|
186
|
+
def settings
|
187
|
+
size 100, 100
|
188
|
+
end
|
189
|
+
|
190
|
+
def setup
|
191
|
+
sketch_title 'Sketch Test'
|
192
|
+
end
|
193
|
+
|
194
|
+
def draw
|
195
|
+
exit if frame_count > 30
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
class SpecTest < Minitest::Test
|
200
|
+
def setup
|
201
|
+
@processing_sketch = TestSketch.new
|
202
|
+
end
|
203
|
+
|
204
|
+
def test_respond
|
205
|
+
METHODS.each do |method_string|
|
206
|
+
assert_respond_to @processing_sketch, method_string
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def tear_down
|
211
|
+
@processing_sketch = nil?
|
212
|
+
end
|
213
|
+
end
|
@@ -0,0 +1,472 @@
|
|
1
|
+
gem 'minitest' # don't use bundled minitest
|
2
|
+
require 'java'
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'minitest/pride'
|
5
|
+
|
6
|
+
require_relative '../lib/propane'
|
7
|
+
|
8
|
+
Java::Monkstone::PropaneLibrary.load(JRuby.runtime)
|
9
|
+
|
10
|
+
|
11
|
+
Dir.chdir(File.dirname(__FILE__))
|
12
|
+
|
13
|
+
class VecmathTest < Minitest::Test
|
14
|
+
|
15
|
+
|
16
|
+
def setup
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_equals
|
21
|
+
x, y = 1.0000001, 1.01
|
22
|
+
a = Vec2D.new(x, y)
|
23
|
+
assert_equal(a.to_a, [x, y], 'Failed to return Vec2D as and Array')
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_not_equals
|
27
|
+
a = Vec2D.new(3, 5)
|
28
|
+
b = Vec2D.new(6, 7)
|
29
|
+
refute_equal(a, b, 'Failed equals false')
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_copy_equals
|
33
|
+
x, y = 1.0000001, 1.01
|
34
|
+
a = Vec2D.new(x, y)
|
35
|
+
b = a.copy
|
36
|
+
assert_equal(a.to_a, b.to_a, 'Failed deep copy')
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_copy_not_equals
|
40
|
+
x, y = 1.0000001, 1.01
|
41
|
+
a = Vec2D.new(x, y)
|
42
|
+
b = a.copy
|
43
|
+
b *= 0
|
44
|
+
refute_equal(a.to_a, b.to_a, 'Failed deep copy')
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_equals_when_close
|
48
|
+
a = Vec2D.new(3.0000000, 5.00000)
|
49
|
+
b = Vec2D.new(3.0000000, 5.000001)
|
50
|
+
assert_equal(a, b, 'Failed to return equal when v. close')
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_sum
|
54
|
+
a = Vec2D.new(3, 5)
|
55
|
+
b = Vec2D.new(6, 7)
|
56
|
+
c = Vec2D.new(9, 12)
|
57
|
+
assert_equal(a + b, c, 'Failed to sum vectors')
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_subtract
|
61
|
+
a = Vec2D.new(3, 5)
|
62
|
+
b = Vec2D.new(6, 7)
|
63
|
+
c = Vec2D.new(-3, -2)
|
64
|
+
assert_equal(a - b, c, 'Failed to subtract vectors')
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_multiply
|
68
|
+
a = Vec2D.new(3, 5)
|
69
|
+
b = 2
|
70
|
+
c = a * b
|
71
|
+
d = Vec2D.new(6, 10)
|
72
|
+
assert_equal(c, d, 'Failed to multiply vector by scalar')
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_divide
|
76
|
+
a = Vec2D.new(3, 5)
|
77
|
+
b = 2
|
78
|
+
c = Vec2D.new(1.5, 2.5)
|
79
|
+
d = a / b
|
80
|
+
assert_equal(c, d, 'Failed to divide vector by scalar')
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_dot
|
84
|
+
a = Vec2D.new(3, 5)
|
85
|
+
b = Vec2D.new(6, 7)
|
86
|
+
assert_in_epsilon(a.dot(b), 53, 0.001, 'Failed to dot product')
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_self_dot
|
90
|
+
a = Vec2D.new(3, 5)
|
91
|
+
assert_in_epsilon(a.dot(a), 34, 0.001, 'Failed self dot product')
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_from_angle
|
95
|
+
a = Vec2D.from_angle(Math::PI * 0.75)
|
96
|
+
assert_equal(a, Vec2D.new(-1 * Math.sqrt(0.5), Math.sqrt(0.5)), 'Failed to create vector from angle')
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_random
|
100
|
+
a = Vec2D.random
|
101
|
+
assert a.kind_of? Vec2D
|
102
|
+
assert_in_epsilon(a.mag, 1.0)
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_assign_value
|
106
|
+
a = Vec2D.new(3, 5)
|
107
|
+
a.x = 23
|
108
|
+
assert_equal(a.x, 23, 'Failed to assign x value')
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_mag
|
112
|
+
a = Vec2D.new(-3, -4)
|
113
|
+
assert_in_epsilon(a.mag, 5, 0.001,'Failed to return magnitude of vector')
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_mag_variant
|
117
|
+
a = Vec2D.new(3.0, 2)
|
118
|
+
b = Math.sqrt(3.0**2 + 2**2)
|
119
|
+
assert_in_epsilon(a.mag, b, 0.001, 'Failed to return magnitude of vector')
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_mag_zero_one
|
123
|
+
a = Vec2D.new(-1, 0)
|
124
|
+
assert_in_epsilon(a.mag, 1, 0.001, 'Failed to return magnitude of vector')
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_dist
|
128
|
+
a = Vec2D.new(3, 5)
|
129
|
+
b = Vec2D.new(6, 7)
|
130
|
+
assert_in_epsilon(a.dist(b), Math.sqrt(3.0**2 + 2**2), 'Failed to return distance between two vectors')
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_lerp
|
134
|
+
a = Vec2D.new(1, 1)
|
135
|
+
b = Vec2D.new(3, 3)
|
136
|
+
assert_equal(a.lerp(b, 0.5), Vec2D.new(2, 2), 'Failed to return lerp between two vectors')
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_lerp_unclamped
|
140
|
+
a = Vec2D.new(1, 1)
|
141
|
+
b = Vec2D.new(3, 3)
|
142
|
+
assert_equal(a.lerp(b, 5), Vec2D.new(11, 11), 'Failed to return lerp between two vectors')
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_lerp!
|
146
|
+
a = Vec2D.new(1, 1)
|
147
|
+
b = Vec2D.new(3, 3)
|
148
|
+
a.lerp!(b, 0.5)
|
149
|
+
assert_equal(a, Vec2D.new(2, 2), 'Failed to return lerp! between two vectors')
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_lerp_unclamped!
|
153
|
+
a = Vec2D.new(1, 1)
|
154
|
+
b = Vec2D.new(3, 3)
|
155
|
+
a.lerp!(b, 5)
|
156
|
+
assert_equal(a, Vec2D.new(11, 11), 'Failed to return lerp! between two vectors')
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_set_mag
|
160
|
+
a = Vec2D.new(1, 1)
|
161
|
+
assert_equal(a.set_mag(Math.sqrt(32)), Vec2D.new(4, 4), 'Failed to set_mag vector')
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_set_mag_block
|
165
|
+
a = Vec2D.new(1, 1)
|
166
|
+
assert_equal(a.set_mag(Math.sqrt(32)) { true }, Vec2D.new(4, 4), 'Failed to set_mag_block true vector')
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_set_mag_block_false
|
170
|
+
a = Vec2D.new(1, 1)
|
171
|
+
assert_equal(a.set_mag(Math.sqrt(32)) { false }, Vec2D.new(1, 1), 'Failed to set_mag_block true vector')
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_plus_assign
|
175
|
+
a = Vec2D.new(3, 5)
|
176
|
+
b = Vec2D.new(6, 7)
|
177
|
+
a += b
|
178
|
+
assert_equal(a, Vec2D.new(9, 12), 'Failed to += assign')
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_normalize
|
182
|
+
a = Vec2D.new(3, 5)
|
183
|
+
b = a.normalize
|
184
|
+
assert_in_epsilon(b.mag, 1, 0.001, 'Failed to return a normalized vector')
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_normalize!
|
188
|
+
a = Vec2D.new(3, 5)
|
189
|
+
a.normalize!
|
190
|
+
assert_in_epsilon(a.mag, 1, 0.001, 'Failed to return a normalized! vector')
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_heading
|
194
|
+
a = Vec2D.new(1, 1)
|
195
|
+
assert_in_epsilon(a.heading, Math::PI / 4.0, 0.001, 'Failed to return heading in radians')
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_rotate
|
199
|
+
x, y = 20, 10
|
200
|
+
b = Vec2D.new(x, y)
|
201
|
+
a = b.rotate(Math::PI / 2)
|
202
|
+
assert_equal(a, Vec2D.new(-10, 20), 'Failed to rotate vector by scalar radians')
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_hash_index
|
206
|
+
x, y = 10, 20
|
207
|
+
b = Vec2D.new(x, y)
|
208
|
+
assert_equal(b[:x], x, 'Failed to hash index')
|
209
|
+
end
|
210
|
+
|
211
|
+
def test_hash_set
|
212
|
+
x = 10
|
213
|
+
b = Vec2D.new
|
214
|
+
b[:x] = x
|
215
|
+
assert_equal(a, Vec2D.new(-10, 20), 'Failed to hash assign')
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_inspect
|
219
|
+
a = Vec2D.new(3, 2.000000000000001)
|
220
|
+
assert_equal(a.inspect, 'Vec2D(x = 3.0000, y = 2.0000)')
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_array_reduce
|
224
|
+
array = [Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(1, 2)]
|
225
|
+
sum = array.reduce(Vec2D.new) { |c, d| c + d }
|
226
|
+
assert_equal(sum, Vec2D.new(12, 6))
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_array_zip
|
230
|
+
one = [Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(1, 2)]
|
231
|
+
two = [Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(1, 2)]
|
232
|
+
zipped = one.zip(two).flatten
|
233
|
+
expected = [Vec2D.new(1, 2), Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(10, 2), Vec2D.new(1, 2), Vec2D.new(1, 2)]
|
234
|
+
assert_equal(zipped, expected)
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_cross_area # NB: the sign might be negative
|
238
|
+
a = Vec2D.new(200, 0)
|
239
|
+
b = Vec2D.new(0, 200)
|
240
|
+
# Expected result is an area, twice that of the triangle created by the vectors
|
241
|
+
assert_equal((a).cross(b).abs, 40_000.0, 'Failed area test using 2D vector cross product')
|
242
|
+
end
|
243
|
+
|
244
|
+
def test_cross_non_zero # Could be used to calculate area of triangle
|
245
|
+
a = Vec2D.new(40, 40)
|
246
|
+
b = Vec2D.new(40, 140)
|
247
|
+
c = Vec2D.new(140, 40)
|
248
|
+
assert_equal((a - b).cross(b - c).abs / 2, 5_000.0, 'Failed area calculation using 2D vector cross product')
|
249
|
+
end
|
250
|
+
|
251
|
+
def test_cross_zero # where a, b, c are collinear area == 0
|
252
|
+
a = Vec2D.new(0, 0)
|
253
|
+
b = Vec2D.new(100, 100)
|
254
|
+
c = Vec2D.new(200, 200)
|
255
|
+
# see http://mathworld.wolfram.com/Collinear.html for details
|
256
|
+
assert((a - b).cross(b - c).zero?, 'Failed collinearity test using 2D vector cross product')
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_equals
|
260
|
+
x, y, z = 1.0000001, 1.01, 0.0
|
261
|
+
a = Vec3D.new(x, y)
|
262
|
+
assert_equal(a.to_a, [x, y, z], 'Failed to return Vec3D as and Array')
|
263
|
+
end
|
264
|
+
|
265
|
+
def test_not_equals
|
266
|
+
a = Vec3D.new(3, 5, 1)
|
267
|
+
b = Vec3D.new(6, 7, 1)
|
268
|
+
refute_equal(a, b, 'Failed equals false')
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_copy_equals
|
272
|
+
x, y, z = 1.0000001, 1.01, 1
|
273
|
+
a = Vec3D.new(x, y, z)
|
274
|
+
b = a.copy
|
275
|
+
assert_equal(a.to_a, b.to_a, 'Failed deep copy')
|
276
|
+
end
|
277
|
+
|
278
|
+
def test_copy_not_equals
|
279
|
+
x, y, z = 1.0000001, 1.01, 6.0
|
280
|
+
a = Vec3D.new(x, y, z)
|
281
|
+
b = a.copy
|
282
|
+
b *= 0
|
283
|
+
refute_equal(a.to_a, b.to_a, 'Failed deep copy')
|
284
|
+
end
|
285
|
+
|
286
|
+
def test_equals_when_close
|
287
|
+
a = Vec3D.new(3.0000000, 5.00000, 2)
|
288
|
+
b = Vec3D.new(3.0000000, 5.000001, 2)
|
289
|
+
assert_equal(a, b, 'Failed to return equal when v. close')
|
290
|
+
end
|
291
|
+
|
292
|
+
def test_sum
|
293
|
+
a = Vec3D.new(3, 5, 1)
|
294
|
+
b = Vec3D.new(6, 7, 1)
|
295
|
+
c = Vec3D.new(9, 12, 2)
|
296
|
+
assert_equal(a + b, c, 'Failed to sum vectors')
|
297
|
+
end
|
298
|
+
|
299
|
+
def test_subtract
|
300
|
+
a = Vec3D.new(3, 5, 0)
|
301
|
+
b = Vec3D.new(6, 7, 1)
|
302
|
+
c = Vec3D.new(-3, -2, -1)
|
303
|
+
assert_equal(a - b, c, 'Failed to subtract vectors')
|
304
|
+
end
|
305
|
+
|
306
|
+
def test_multiply
|
307
|
+
a = Vec3D.new(3, 5, 1)
|
308
|
+
b = 2
|
309
|
+
c = a * b
|
310
|
+
d = Vec3D.new(6, 10, 2)
|
311
|
+
assert_equal(c, d, 'Failed to multiply vector by scalar')
|
312
|
+
end
|
313
|
+
|
314
|
+
def test_divide
|
315
|
+
a = Vec3D.new(3, 5, 4)
|
316
|
+
b = 2
|
317
|
+
c = Vec3D.new(1.5, 2.5, 2)
|
318
|
+
d = a / b
|
319
|
+
assert_equal(c, d, 'Failed to divide vector by scalar')
|
320
|
+
end
|
321
|
+
|
322
|
+
def test_random
|
323
|
+
a = Vec3D.random
|
324
|
+
assert a.kind_of? Vec3D
|
325
|
+
assert_in_epsilon(a.mag, 1.0)
|
326
|
+
end
|
327
|
+
|
328
|
+
def test_assign_value
|
329
|
+
a = Vec3D.new(3, 5)
|
330
|
+
a.x=23
|
331
|
+
assert_equal(a.x, 23, 'Failed to assign x value')
|
332
|
+
end
|
333
|
+
|
334
|
+
def test_mag
|
335
|
+
a = Vec3D.new(-3, -4)
|
336
|
+
assert_equal(a.mag, 5, 'Failed to return magnitude of vector')
|
337
|
+
end
|
338
|
+
|
339
|
+
def test_mag_variant
|
340
|
+
a = Vec3D.new(3.0, 2)
|
341
|
+
b = Math.sqrt(3.0**2 + 2**2)
|
342
|
+
assert_in_epsilon(a.mag, b, 0.001, 'Failed to return magnitude of vector')
|
343
|
+
end
|
344
|
+
|
345
|
+
def test_mag_zero_one
|
346
|
+
a = Vec3D.new(-1, 0)
|
347
|
+
assert_equal(a.mag, 1, 'Failed to return magnitude of vector')
|
348
|
+
end
|
349
|
+
|
350
|
+
def test_dist
|
351
|
+
a = Vec3D.new(3, 5, 2)
|
352
|
+
b = Vec3D.new(6, 7, 1)
|
353
|
+
message = 'Failed to return distance between two vectors'
|
354
|
+
assert_equal(a.dist(b), Math.sqrt(3.0**2 + 2**2 + 1), message)
|
355
|
+
end
|
356
|
+
|
357
|
+
def test_dist_squared
|
358
|
+
a = Vec3D.new(3, 5, 2)
|
359
|
+
b = Vec3D.new(6, 7, 1)
|
360
|
+
message = 'Failed to return distance squared between two vectors'
|
361
|
+
assert_equal(a.dist_squared(b), 3.0**2 + 2**2 + 1, message)
|
362
|
+
end
|
363
|
+
|
364
|
+
def test_dot
|
365
|
+
a = Vec3D.new(10, 20, 0)
|
366
|
+
b = Vec3D.new(60, 80, 0)
|
367
|
+
assert_in_epsilon(a.dot(b), 2200.0, 0.001, 'Failed to dot product')
|
368
|
+
end
|
369
|
+
|
370
|
+
def test_self_dot
|
371
|
+
a = Vec3D.new(10, 20, 4)
|
372
|
+
assert_in_epsilon(a.dot(a), 516.0, 0.001, 'Failed to self dot product')
|
373
|
+
end
|
374
|
+
|
375
|
+
def test_cross
|
376
|
+
a = Vec3D.new(3, 5, 2)
|
377
|
+
b = Vec3D.new(6, 7, 1)
|
378
|
+
c = Vec3D.new(-9.0, 9.0, -9.0)
|
379
|
+
assert_equal(a.cross(b), c, 'Failed cross product')
|
380
|
+
end
|
381
|
+
|
382
|
+
def test_set_mag
|
383
|
+
a = Vec3D.new(1, 1)
|
384
|
+
assert_equal(a.set_mag(Math.sqrt(32)), Vec3D.new(4, 4), 'Failed to set_mag vector')
|
385
|
+
end
|
386
|
+
|
387
|
+
def test_set_mag_block
|
388
|
+
a = Vec3D.new(1, 1)
|
389
|
+
assert_equal(a.set_mag(Math.sqrt(32)) { true }, Vec3D.new(4, 4), 'Failed to set_mag_block true vector')
|
390
|
+
end
|
391
|
+
|
392
|
+
def test_set_mag_block_false
|
393
|
+
a = Vec3D.new(1, 1)
|
394
|
+
assert_equal(a.set_mag(Math.sqrt(32)) { false }, Vec3D.new(1, 1), 'Failed to set_mag_block true vector')
|
395
|
+
end
|
396
|
+
|
397
|
+
def test_plus_assign
|
398
|
+
a = Vec3D.new(3, 5)
|
399
|
+
b = Vec3D.new(6, 7)
|
400
|
+
a += b
|
401
|
+
assert_equal(a, Vec3D.new(9, 12), 'Failed to += assign')
|
402
|
+
end
|
403
|
+
|
404
|
+
def test_normalize
|
405
|
+
a = Vec3D.new(3, 5)
|
406
|
+
b = a.normalize
|
407
|
+
assert_in_epsilon(b.mag, 1, 0.001, 'Failed to return a normalized vector')
|
408
|
+
end
|
409
|
+
|
410
|
+
def test_normalize!
|
411
|
+
a = Vec3D.new(3, 5)
|
412
|
+
a.normalize!
|
413
|
+
assert_in_epsilon(a.mag, 1, 0.001, 'Failed to return a normalized! vector')
|
414
|
+
end
|
415
|
+
|
416
|
+
def test_inspect
|
417
|
+
a = Vec3D.new(3, 2.000000000000001, 1)
|
418
|
+
assert_equal(a.inspect, 'Vec3D(x = 3.0000, y = 2.0000, z = 1.0000)')
|
419
|
+
end
|
420
|
+
|
421
|
+
def test_array_reduce
|
422
|
+
array = [Vec3D.new(1, 2), Vec3D.new(10, 2), Vec3D.new(1, 2)]
|
423
|
+
sum = array.reduce(Vec3D.new) { |c, d| c + d }
|
424
|
+
assert_equal(sum, Vec3D.new(12, 6))
|
425
|
+
end
|
426
|
+
|
427
|
+
def test_array_zip
|
428
|
+
one = [Vec3D.new(1, 2), Vec3D.new(10, 2), Vec3D.new(1, 2)]
|
429
|
+
two = [Vec3D.new(1, 2), Vec3D.new(10, 2), Vec3D.new(1, 2)]
|
430
|
+
zipped = one.zip(two).flatten
|
431
|
+
expected = [Vec3D.new(1, 2), Vec3D.new(1, 2), Vec3D.new(10, 2), Vec3D.new(10, 2), Vec3D.new(1, 2), Vec3D.new(1, 2)]
|
432
|
+
assert_equal(zipped, expected)
|
433
|
+
end
|
434
|
+
|
435
|
+
def test_eql?
|
436
|
+
a = Vec3D.new(3.0, 5.0, 0)
|
437
|
+
b = Vec3D.new(3.0, 5.0, 0)
|
438
|
+
assert(a.eql?(b))
|
439
|
+
end
|
440
|
+
|
441
|
+
def test_not_eql?
|
442
|
+
a = Vec3D.new(3.0, 5.0, 0)
|
443
|
+
b = Vec3D.new(3.0, 5.000001, 0)
|
444
|
+
refute(a.eql?(b))
|
445
|
+
end
|
446
|
+
|
447
|
+
def test_equal?
|
448
|
+
a = Vec3D.new(3.0, 5.0, 0)
|
449
|
+
assert(a.equal?(a))
|
450
|
+
end
|
451
|
+
|
452
|
+
def test_not_equal?
|
453
|
+
a = Vec3D.new(3.0, 5.0, 0)
|
454
|
+
b = Vec3D.new(3.0, 5.0, 0)
|
455
|
+
refute(a.equal?(b))
|
456
|
+
end
|
457
|
+
|
458
|
+
def test_hash_key
|
459
|
+
x, y, z = 10, 20, 50
|
460
|
+
b = Vec3D.new(x, y, z)
|
461
|
+
assert_equal(b[:x], x, 'Failed hash key access')
|
462
|
+
assert_equal(b[:y], y, 'Failed hash key access')
|
463
|
+
assert_equal(b[:z], z, 'Failed hash key access')
|
464
|
+
end
|
465
|
+
|
466
|
+
def test_hash_set
|
467
|
+
x = 10
|
468
|
+
b = Vec3D.new
|
469
|
+
b[:x] = x
|
470
|
+
assert_equal(b, Vec3D.new(x, 0, 0), 'Failed to hash assign')
|
471
|
+
end
|
472
|
+
end
|
data/vendors/Rakefile
CHANGED
@@ -9,7 +9,7 @@ SOUND = 'sound.zip'.freeze
|
|
9
9
|
SOUND_VERSION = 'v1.3.2' # version 1.3.2
|
10
10
|
VIDEO = 'video-2.zip'
|
11
11
|
VIDEO_VERSION = '2' # version 1.0.1
|
12
|
-
EXAMPLES = '0.
|
12
|
+
EXAMPLES = '0.9'.freeze
|
13
13
|
HOME_DIR = ENV['HOME']
|
14
14
|
MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig::CONFIG['host_os']
|
15
15
|
|
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.1.
|
4
|
+
version: 2.1.1
|
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: 2017-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: arcball
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.0.3
|
27
|
-
description: A batteries included version of processing in ruby,
|
27
|
+
description: A batteries included version of processing in ruby, MacOS and linux64
|
28
28
|
email:
|
29
29
|
- mamba2928@yahoo.co.uk
|
30
30
|
executables:
|
@@ -45,13 +45,11 @@ files:
|
|
45
45
|
- Rakefile
|
46
46
|
- bin/propane
|
47
47
|
- lib/PROCESSING_LICENSE.txt
|
48
|
-
- lib/core-3.2.
|
48
|
+
- lib/core-3.2.4.jar
|
49
49
|
- lib/export.txt
|
50
|
-
- lib/gluegen-rt-2.3.2-natives-linux-
|
51
|
-
- lib/gluegen-rt-2.3.2-natives-macosx-universal.jar
|
50
|
+
- lib/gluegen-rt-2.3.2-natives-linux-armv6hf.jar
|
52
51
|
- lib/gluegen-rt-2.3.2.jar
|
53
|
-
- lib/jogl-all-2.3.2-natives-linux-
|
54
|
-
- lib/jogl-all-2.3.2-natives-macosx-universal.jar
|
52
|
+
- lib/jogl-all-2.3.2-natives-linux-armv6hf.jar
|
55
53
|
- lib/jogl-all-2.3.2.jar
|
56
54
|
- lib/propane.jar
|
57
55
|
- lib/propane.rb
|
@@ -106,6 +104,12 @@ files:
|
|
106
104
|
- test/deglut_spec_test.rb
|
107
105
|
- test/math_tool_test.rb
|
108
106
|
- test/respond_to_test.rb
|
107
|
+
- test/test_create.rb
|
108
|
+
- test/test_deglut_spec.rb
|
109
|
+
- test/test_helper.rb
|
110
|
+
- test/test_math_tool.rb
|
111
|
+
- test/test_respond_to.rb
|
112
|
+
- test/vecmath_spec_test.rb
|
109
113
|
- vendors/Rakefile
|
110
114
|
homepage: https://ruby-processing.github.io/propane/
|
111
115
|
licenses:
|
@@ -128,12 +132,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
132
|
version: '0'
|
129
133
|
requirements: []
|
130
134
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.6.
|
135
|
+
rubygems_version: 2.6.8
|
132
136
|
signing_key:
|
133
137
|
specification_version: 4
|
134
|
-
summary:
|
138
|
+
summary: ruby wrapper for processing-3.2.4 on MacOS and linux64 bit only for opengl
|
135
139
|
test_files:
|
136
140
|
- test/create_test.rb
|
137
141
|
- test/deglut_spec_test.rb
|
138
142
|
- test/math_tool_test.rb
|
139
143
|
- test/respond_to_test.rb
|
144
|
+
- test/test_create.rb
|
145
|
+
- test/test_deglut_spec.rb
|
146
|
+
- test/test_helper.rb
|
147
|
+
- test/test_math_tool.rb
|
148
|
+
- test/test_respond_to.rb
|
149
|
+
- test/vecmath_spec_test.rb
|