picrate 2.0.0.pre-java → 2.2.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/extensions.xml +1 -1
  3. data/.mvn/wrapper/MavenWrapperDownloader.java +1 -1
  4. data/.mvn/wrapper/maven-wrapper.properties +2 -2
  5. data/CHANGELOG.md +10 -0
  6. data/README.md +11 -9
  7. data/Rakefile +9 -8
  8. data/docs/_config.yml +1 -1
  9. data/docs/_editors/geany.md +1 -0
  10. data/docs/_gems/gems/gems.md +1 -1
  11. data/docs/_methods/alternative_methods.md +2 -1
  12. data/docs/_posts/2018-05-06-getting_started.md +4 -4
  13. data/docs/_posts/2018-05-06-install_jruby.md +5 -11
  14. data/docs/_posts/2018-05-11-arch-linux-arm.md +1 -11
  15. data/docs/_posts/2018-11-18-building-gem.md +4 -2
  16. data/docs/_posts/2018-11-27-getting_started_geany.md +1 -1
  17. data/docs/_posts/2019-11-11-getting_started_buster.md +4 -7
  18. data/docs/_posts/{2018-06-26-auto_install_picrate.md → 2020-03-09-auto_install_picrate.md} +9 -6
  19. data/docs/_posts/2020-05-11-getting_started_manjaro.md +106 -0
  20. data/docs/about.md +1 -1
  21. data/lib/picrate.rb +2 -1
  22. data/lib/picrate/app.rb +1 -0
  23. data/lib/picrate/helper_methods.rb +1 -1
  24. data/lib/picrate/native_folder.rb +6 -7
  25. data/lib/picrate/runner.rb +4 -4
  26. data/lib/picrate/version.rb +1 -1
  27. data/library/jcomplex/jcomplex.rb +1 -0
  28. data/mvnw +2 -2
  29. data/mvnw.cmd +2 -2
  30. data/picrate.gemspec +3 -5
  31. data/pom.rb +18 -15
  32. data/pom.xml +20 -8
  33. data/src/main/java/monkstone/complex/JComplex.java +252 -0
  34. data/src/main/java/processing/awt/PGraphicsJava2D.java +22 -23
  35. data/src/main/java/processing/awt/PImageAWT.java +377 -0
  36. data/src/main/java/processing/awt/ShimAWT.java +545 -0
  37. data/src/main/java/processing/core/PApplet.java +2030 -2556
  38. data/src/main/java/processing/core/PGraphics.java +138 -124
  39. data/src/main/java/processing/core/PImage.java +1517 -1702
  40. data/src/main/java/processing/core/PSurface.java +105 -139
  41. data/src/main/java/processing/core/PSurfaceNone.java +29 -0
  42. data/src/main/java/processing/opengl/PGL.java +649 -3699
  43. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +223 -184
  44. data/src/main/java/processing/opengl/PJOGL.java +374 -1526
  45. data/src/main/java/processing/opengl/PShapeOpenGL.java +5 -6
  46. data/src/main/java/processing/opengl/PSurfaceJOGL.java +220 -86
  47. data/vendors/Rakefile +33 -21
  48. data/vendors/{picrate_sketches.geany → geany.rb} +32 -7
  49. metadata +17 -48
  50. data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
  51. data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
  52. data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
  53. data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
@@ -4,7 +4,7 @@ title: About
4
4
  permalink: /about/
5
5
  ---
6
6
  ![picrate.png]({{ site.github.url }}/assets/android-chrome-192x192.png)
7
- PiCrate is both a `library` and an `app` that allows you to create [processing][processing] sketches in ruby on the [RaspberryPI][PI] (or 64 bit linux). PiCrate is available as a gem (from [rubygems][rubygems]), it requires [JRuby][jruby] to both install and run. It does not depend on a vanilla processing install ( _cf_ JRubyArt).
7
+ PiCrate is both a `library` and an `app` that allows you to create [processing][processing] sketches in ruby on the [RaspberryPI][PI] (or 64 bit linux). PiCrate is available as a gem (from [rubygems][rubygems]), it requires [JRuby][jruby] to both install and run. It does not depend on a vanilla processing install ( _cf_ JRubyArt).Tested on raspbian Buster on RaspberryPI3B+ and RaspberryPI4, also works on Manajaro distro (64bit) on RapsberryPI4.
8
8
 
9
9
  #### Executable ####
10
10
 
@@ -9,4 +9,5 @@ end
9
9
  Dir["#{PICRATE_ROOT}/lib/*.jar"].sort.each do |jar|
10
10
  require jar
11
11
  end
12
- require_relative 'picrate/app'
12
+ require "#{PICRATE_ROOT}/lib/picrate/app"
13
+ require "#{PICRATE_ROOT}/lib/picrate/helpers/numeric"
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
+ require 'jruby'
3
4
  require_relative 'helper_methods'
4
5
  require_relative 'library_loader'
5
6
  # A wrapper module for the processing App
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  # processing module wrapper
4
- require_relative 'helpers/numeric'
4
+
5
5
  module Processing
6
6
  # Provides some convenience methods
7
7
  module HelperMethods
@@ -1,15 +1,13 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'rbconfig'
4
2
 
5
3
  # Utility to load native binaries on Java CLASSPATH
6
- # HACK until jruby returns a more specific 'host_os' than 'linux'
4
+ #HACK until jruby returns a more specific 'host_os' than 'linux'
7
5
  class NativeFolder
8
6
  attr_reader :os, :bit
9
7
 
10
- LINUX_FORMAT = 'linux%s'
11
- ARM32 = '-armv6hf'
12
- # ARM64 = '-aarch64'.freeze
8
+ LINUX_FORMAT = 'linux%s'.freeze
9
+ ARM32 = '-armv6hf'.freeze
10
+ ARM64 = '-aarch64'.freeze
13
11
 
14
12
  def initialize
15
13
  @os = RbConfig::CONFIG['host_os'].downcase
@@ -20,8 +18,9 @@ class NativeFolder
20
18
  if /linux/.match?(os)
21
19
  return format(LINUX_FORMAT, '64') if /amd64/.match?(bit)
22
20
  return format(LINUX_FORMAT, ARM32) if /arm/.match?(bit)
21
+ return format(LINUX_FORMAT, ARM64) if /aarch/.match?(bit)
23
22
  end
24
- raise 'Unsupported Architecture'
23
+ raise RuntimeError, "Unsupported Architecture"
25
24
  end
26
25
 
27
26
  def extension
@@ -32,7 +32,7 @@ module Processing
32
32
  opt_parser = OptionParser.new do |opts|
33
33
  # Set a banner, displayed at the top
34
34
  # of the help screen.
35
- opts.banner = 'Usage: picrate [options] [<sketch.rb>]'
35
+ opts.banner = 'Usage: picrate [options] [<name>]'
36
36
 
37
37
  # Define the options, and what they do
38
38
  options[:version] = false
@@ -55,6 +55,8 @@ module Processing
55
55
  # assumed to have this option.
56
56
  opts.on_tail('-h', '--help', 'Display this screen') do
57
57
  puts opts
58
+ puts ''
59
+ puts 'Run a sketch: jruby [--dev] [<sketch.rb>]'
58
60
  exit
59
61
  end
60
62
  end
@@ -81,9 +83,7 @@ module Processing
81
83
  library ||= 'new'
82
84
  choice = library.downcase
83
85
  case choice
84
- when /sound/
85
- warn 'The sound library is broken, try minim instead'
86
- when /samples|video/
86
+ when /samples|sound|video/
87
87
  system "cd #{PICRATE_ROOT}/vendors && rake install_#{choice}"
88
88
  when /new/
89
89
  # install samples and config geany
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PiCrate
4
- VERSION = '2.0.0.pre'
4
+ VERSION = '2.2.0'
5
5
  end
@@ -0,0 +1 @@
1
+ java_import Java::MonkstoneComplex::JComplex
data/mvnw CHANGED
@@ -212,9 +212,9 @@ else
212
212
  echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
213
213
  fi
214
214
  if [ -n "$MVNW_REPOURL" ]; then
215
- jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
215
+ jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
216
216
  else
217
- jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
217
+ jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
218
218
  fi
219
219
  while IFS="=" read key value; do
220
220
  case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
data/mvnw.cmd CHANGED
@@ -120,7 +120,7 @@ SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120
120
  set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121
121
  set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122
122
 
123
- set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
123
+ set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
124
124
 
125
125
  FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126
126
  IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
@@ -134,7 +134,7 @@ if exist %WRAPPER_JAR% (
134
134
  )
135
135
  ) else (
136
136
  if not "%MVNW_REPOURL%" == "" (
137
- SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
137
+ SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
138
138
  )
139
139
  if "%MVNW_VERBOSE%" == "true" (
140
140
  echo Couldn't find %WRAPPER_JAR%, downloading it ...
@@ -23,17 +23,15 @@ Gem::Specification.new do |gem|
23
23
  gem.files << 'lib/jogl-all.jar'
24
24
  gem.files << 'lib/gluegen-rt-natives-linux-amd64.jar'
25
25
  gem.files << 'lib/gluegen-rt-natives-linux-armv6hf.jar'
26
- # gem.files << 'lib/gluegen-rt-natives-linux-aarch64.jar'
26
+ gem.files << 'lib/gluegen-rt-natives-linux-aarch64.jar'
27
27
  gem.files << 'lib/jogl-all-natives-linux-amd64.jar'
28
28
  gem.files << 'lib/jogl-all-natives-linux-armv6hf.jar'
29
- # gem.files << 'lib/jogl-all-natives-linux-aarch64.jar'
29
+ gem.files << 'lib/jogl-all-natives-linux-aarch64.jar'
30
30
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
31
31
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
32
32
  gem.add_development_dependency 'minitest', '~> 5.10'
33
- gem.add_development_dependency 'rake', '~> 12.3'
33
+ gem.add_runtime_dependency 'rake', '~> 13.0'
34
34
  gem.add_runtime_dependency 'arcball', '~> 1.0', '>= 1.0.1'
35
- gem.add_runtime_dependency 'geomerative', '~> 1.1'
36
- gem.add_runtime_dependency 'ruby_wordcram', '~> 2.0', '>= 2.0.4'
37
35
  gem.require_paths = ['lib']
38
36
  gem.platform = 'java'
39
37
  gem.requirements << 'java runtime == 11+'
data/pom.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  project 'picrate', 'http://maven.apache.org' do
4
4
  model_version '4.0.0'
5
- id 'ruby-processing:picrate:2.0.0.pre'
5
+ id 'ruby-processing:picrate:2.2.0'
6
6
  packaging 'jar'
7
7
 
8
8
  description 'An integrated processing-core (somewhat hacked), with additional java code for a jruby version of processing.'
@@ -22,7 +22,7 @@ project 'picrate', 'http://maven.apache.org' do
22
22
  license 'LGPL 2', 'https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html'
23
23
 
24
24
  issue_management 'https://github.com/ruby-processing/PiCrate/issues', 'Github'
25
-
25
+ # Need to update to jogl 2.4.1 as soon as available, then make a dependency
26
26
  properties('jogl.version' => '2.3.2',
27
27
  'jruby.api' => 'http://jruby.org/apidocs/',
28
28
  'source.directory' => 'src',
@@ -31,28 +31,31 @@ project 'picrate', 'http://maven.apache.org' do
31
31
  'project.build.sourceEncoding' => 'utf-8',
32
32
  'polyglot.dump.pom' => 'pom.xml')
33
33
 
34
- pom 'org.jruby:jruby:9.2.11.0'
34
+ pom 'org.jruby:jruby:9.2.14.0'
35
35
  jar 'org.jogamp.jogl:jogl-all:${jogl.version}'
36
36
  jar 'org.jogamp.gluegen:gluegen-rt-main:${jogl.version}'
37
37
  jar 'org.processing:video:3.0.2'
38
38
  end
39
39
 
40
40
  overrides do
41
- plugin :resources, '2.7'
42
- plugin :dependency, '2.8'
43
- plugin(:compiler, '3.8.1', 'release' => '11')
44
- plugin(
45
- :javadoc,
46
- '3.1.1',
47
- 'detectOfflineLinks' => 'false',
48
- 'links' => ['${processing.api}', '${jruby.api}']
49
- )
50
- plugin(
51
- :jar, '3.1.2',
41
+ plugin :resources, '3.1.0'
42
+ plugin :dependency, '3.1.2'
43
+ plugin(:compiler, '3.8.1',
44
+ 'release' => '11')
45
+ plugin(:javadoc, '2.10.4',
46
+ 'detectOfflineLinks' => 'false',
47
+ 'links' => ['${processing.api}',
48
+ '${jruby.api}'])
49
+ plugin(:jar, '3.2.0',
52
50
  'archive' => {
53
- 'manifestEntries' => { 'Class-Path' => 'gluegen-rt.jar jog-all.jar' }
51
+ 'manifestEntries' => {
52
+ 'Automatic-Module-Name' => 'processing.core'
53
+ }
54
54
  }
55
55
  )
56
+ plugin :jdeps, '3.1.2' do
57
+ execute_goals 'jdkinternals', 'test-jdkinternals'
58
+ end
56
59
  end
57
60
 
58
61
  build do
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 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
9
+ <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://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>2.0.0.pre</version>
14
+ <version>2.2.0</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>
@@ -76,7 +76,7 @@ DO NOT MODIFIY - GENERATED CODE
76
76
  <dependency>
77
77
  <groupId>org.jruby</groupId>
78
78
  <artifactId>jruby</artifactId>
79
- <version>9.2.11.0</version>
79
+ <version>9.2.14.0</version>
80
80
  <type>pom</type>
81
81
  </dependency>
82
82
  <dependency>
@@ -119,11 +119,11 @@ DO NOT MODIFIY - GENERATED CODE
119
119
  <plugins>
120
120
  <plugin>
121
121
  <artifactId>maven-resources-plugin</artifactId>
122
- <version>2.7</version>
122
+ <version>3.1.0</version>
123
123
  </plugin>
124
124
  <plugin>
125
125
  <artifactId>maven-dependency-plugin</artifactId>
126
- <version>2.8</version>
126
+ <version>3.1.2</version>
127
127
  </plugin>
128
128
  <plugin>
129
129
  <artifactId>maven-compiler-plugin</artifactId>
@@ -134,7 +134,7 @@ DO NOT MODIFIY - GENERATED CODE
134
134
  </plugin>
135
135
  <plugin>
136
136
  <artifactId>maven-javadoc-plugin</artifactId>
137
- <version>3.1.1</version>
137
+ <version>2.10.4</version>
138
138
  <configuration>
139
139
  <detectOfflineLinks>false</detectOfflineLinks>
140
140
  <links>
@@ -145,15 +145,27 @@ DO NOT MODIFIY - GENERATED CODE
145
145
  </plugin>
146
146
  <plugin>
147
147
  <artifactId>maven-jar-plugin</artifactId>
148
- <version>3.1.2</version>
148
+ <version>3.2.0</version>
149
149
  <configuration>
150
150
  <archive>
151
151
  <manifestEntries>
152
- <Class-Path>gluegen-rt.jar jog-all.jar</Class-Path>
152
+ <Automatic-Module-Name>processing.core</Automatic-Module-Name>
153
153
  </manifestEntries>
154
154
  </archive>
155
155
  </configuration>
156
156
  </plugin>
157
+ <plugin>
158
+ <artifactId>maven-jdeps-plugin</artifactId>
159
+ <version>3.1.2</version>
160
+ <executions>
161
+ <execution>
162
+ <goals>
163
+ <goal>jdkinternals</goal>
164
+ <goal>test-jdkinternals</goal>
165
+ </goals>
166
+ </execution>
167
+ </executions>
168
+ </plugin>
157
169
  </plugins>
158
170
  </pluginManagement>
159
171
  </build>
@@ -0,0 +1,252 @@
1
+ package monkstone.complex;
2
+
3
+ import java.util.Objects;
4
+
5
+ /**
6
+ * The purpose of this class is to to make Complex operations more efficient
7
+ * than JRuby RubyComplex, by having a simpler interface, only modest
8
+ * improvements were obtained (but this is better than nothing on RaspberryPI).
9
+ */
10
+ public final class JComplex {
11
+
12
+ private final double re; // the real part
13
+ private final double im; // the imaginary part
14
+ private final static JComplex ZERO = new JComplex(0, 0);
15
+ private final static JComplex NAN = new JComplex(Double.NaN, Double.NaN);
16
+
17
+ /**
18
+ * create a new object with the given real and imaginary parts
19
+ *
20
+ * @param real
21
+ * @param imag
22
+ */
23
+ public JComplex(double real, double imag) {
24
+ re = real;
25
+ im = imag;
26
+ }
27
+
28
+ /**
29
+ * @return a string representation of the invoking Complex object
30
+ */
31
+ @Override
32
+ public String toString() {
33
+ return "JComplex(" + re + ", " + im + "i)";
34
+ }
35
+
36
+ /**
37
+ *
38
+ * @return abs/modulus/magnitude
39
+ */
40
+ public final double abs() {
41
+ return Math.hypot(re, im);
42
+ }
43
+
44
+ /**
45
+ *
46
+ * @return square of abs/modulus/magnitude
47
+ */
48
+ public final double abs2() {
49
+ return re * re + im * im;
50
+ }
51
+
52
+ /**
53
+ *
54
+ * @return angle/phase/argument, normalized to be between -pi and pi
55
+ */
56
+ public final double phase() {
57
+ return Math.atan2(im, re);
58
+ }
59
+
60
+ /**
61
+ *
62
+ * @param b
63
+ * @return a new Complex object whose value is (this + b)
64
+ */
65
+ public final JComplex add(JComplex b) {
66
+ JComplex a = this; // invoking object
67
+ double real = a.re + b.re;
68
+ double imag = a.im + b.im;
69
+ return new JComplex(real, imag);
70
+ }
71
+
72
+ /**
73
+ *
74
+ * @param scalar
75
+ * @return a new Complex object whose value is (this + scalar)
76
+ */
77
+ public final JComplex add(double scalar) {
78
+ return new JComplex(re + scalar, im);
79
+ }
80
+
81
+ public final boolean zero() {
82
+ return this.equals(ZERO);
83
+ }
84
+
85
+ /**
86
+ *
87
+ * @param b
88
+ * @return a new Complex object whose value is (this - b)
89
+ */
90
+ public final JComplex sub(JComplex b) {
91
+ JComplex a = this;
92
+ double real = a.re - b.re;
93
+ double imag = a.im - b.im;
94
+ return new JComplex(real, imag);
95
+ }
96
+
97
+ /**
98
+ *
99
+ * @param scalar
100
+ * @return a new Complex object whose value is (this - scalar)
101
+ */
102
+ public final JComplex sub(double scalar) {
103
+ return new JComplex(re - scalar, im);
104
+ }
105
+
106
+ /**
107
+ *
108
+ * @param b
109
+ * @return a new Complex object whose value is (this * b)
110
+ */
111
+ public final JComplex mul(JComplex b) {
112
+ JComplex a = this;
113
+ double real = a.re * b.re - a.im * b.im;
114
+ double imag = a.re * b.im + a.im * b.re;
115
+ return new JComplex(real, imag);
116
+ }
117
+
118
+ /**
119
+ * Also known as scale
120
+ *
121
+ * @param b
122
+ * @return a new Complex object whose value is (this * b)
123
+ */
124
+ public final JComplex mul(double b) {
125
+ return new JComplex(re * b, im * b);
126
+ }
127
+
128
+ /**
129
+ *
130
+ * @return a new Complex object whose value is the conjugate of this
131
+ */
132
+ public final JComplex conjugate() {
133
+ return new JComplex(re, -im);
134
+ }
135
+
136
+ /**
137
+ *
138
+ * @return a new Complex object whose value is the reciprocal of this
139
+ */
140
+ private JComplex reciprocal() {
141
+ double scale = re * re + im * im; // self dot product
142
+ return new JComplex(re / scale, -im / scale);
143
+ }
144
+
145
+ /**
146
+ *
147
+ * @param other
148
+ * @return this^other
149
+ */
150
+ public final JComplex pow(JComplex other) {
151
+ if (this.zero()) {
152
+ if (other.zero()) {
153
+ return ZERO;
154
+ }
155
+ return NAN;
156
+ }
157
+ return (this).log().mul(other).exp();
158
+ }
159
+
160
+ /**
161
+ *
162
+ * @param scalar
163
+ * @return this^scalar
164
+ */
165
+ public final JComplex pow(double scalar) {
166
+ if (this.zero()) {
167
+ if (scalar == 0) {
168
+ return ZERO;
169
+ }
170
+ return NAN;
171
+ }
172
+ return (this).log().mul(scalar).exp();
173
+ }
174
+
175
+ /**
176
+ *
177
+ * @return log
178
+ */
179
+ private JComplex log() {
180
+ return new JComplex(Math.log(abs()), Math.atan2(im, re));
181
+ }
182
+
183
+ /**
184
+ *
185
+ * @return real part
186
+ */
187
+ public final double re() {
188
+ return re;
189
+ }
190
+
191
+ /**
192
+ *
193
+ * @return imaginary part
194
+ */
195
+ public final double im() {
196
+ return im;
197
+ }
198
+
199
+ /**
200
+ *
201
+ * @param b
202
+ * @return a / b
203
+ */
204
+ public final JComplex div(JComplex b) {
205
+ JComplex a = this;
206
+ return a.mul(b.reciprocal());
207
+ }
208
+
209
+ /**
210
+ *
211
+ * @param b
212
+ * @return a / b
213
+ */
214
+ public final JComplex div(double b) {
215
+ if (b == 0) {
216
+ return NAN;
217
+ }
218
+ return new JComplex(re / b, im / b);
219
+ }
220
+
221
+ /**
222
+ *
223
+ * @return a new Complex object whose value is the complex exponential of
224
+ * this
225
+ */
226
+ public final JComplex exp() {
227
+ return new JComplex(Math.exp(re) * Math.cos(im), Math.exp(re) * Math.sin(im));
228
+ }
229
+
230
+ @Override
231
+ public final int hashCode() {
232
+ return Objects.hash(re, im);
233
+ }
234
+
235
+ @Override
236
+ public final boolean equals(Object obj) {
237
+ if (this == obj) {
238
+ return true;
239
+ }
240
+ if (obj == null) {
241
+ return false;
242
+ }
243
+ if (getClass() != obj.getClass()) {
244
+ return false;
245
+ }
246
+ final JComplex other = (JComplex) obj;
247
+ if (Double.doubleToLongBits(this.re) != Double.doubleToLongBits(other.re)) {
248
+ return false;
249
+ }
250
+ return Double.doubleToLongBits(this.im) == Double.doubleToLongBits(other.im);
251
+ }
252
+ }