picrate 1.3.0-java → 2.0.0.pre-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -1
- data/.mvn/wrapper/maven-wrapper.properties +2 -2
- data/CHANGELOG.md +2 -1
- data/Gemfile +3 -1
- data/README.md +4 -2
- data/Rakefile +8 -4
- data/bin/picrate +3 -1
- data/docs/_posts/2019-11-11-getting_started_buster.md +1 -1
- data/lib/picrate.rb +1 -1
- data/lib/picrate/app.rb +10 -3
- data/lib/picrate/creators/parameters.rb +8 -8
- data/lib/picrate/creators/sketch_factory.rb +5 -3
- data/lib/picrate/helper_methods.rb +21 -21
- data/lib/picrate/helpers/numeric.rb +2 -0
- data/lib/picrate/library.rb +5 -1
- data/lib/picrate/library_loader.rb +2 -0
- data/lib/picrate/native_folder.rb +6 -4
- data/lib/picrate/native_loader.rb +3 -0
- data/lib/picrate/runner.rb +1 -0
- data/lib/picrate/version.rb +1 -1
- data/library/boids/boids.rb +17 -8
- data/library/chooser/chooser.rb +10 -9
- data/library/color_group/color_group.rb +2 -0
- data/library/control_panel/control_panel.rb +7 -4
- data/library/dxf/dxf.rb +2 -0
- data/library/library_proxy/library_proxy.rb +2 -0
- data/library/net/net.rb +2 -0
- data/library/slider/slider.rb +24 -23
- data/library/vector_utils/vector_utils.rb +4 -0
- data/library/video_event/video_event.rb +2 -0
- data/picrate.gemspec +14 -12
- data/pom.rb +15 -15
- data/pom.xml +5 -5
- data/src/main/java/monkstone/ColorUtil.java +1 -1
- data/src/main/java/monkstone/MathToolModule.java +1 -1
- data/src/main/java/monkstone/PicrateLibrary.java +8 -8
- data/src/main/java/monkstone/fastmath/Deglut.java +16 -16
- data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +3 -3
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +12 -12
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +11 -13
- data/src/main/java/processing/awt/PSurfaceAWT.java +0 -20
- data/src/main/java/processing/core/PApplet.java +1949 -2247
- data/src/main/java/processing/core/PConstants.java +180 -180
- data/src/main/java/processing/core/PFont.java +2 -2
- data/src/main/java/processing/core/PGraphics.java +90 -90
- data/src/main/java/processing/core/PImage.java +65 -65
- data/src/main/java/processing/core/PMatrix.java +39 -39
- data/src/main/java/processing/core/PSurface.java +37 -37
- data/src/main/java/processing/core/PVector.java +2 -2
- data/src/main/java/processing/data/FloatDict.java +251 -284
- data/src/main/java/processing/data/TableRow.java +32 -32
- data/src/main/java/processing/dxf/RawDXF.java +3 -3
- data/src/main/java/processing/net/Client.java +1 -1
- data/src/main/java/processing/opengl/PGL.java +3884 -3950
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +38 -21
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +42 -61
- data/test/color_group_test.rb +4 -4
- data/test/deglut_spec_test.rb +2 -0
- data/test/helper_methods_test.rb +41 -13
- data/test/math_tool_test.rb +46 -37
- data/test/respond_to_test.rb +5 -3
- data/test/sketches/key_event.rb +2 -2
- data/test/sketches/library/my_library/my_library.rb +3 -0
- data/test/test_helper.rb +2 -0
- data/test/vecmath_spec_test.rb +30 -19
- data/vendors/Rakefile +2 -2
- metadata +29 -17
data/library/chooser/chooser.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
# Usage:
|
3
4
|
# load_library :chooser
|
4
|
-
#
|
5
|
+
#
|
5
6
|
# def setup
|
6
|
-
|
7
|
-
|
7
|
+
# java_signature 'void selectInput(String, String)'
|
8
|
+
# selectInput('Select a file to process:', 'fileSelected')
|
8
9
|
# end
|
9
|
-
#
|
10
|
+
#
|
10
11
|
# def fileSelected(selection)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
# if selection.nil?
|
13
|
+
# puts 'Window was closed or the user hit cancel.'
|
14
|
+
# else
|
15
|
+
# puts format('User selected %s', selection.get_absolute_path)
|
16
|
+
# end
|
16
17
|
# end
|
17
18
|
class Processing::App
|
18
19
|
include Java::MonkstoneFilechooser::Chooser
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Here's a little library for quickly hooking up controls to sketches.
|
2
4
|
# For messing with the parameters and such.
|
3
5
|
# These controls will set instance variables on the sketches.
|
@@ -25,7 +27,7 @@ module ControlPanel
|
|
25
27
|
add_change_listener do
|
26
28
|
update_label(label, name, value)
|
27
29
|
ControlPanel.app_value(name, value)
|
28
|
-
proc
|
30
|
+
proc&.call(value)
|
29
31
|
end
|
30
32
|
ControlPanel.app_value(name, val)
|
31
33
|
end
|
@@ -49,7 +51,7 @@ module ControlPanel
|
|
49
51
|
control_panel.add_element(self, name)
|
50
52
|
add_action_listener do
|
51
53
|
ControlPanel.app_value(name, value) unless value.nil?
|
52
|
-
proc
|
54
|
+
proc&.call(value)
|
53
55
|
end
|
54
56
|
set_selected_index(initial_value ? elements.index(initial_value) : 0)
|
55
57
|
end
|
@@ -69,7 +71,7 @@ module ControlPanel
|
|
69
71
|
control_panel.add_element(self, name, false)
|
70
72
|
add_action_listener do
|
71
73
|
ControlPanel.app_value(name, value)
|
72
|
-
proc
|
74
|
+
proc&.call(value)
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
@@ -87,7 +89,7 @@ module ControlPanel
|
|
87
89
|
control_panel.add_element(self, name, false, true)
|
88
90
|
add_action_listener do
|
89
91
|
Processing.app.send(name)
|
90
|
-
proc
|
92
|
+
proc&.call(value)
|
91
93
|
end
|
92
94
|
end
|
93
95
|
end
|
@@ -171,6 +173,7 @@ module ControlPanel
|
|
171
173
|
def control_panel
|
172
174
|
@control_panel ||= ControlPanel::Panel.new
|
173
175
|
return @control_panel unless block_given?
|
176
|
+
|
174
177
|
yield(@control_panel)
|
175
178
|
@control_panel.display
|
176
179
|
@control_panel.set_visible true
|
data/library/dxf/dxf.rb
CHANGED
data/library/net/net.rb
CHANGED
data/library/slider/slider.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
# Here's a little library for quickly hooking up in sketch sliders.
|
3
|
-
# Copyright (c) 2016-
|
4
|
+
# Copyright (c) 2016-20 Martin Prout.
|
4
5
|
|
5
6
|
java_import 'monkstone.slider.CustomHorizontalSlider'
|
6
7
|
java_import 'monkstone.slider.CustomVerticalSlider'
|
@@ -8,34 +9,34 @@ java_import 'monkstone.slider.CustomVerticalSlider'
|
|
8
9
|
module Slider
|
9
10
|
def self.slider(app:, x:, y:, name:, **opts)
|
10
11
|
options = default.merge opts
|
11
|
-
if options[:vertical]
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
12
|
+
slider = if options[:vertical]
|
13
|
+
CustomVerticalSlider.new(
|
14
|
+
app,
|
15
|
+
x,
|
16
|
+
y,
|
17
|
+
options[:length],
|
18
|
+
options[:range].first,
|
19
|
+
options[:range].last,
|
20
|
+
name
|
21
|
+
)
|
22
|
+
else
|
23
|
+
CustomHorizontalSlider.new(
|
24
|
+
app,
|
25
|
+
x,
|
26
|
+
y,
|
27
|
+
options[:length],
|
28
|
+
options[:range].first,
|
29
|
+
options[:range].last,
|
30
|
+
name
|
31
|
+
)
|
32
|
+
end
|
32
33
|
unless opts.empty?
|
33
34
|
slider.bar_width(opts.fetch(:bar_width, 10))
|
34
35
|
slider.set_value(opts.fetch(:initial_value, 0))
|
35
36
|
end
|
36
37
|
slider
|
37
38
|
end
|
38
|
-
|
39
|
+
|
39
40
|
def self.default
|
40
41
|
{ length: 100, range: (0..100) }
|
41
42
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
PHI ||= (1 + Math.sqrt(5)) / 2 # golden ratio
|
2
4
|
GA = PHI * 2 * Math::PI # golden angle
|
3
5
|
|
@@ -48,6 +50,7 @@ module VectorUtil
|
|
48
50
|
def self.cartesian_to_polar(vec:)
|
49
51
|
res = Vec3D.new(vec.mag, 0, 0)
|
50
52
|
return Vec3D.new unless res.x > 0
|
53
|
+
|
51
54
|
res.y = -Math.atan2(vec.z, vec.x)
|
52
55
|
res.z = Math.asin(vec.y / res.x)
|
53
56
|
res
|
@@ -64,6 +67,7 @@ module VectorUtil
|
|
64
67
|
|
65
68
|
def self.polar_to_cartesian(vec:)
|
66
69
|
return Vec3D.new if vec.mag <= 0
|
70
|
+
|
67
71
|
Vec3D.new(Math.asin(vec.y / vec.mag), vec.mag, -Math.atan2(vec.z, vec.x))
|
68
72
|
end
|
69
73
|
end
|
data/picrate.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'picrate/version'
|
5
6
|
|
@@ -8,31 +9,32 @@ Gem::Specification.new do |gem|
|
|
8
9
|
gem.version = PiCrate::VERSION
|
9
10
|
gem.authors = ['monkstone']
|
10
11
|
gem.email = ['mamba2928@yahoo.co.uk']
|
11
|
-
gem.licenses = %w
|
12
|
+
gem.licenses = %w[GPL-3.0 LGPL-2.0]
|
12
13
|
gem.description = <<~EOS
|
13
14
|
A batteries included version of processing in ruby, for raspberrypi and
|
14
15
|
linux. Install samples to configures geany ide.
|
15
16
|
EOS
|
16
|
-
gem.summary =
|
17
|
+
gem.summary = 'ruby implementation of processing-3 on raspberrypi and linux64'
|
17
18
|
gem.homepage = 'https://ruby-processing.github.io/PiCrate/'
|
18
|
-
gem.post_install_message =
|
19
|
-
gem.files
|
19
|
+
gem.post_install_message = "Use 'picrate --install' to config geany & install samples"
|
20
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
20
21
|
gem.files << "lib/picrate-#{PiCrate::VERSION}.jar"
|
21
22
|
gem.files << 'lib/gluegen-rt.jar'
|
22
23
|
gem.files << 'lib/jogl-all.jar'
|
23
24
|
gem.files << 'lib/gluegen-rt-natives-linux-amd64.jar'
|
24
25
|
gem.files << 'lib/gluegen-rt-natives-linux-armv6hf.jar'
|
26
|
+
# gem.files << 'lib/gluegen-rt-natives-linux-aarch64.jar'
|
25
27
|
gem.files << 'lib/jogl-all-natives-linux-amd64.jar'
|
26
28
|
gem.files << 'lib/jogl-all-natives-linux-armv6hf.jar'
|
27
|
-
|
29
|
+
# gem.files << 'lib/jogl-all-natives-linux-aarch64.jar'
|
30
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
28
31
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
29
|
-
gem.add_development_dependency 'rake', '~> 12.3'
|
30
32
|
gem.add_development_dependency 'minitest', '~> 5.10'
|
31
|
-
gem.
|
32
|
-
|
33
|
+
gem.add_development_dependency 'rake', '~> 12.3'
|
34
|
+
gem.add_runtime_dependency 'arcball', '~> 1.0', '>= 1.0.1'
|
33
35
|
gem.add_runtime_dependency 'geomerative', '~> 1.1'
|
34
|
-
gem.add_runtime_dependency 'ruby_wordcram', '~> 2.0.4'
|
36
|
+
gem.add_runtime_dependency 'ruby_wordcram', '~> 2.0', '>= 2.0.4'
|
35
37
|
gem.require_paths = ['lib']
|
36
38
|
gem.platform = 'java'
|
37
|
-
gem.requirements << 'java runtime ==
|
39
|
+
gem.requirements << 'java runtime == 11+'
|
38
40
|
end
|
data/pom.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
project 'picrate', 'http://maven.apache.org' do
|
3
4
|
model_version '4.0.0'
|
4
|
-
id 'ruby-processing:picrate:
|
5
|
+
id 'ruby-processing:picrate:2.0.0.pre'
|
5
6
|
packaging 'jar'
|
6
7
|
|
7
8
|
description 'An integrated processing-core (somewhat hacked), with additional java code for a jruby version of processing.'
|
@@ -22,14 +23,13 @@ project 'picrate', 'http://maven.apache.org' do
|
|
22
23
|
|
23
24
|
issue_management 'https://github.com/ruby-processing/PiCrate/issues', 'Github'
|
24
25
|
|
25
|
-
properties(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
)
|
26
|
+
properties('jogl.version' => '2.3.2',
|
27
|
+
'jruby.api' => 'http://jruby.org/apidocs/',
|
28
|
+
'source.directory' => 'src',
|
29
|
+
'processing.api' => 'http://processing.github.io/processing-javadocs/core/',
|
30
|
+
'picrate.basedir' => '${project.basedir}',
|
31
|
+
'project.build.sourceEncoding' => 'utf-8',
|
32
|
+
'polyglot.dump.pom' => 'pom.xml')
|
33
33
|
|
34
34
|
pom 'org.jruby:jruby:9.2.11.0'
|
35
35
|
jar 'org.jogamp.jogl:jogl-all:${jogl.version}'
|
@@ -38,14 +38,14 @@ project 'picrate', 'http://maven.apache.org' do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
overrides do
|
41
|
-
plugin :resources, '
|
42
|
-
plugin :dependency, '
|
43
|
-
plugin(
|
41
|
+
plugin :resources, '2.7'
|
42
|
+
plugin :dependency, '2.8'
|
43
|
+
plugin(:compiler, '3.8.1', 'release' => '11')
|
44
44
|
plugin(
|
45
45
|
:javadoc,
|
46
46
|
'3.1.1',
|
47
|
-
'detectOfflineLinks' =>
|
48
|
-
'links' => [
|
47
|
+
'detectOfflineLinks' => 'false',
|
48
|
+
'links' => ['${processing.api}', '${jruby.api}']
|
49
49
|
)
|
50
50
|
plugin(
|
51
51
|
:jar, '3.1.2',
|
data/pom.xml
CHANGED
@@ -6,12 +6,12 @@ DO NOT MODIFIY - GENERATED CODE
|
|
6
6
|
|
7
7
|
|
8
8
|
-->
|
9
|
-
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
9
|
+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
10
10
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
11
11
|
<modelVersion>4.0.0</modelVersion>
|
12
12
|
<groupId>ruby-processing</groupId>
|
13
13
|
<artifactId>picrate</artifactId>
|
14
|
-
<version>
|
14
|
+
<version>2.0.0.pre</version>
|
15
15
|
<name>picrate</name>
|
16
16
|
<description>An integrated processing-core (somewhat hacked), with additional java code for a jruby version of processing.</description>
|
17
17
|
<url>http://maven.apache.org</url>
|
@@ -119,17 +119,17 @@ DO NOT MODIFIY - GENERATED CODE
|
|
119
119
|
<plugins>
|
120
120
|
<plugin>
|
121
121
|
<artifactId>maven-resources-plugin</artifactId>
|
122
|
-
<version>
|
122
|
+
<version>2.7</version>
|
123
123
|
</plugin>
|
124
124
|
<plugin>
|
125
125
|
<artifactId>maven-dependency-plugin</artifactId>
|
126
|
-
<version>
|
126
|
+
<version>2.8</version>
|
127
127
|
</plugin>
|
128
128
|
<plugin>
|
129
129
|
<artifactId>maven-compiler-plugin</artifactId>
|
130
130
|
<version>3.8.1</version>
|
131
131
|
<configuration>
|
132
|
-
<release>
|
132
|
+
<release>11</release>
|
133
133
|
</configuration>
|
134
134
|
</plugin>
|
135
135
|
<plugin>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
* in their sketches. Includes a method to efficiently convert an cols of web
|
4
4
|
* strings to an cols of color int, and another to convert an cols of p5 color
|
5
5
|
* (int) to a string that can be used in ruby code (to generate web color cols).
|
6
|
-
* Copyright (c) 2015-
|
6
|
+
* Copyright (c) 2015-20 Martin Prout.
|
7
7
|
* This utility is free software; you can redistribute it and/or modify
|
8
8
|
* it under the terms of the GNU Lesser General Public License as published by
|
9
9
|
* the Free Software Foundation; either version 2.1 of the License, or (at
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* The purpose of this tool is to allow JRubyArt users to use an alternative
|
3
3
|
* to processing.org map, lerp and norm methods in their sketches and to implement
|
4
4
|
* JRubyArt convenenience method grid(width, height, stepW, stepH) { |x, y| do stuff }
|
5
|
-
* Copyright (c) 2015-
|
5
|
+
* Copyright (c) 2015-20 Martin Prout. This tool is free software; you can
|
6
6
|
* redistribute it and/or modify it under the terms of the GNU Lesser General
|
7
7
|
* Public License as published by the Free Software Foundation; either version
|
8
8
|
* 2.1 of the License, or (at your option) any later version.
|
@@ -1,10 +1,10 @@
|
|
1
1
|
/**
|
2
|
-
* The purpose of this class is to load the MathTool into PiCrate runtime
|
3
|
-
* Copyright (C)
|
2
|
+
* The purpose of this class is to load the MathTool into PiCrate runtime
|
3
|
+
* Copyright (C) 2018-20 Martin Prout. This code is free software; you can
|
4
4
|
* redistribute it and/or modify it under the terms of the GNU Lesser General
|
5
|
-
* Public License as published by the Free Software Foundation; either version
|
5
|
+
* Public License as published by the Free Software Foundation; either version
|
6
6
|
* 2.1 of the License, or (at your option) any later version.
|
7
|
-
*
|
7
|
+
*
|
8
8
|
* Obtain a copy of the license at http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
9
9
|
*/
|
10
10
|
|
@@ -23,7 +23,7 @@ import org.jruby.runtime.load.Library;
|
|
23
23
|
* @author Martin Prout
|
24
24
|
*/
|
25
25
|
public class PicrateLibrary implements Library{
|
26
|
-
|
26
|
+
|
27
27
|
/**
|
28
28
|
*
|
29
29
|
* @param runtime
|
@@ -33,8 +33,8 @@ public class PicrateLibrary implements Library{
|
|
33
33
|
Deglut.createDeglut(runtime);
|
34
34
|
Vec2.createVec2(runtime);
|
35
35
|
Vec3.createVec3(runtime);
|
36
|
-
}
|
37
|
-
|
36
|
+
}
|
37
|
+
|
38
38
|
/**
|
39
39
|
*
|
40
40
|
* @param runtime
|
@@ -44,5 +44,5 @@ public class PicrateLibrary implements Library{
|
|
44
44
|
@Override
|
45
45
|
public void load(final Ruby runtime, boolean wrap) throws IOException {
|
46
46
|
load(runtime);
|
47
|
-
}
|
47
|
+
}
|
48
48
|
}
|
@@ -1,18 +1,18 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (c) 2018-
|
3
|
-
*
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2018-20 Martin Prout
|
3
|
+
*
|
4
4
|
* This library is free software; you can redistribute it and/or
|
5
5
|
* modify it under the terms of the GNU General Public
|
6
6
|
* License as published by the Free Software Foundation; either
|
7
7
|
* version 3.0 of the License, or (at your option) any later version.
|
8
|
-
*
|
8
|
+
*
|
9
9
|
* http://creativecommons.org/licenses/LGPL/2.1/
|
10
|
-
*
|
10
|
+
*
|
11
11
|
* This library is distributed in the hope that it will be useful,
|
12
12
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
13
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
14
|
* Lesser General Public License for more details.
|
15
|
-
*
|
15
|
+
*
|
16
16
|
* You should have received a copy of the GNU General Public
|
17
17
|
* License along with this library; if not, write to the Free Software
|
18
18
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
@@ -35,7 +35,7 @@ import org.jruby.runtime.builtin.IRubyObject;
|
|
35
35
|
*/
|
36
36
|
@JRubyModule(name = "DegLut")
|
37
37
|
public class Deglut {
|
38
|
-
|
38
|
+
|
39
39
|
/**
|
40
40
|
* Lookup table for degree cosine/sine, has a fixed precision 1.0
|
41
41
|
* degrees Quite accurate but imprecise
|
@@ -49,11 +49,11 @@ public class Deglut {
|
|
49
49
|
*
|
50
50
|
*/
|
51
51
|
private static boolean initialized = false;
|
52
|
-
|
52
|
+
|
53
53
|
private final static int NINETY = 90;
|
54
54
|
private final static int FULL = 360;
|
55
55
|
private static final long serialVersionUID = -1466528933765940101L;
|
56
|
-
|
56
|
+
|
57
57
|
/**
|
58
58
|
* Initialize sin table with values (first quadrant only)
|
59
59
|
*/
|
@@ -65,19 +65,19 @@ public class Deglut {
|
|
65
65
|
initialized = true;
|
66
66
|
}
|
67
67
|
}
|
68
|
-
|
68
|
+
|
69
69
|
/**
|
70
70
|
*
|
71
71
|
* @param runtime Ruby
|
72
72
|
*/
|
73
|
-
|
73
|
+
|
74
74
|
public static void createDeglut(final Ruby runtime){
|
75
75
|
RubyModule deglutModule = runtime.defineModule("DegLut");
|
76
76
|
deglutModule.defineAnnotatedMethods(Deglut.class);
|
77
77
|
Deglut.initTable();
|
78
78
|
}
|
79
|
-
|
80
|
-
|
79
|
+
|
80
|
+
|
81
81
|
/**
|
82
82
|
*
|
83
83
|
* @param context ThreadContext
|
@@ -86,7 +86,7 @@ public class Deglut {
|
|
86
86
|
* @return sin IRubyObject
|
87
87
|
*/
|
88
88
|
@JRubyMethod(name = "sin", module = true)
|
89
|
-
|
89
|
+
|
90
90
|
public static IRubyObject sin(ThreadContext context, IRubyObject recv, IRubyObject other) {
|
91
91
|
int thet = (int) ((RubyInteger)other).getLongValue();
|
92
92
|
while (thet < 0) {
|
@@ -99,7 +99,7 @@ public class Deglut {
|
|
99
99
|
? -SIN_DEG_LUT[y] : -SIN_DEG_LUT[NINETY - y];
|
100
100
|
return context.runtime.newFloat(result);
|
101
101
|
}
|
102
|
-
|
102
|
+
|
103
103
|
/**
|
104
104
|
*
|
105
105
|
* @param context ThreadContext
|
@@ -119,5 +119,5 @@ public class Deglut {
|
|
119
119
|
? -SIN_DEG_LUT[y] : (theta < 270)
|
120
120
|
? -SIN_DEG_LUT[NINETY - y] : SIN_DEG_LUT[y];
|
121
121
|
return context.runtime.newFloat(result);
|
122
|
-
}
|
122
|
+
}
|
123
123
|
}
|