pbox2d 0.9.1-java → 1.0.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -5
  3. data/CHANGELOG.md +4 -0
  4. data/README.md +6 -6
  5. data/docs/.gitignore +6 -0
  6. data/docs/_classes/pbox2d.md +375 -0
  7. data/docs/_classes/world_builder.md +7 -0
  8. data/docs/_config.yml +32 -0
  9. data/docs/_includes/footer.html +55 -0
  10. data/docs/_includes/head.html +18 -0
  11. data/docs/_includes/header.html +27 -0
  12. data/docs/_includes/menu.html +8 -0
  13. data/docs/_includes/navigation.html +24 -0
  14. data/docs/_layouts/default.html +20 -0
  15. data/docs/_layouts/page.html +14 -0
  16. data/docs/_layouts/post.html +15 -0
  17. data/docs/_methods/init_options.md +28 -0
  18. data/docs/_methods/processing_to_world.md +29 -0
  19. data/docs/_methods/scale_to_processing.md +24 -0
  20. data/docs/_methods/scale_to_world.md +29 -0
  21. data/docs/_methods/step_options.md +25 -0
  22. data/docs/_methods/world_to_processing.md +30 -0
  23. data/docs/_modules/pb.md +25 -0
  24. data/docs/_modules/world_builder.md +26 -0
  25. data/docs/_posts/2016-10-14-welcome.md +183 -0
  26. data/docs/_sass/_base.scss +204 -0
  27. data/docs/_sass/_layout.scss +236 -0
  28. data/docs/_sass/_syntax-highlighting.scss +67 -0
  29. data/docs/about.md +20 -0
  30. data/docs/classes.html +9 -0
  31. data/docs/css/main.scss +52 -0
  32. data/docs/favicon.ico +0 -0
  33. data/docs/index.html +38 -0
  34. data/docs/methods.html +9 -0
  35. data/docs/modules.html +12 -0
  36. data/lib/pbox2d/version.rb +1 -1
  37. data/pbox2d.gemspec +4 -7
  38. data/pom.rb +8 -6
  39. data/pom.xml +3 -3
  40. data/src/org/jbox2d/collision/AABB.java +2 -2
  41. data/src/org/jbox2d/collision/Manifold.java +2 -2
  42. data/src/org/jbox2d/collision/ManifoldPoint.java +2 -2
  43. data/src/org/jbox2d/collision/shapes/MassData.java +1 -1
  44. data/src/org/jbox2d/common/Mat22.java +6 -13
  45. data/src/org/jbox2d/common/Mat33.java +253 -233
  46. data/src/org/jbox2d/common/MathUtils.java +5 -5
  47. data/src/org/jbox2d/common/Rot.java +16 -19
  48. data/src/org/jbox2d/common/Transform.java +4 -4
  49. data/src/org/jbox2d/common/Vec2.java +6 -12
  50. data/src/org/jbox2d/common/Vec3.java +147 -142
  51. data/src/org/jbox2d/dynamics/joints/DistanceJoint.java +4 -2
  52. metadata +62 -25
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Syntax highlighting styles
3
+ */
4
+ .highlight {
5
+ background: #fff;
6
+ @extend %vertical-rhythm;
7
+
8
+ .c { color: #998; font-style: italic } // Comment
9
+ .err { color: #a61717; background-color: #e3d2d2 } // Error
10
+ .k { font-weight: bold } // Keyword
11
+ .o { font-weight: bold } // Operator
12
+ .cm { color: #998; font-style: italic } // Comment.Multiline
13
+ .cp { color: #999; font-weight: bold } // Comment.Preproc
14
+ .c1 { color: #998; font-style: italic } // Comment.Single
15
+ .cs { color: #999; font-weight: bold; font-style: italic } // Comment.Special
16
+ .gd { color: #000; background-color: #fdd } // Generic.Deleted
17
+ .gd .x { color: #000; background-color: #faa } // Generic.Deleted.Specific
18
+ .ge { font-style: italic } // Generic.Emph
19
+ .gr { color: #a00 } // Generic.Error
20
+ .gh { color: #999 } // Generic.Heading
21
+ .gi { color: #000; background-color: #dfd } // Generic.Inserted
22
+ .gi .x { color: #000; background-color: #afa } // Generic.Inserted.Specific
23
+ .go { color: #888 } // Generic.Output
24
+ .gp { color: #555 } // Generic.Prompt
25
+ .gs { font-weight: bold } // Generic.Strong
26
+ .gu { color: #aaa } // Generic.Subheading
27
+ .gt { color: #a00 } // Generic.Traceback
28
+ .kc { font-weight: bold } // Keyword.Constant
29
+ .kd { font-weight: bold } // Keyword.Declaration
30
+ .kp { font-weight: bold } // Keyword.Pseudo
31
+ .kr { font-weight: bold } // Keyword.Reserved
32
+ .kt { color: #458; font-weight: bold } // Keyword.Type
33
+ .m { color: #099 } // Literal.Number
34
+ .s { color: #d14 } // Literal.String
35
+ .na { color: #008080 } // Name.Attribute
36
+ .nb { color: #0086B3 } // Name.Builtin
37
+ .nc { color: #458; font-weight: bold } // Name.Class
38
+ .no { color: #008080 } // Name.Constant
39
+ .ni { color: #800080 } // Name.Entity
40
+ .ne { color: #900; font-weight: bold } // Name.Exception
41
+ .nf { color: #900; font-weight: bold } // Name.Function
42
+ .nn { color: #555 } // Name.Namespace
43
+ .nt { color: #000080 } // Name.Tag
44
+ .nv { color: #008080 } // Name.Variable
45
+ .ow { font-weight: bold } // Operator.Word
46
+ .w { color: #bbb } // Text.Whitespace
47
+ .mf { color: #099 } // Literal.Number.Float
48
+ .mh { color: #099 } // Literal.Number.Hex
49
+ .mi { color: #099 } // Literal.Number.Integer
50
+ .mo { color: #099 } // Literal.Number.Oct
51
+ .sb { color: #d14 } // Literal.String.Backtick
52
+ .sc { color: #d14 } // Literal.String.Char
53
+ .sd { color: #d14 } // Literal.String.Doc
54
+ .s2 { color: #d14 } // Literal.String.Double
55
+ .se { color: #d14 } // Literal.String.Escape
56
+ .sh { color: #d14 } // Literal.String.Heredoc
57
+ .si { color: #d14 } // Literal.String.Interpol
58
+ .sx { color: #d14 } // Literal.String.Other
59
+ .sr { color: #009926 } // Literal.String.Regex
60
+ .s1 { color: #d14 } // Literal.String.Single
61
+ .ss { color: #990073 } // Literal.String.Symbol
62
+ .bp { color: #999 } // Name.Builtin.Pseudo
63
+ .vc { color: #008080 } // Name.Variable.Class
64
+ .vg { color: #008080 } // Name.Variable.Global
65
+ .vi { color: #008080 } // Name.Variable.Instance
66
+ .il { color: #099 } // Literal.Number.Integer.Long
67
+ }
@@ -0,0 +1,20 @@
1
+ ---
2
+ layout: page
3
+ title: About
4
+ permalink: /about/
5
+ categories: jruby_art update
6
+ ---
7
+
8
+ [JRubyArt][jruby_art] is a ruby wrapper for [processing-3.2.1][processing]. Create processing sketches in ruby using regular ruby-2.3 syntax, and use the magic [JRuby][jruby] to run them. You can use both rubygems and and regular processing libraries in your sketches. Features run, watch and live modes (uses pry).
9
+
10
+ In general where there is a choice of using a java (processing) method or a regular ruby method you should choose the ruby method (eg use `rand` in place of `random`). Further you should prefer to use `JRuby` classes `Vec2D` and `Vec3D` instead of processings `PVector` class. Processing has a number of convenience methods which are not needed in ruby (eg 'pow' use `**` in JRubyArt) and some static methods have not been implemented in JRubyArt. For the processing `map` method prefer `map1d` ([see example][map1d]) or use `p5map` if you must. Another thing to watch is `color` which is implemented differently in JRubyArt ([see example][color]).
11
+
12
+ See also my [blog][blog] for more code ideas.
13
+
14
+ [jruby]: https://jruby.org
15
+ [processing]: https://processing.org
16
+
17
+ [jruby_art]: https://ruby-processing.github.io/index.html
18
+ [color]: https://github.com/ruby-processing/JRubyArt-examples/blob/master/processing_app/basics/color/creating.rb
19
+ [map1d]: https://github.com/ruby-processing/JRubyArt-examples/blob/master/processing_app/basics/arrays/array.rb
20
+ [blog]:https://monkstone.github.io/
@@ -0,0 +1,9 @@
1
+ ---
2
+ layout: page
3
+ title: Classes
4
+ ---
5
+ {% for class in site.classes %}
6
+ <div class="class">
7
+ <h2><a href="{{ class.url | prepend: site.github.url }}">{{ class.title }}</a></h2>
8
+ </div>
9
+ {% endfor %}
@@ -0,0 +1,52 @@
1
+ ---
2
+ # Only the main Sass file needs front matter (the dashes are enough)
3
+ ---
4
+ @charset "utf-8";
5
+
6
+
7
+
8
+ // Our variables
9
+ $base-font-family: Helvetica, Arial, sans-serif;
10
+ $base-font-size: 16px;
11
+ $small-font-size: $base-font-size * 0.875;
12
+ $base-line-height: 1.5;
13
+
14
+ $spacing-unit: 30px;
15
+
16
+ $text-color: #111;
17
+ $background-color: #fdfdfd;
18
+ $brand-color: #2a7ae2;
19
+
20
+ $grey-color: #828282;
21
+ $grey-color-light: lighten($grey-color, 40%);
22
+ $grey-color-dark: darken($grey-color, 25%);
23
+
24
+ // Width of the content area
25
+ $content-width: 800px;
26
+
27
+ $on-palm: 600px;
28
+ $on-laptop: 800px;
29
+
30
+
31
+
32
+ // Using media queries with like this:
33
+ // @include media-query($on-palm) {
34
+ // .wrapper {
35
+ // padding-right: $spacing-unit / 2;
36
+ // padding-left: $spacing-unit / 2;
37
+ // }
38
+ // }
39
+ @mixin media-query($device) {
40
+ @media screen and (max-width: $device) {
41
+ @content;
42
+ }
43
+ }
44
+
45
+
46
+
47
+ // Import partials from `sass_dir` (defaults to `_sass`)
48
+ @import
49
+ "base",
50
+ "layout",
51
+ "syntax-highlighting"
52
+ ;
Binary file
@@ -0,0 +1,38 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+ <section role="banner">
5
+ <svg version="1.1" id="Layer_1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink" x="0px" y="0px"
6
+ width="256px" height="256px" viewBox="10 10 200 200" style="enable-background:new 0 0 200 200;" xml:space="preserve" fill="#380E99">
7
+ <g>
8
+ <path d="M56.161,183.028l4.452-43.162l7.904,6.584L56,185.335L56.161,183.028z M70.823,152.055l19.61,39.046l-32.951,4.116
9
+ L70.823,152.055z M92.739,195.552v0.161V195.552l0.657-0.161v0.161l93.095,3.62l-126.703,0.496L92.739,195.552z M127.997,90.604
10
+ l-30.645,34.098l-27.186,17.137l-7.743-6.584l10.874-20.435l25.872-28.842l24.711-17.297l11.371,3.138L127.997,90.604z
11
+ M90.266,182.036l-18.122-36.082l25.375-16.144L90.266,182.036z M154.693,141.181l-61.129,48.271l8.24-59.306L154.693,141.181z
12
+ M158.152,144.479l38.06,51.569l-98.532-3.795L158.152,144.479z M130.638,94.546l22.734,43.015l-51.241-11.371L130.638,94.546z
13
+ M171.004,56.332l-34.111,11.035l-6.094-1.649L171.004,56.332z M132.945,90.604l7.576-19.281l42.183,6.758L132.945,90.604z
14
+ M134.922,94.546l53.875-14.494l-30.973,57.83L134.922,94.546z M194.234,76.257l-45.146-7.897l36.082-11.706L194.234,76.257z
15
+ M200,195.391l-39.213-53.218l33.943-63.609L200,195.391z"/>
16
+ </g>
17
+ </svg>
18
+ </section>
19
+
20
+ <div class="home">
21
+
22
+ <h1 class="page-heading">Articles</h1>
23
+
24
+ <ul class="post-list">
25
+ {% for post in site.posts %}
26
+ <li>
27
+ <span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>
28
+
29
+ <h2>
30
+ <a class="post-link" href="{{ post.url | prepend: site.github.url }}">{{ post.title }}</a>
31
+ </h2>
32
+ </li>
33
+ {% endfor %}
34
+ </ul>
35
+
36
+ <p class="rss-subscribe">subscribe <a href="{{ "/feed.xml" | prepend: site.github.url }}">via RSS</a></p>
37
+
38
+ </div>
@@ -0,0 +1,9 @@
1
+ ---
2
+ layout: page
3
+ title: Methods
4
+ ---
5
+ {% for method in site.methods %}
6
+ <div class="method">
7
+ <h2><a href="{{ method.url | prepend: site.github.url }}">{{ method.title }}</a></h2>
8
+ </div>
9
+ {% endfor %}
@@ -0,0 +1,12 @@
1
+ ---
2
+ layout: page
3
+ title: Modules
4
+ ---
5
+
6
+ {% for module in site.modules %}
7
+ <div class="module">
8
+ <h2><a href="{{ module.url | prepend: site.github.url }}">{{ module.title }}</a></h2>
9
+ </div>
10
+ {% endfor %}
11
+
12
+ <p>If you are new to ruby, you can read more about <a href="https://www.tutorialspoint.com/ruby/ruby_modules.htm">modules here</a></p>
@@ -1,4 +1,4 @@
1
1
  # module to give version a namespace
2
2
  module Pbox2d
3
- VERSION = '0.9.1'
3
+ VERSION = '1.0.0'
4
4
  end
@@ -13,16 +13,13 @@ Gem::Specification.new do |spec|
13
13
  spec.email = ['mamba2928@yahoo.co.uk']
14
14
  spec.summary = %q{jbox2d wrapped in a gem for JRubyArt}
15
15
  spec.description = <<-EOF
16
- "An exemplar for making processing/java libraries available as a gem, for use
17
- in JRubyArt. Features a polyglot maven build, and also demonstrates how creating
18
- an interface can avoid the need for explicit calls to java reflection."
16
+ "An exemplar for making java libraries available as a gem, for use in JRubyArt /propane. Features a polyglot maven build, and also demonstrates how to create an interface so avoid needing explicit calls to java reflection."
19
17
  EOF
20
- spec.homepage = 'https://github.com/ruby-processing/jbox2d'
18
+ spec.homepage = 'https://ruby-processing.github.io/jbox2d'
21
19
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
20
  spec.files << 'lib/box2d.jar'
23
21
  spec.require_paths = ['lib']
24
- spec.add_dependency 'jruby_art', '~> 1.2'
25
- spec.add_development_dependency "rake", "~> 11.1"
26
- spec.add_development_dependency "minitest", "~> 5.8"
22
+ spec.add_development_dependency "rake", "~> 12.0"
23
+ spec.add_development_dependency "minitest", "~> 5.10"
27
24
  spec.platform='java'
28
25
  end
data/pom.rb CHANGED
@@ -2,7 +2,7 @@ require 'fileutils'
2
2
  project 'pbox2d', 'https://github.com/ruby-processing/jbox2d' do
3
3
 
4
4
  model_version '4.0.0'
5
- id 'ruby-processing:pbox2d', '0.9.1'
5
+ id 'ruby-processing:pbox2d', '1.0.0'
6
6
  packaging 'jar'
7
7
 
8
8
  description 'jbox2d for JRubyArt'
@@ -12,7 +12,7 @@ project 'pbox2d', 'https://github.com/ruby-processing/jbox2d' do
12
12
  developer 'monkstone' do
13
13
  name 'Martin Prout'
14
14
  email 'mamba2928@yahoo.co.uk'
15
- roles 'developer'
15
+ roles 'developer'
16
16
  end
17
17
 
18
18
  license 'BSD-2-clause', 'http://www.opensource.org/licenses/bsd-license.php'
@@ -24,7 +24,7 @@ project 'pbox2d', 'https://github.com/ruby-processing/jbox2d' do
24
24
  :connection => 'scm:git:git://github.com/ruby-processing/jbox2d.git',
25
25
  :developer_connection => 'scm:git:git@github.com/ruby-processing/jbox2dt.git'
26
26
  )
27
-
27
+
28
28
  properties( 'maven.compiler.source' => '1.8',
29
29
  'project.build.sourceEncoding' => 'UTF-8',
30
30
  'maven.compiler.target' => '1.8',
@@ -33,12 +33,14 @@ project 'pbox2d', 'https://github.com/ruby-processing/jbox2d' do
33
33
  'jruby.api' => "http://jruby.org/apidocs/"
34
34
  )
35
35
 
36
- pom 'org.jruby:jruby:9.1.5.0'
37
- jar 'org.processing:core:3.2.1'
36
+
37
+ pom 'org.jruby:jruby:9.1.8.0'
38
+ jar 'org.processing:core:3.3.0'
39
+
38
40
  plugin_management do
39
41
  plugin :resources, '2.6'
40
42
  plugin :dependency, '2.8'
41
- plugin(
43
+ plugin(
42
44
  :compiler, '3.5.1',
43
45
  source: '${maven.compiler.source}',
44
46
  target: '${maven.compiler.target}'
data/pom.xml CHANGED
@@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE
11
11
  <modelVersion>4.0.0</modelVersion>
12
12
  <groupId>ruby-processing</groupId>
13
13
  <artifactId>pbox2d</artifactId>
14
- <version>0.9.1</version>
14
+ <version>1.0.0</version>
15
15
  <name>pbox2d</name>
16
16
  <description>jbox2d for JRubyArt</description>
17
17
  <url>https://github.com/ruby-processing/jbox2d</url>
@@ -56,13 +56,13 @@ DO NOT MODIFIY - GENERATED CODE
56
56
  <dependency>
57
57
  <groupId>org.jruby</groupId>
58
58
  <artifactId>jruby</artifactId>
59
- <version>9.1.5.0</version>
59
+ <version>9.1.8.0</version>
60
60
  <type>pom</type>
61
61
  </dependency>
62
62
  <dependency>
63
63
  <groupId>org.processing</groupId>
64
64
  <artifactId>core</artifactId>
65
- <version>3.2.1</version>
65
+ <version>3.3.0</version>
66
66
  </dependency>
67
67
  </dependencies>
68
68
  <build>
@@ -69,8 +69,8 @@ public class AABB {
69
69
  * @param upperVertex
70
70
  */
71
71
  public AABB(final Vec2 lowerVertex, final Vec2 upperVertex) {
72
- this.lowerBound = lowerVertex.clone(); // clone to be safe
73
- this.upperBound = upperVertex.clone();
72
+ this.lowerBound = new Vec2(lowerVertex); // clone to be safe
73
+ this.upperBound = new Vec2(upperVertex);
74
74
  }
75
75
 
76
76
  /**
@@ -88,8 +88,8 @@ public class Manifold {
88
88
  */
89
89
  public Manifold(Manifold other) {
90
90
  points = new ManifoldPoint[Settings.maxManifoldPoints];
91
- localNormal = other.localNormal.clone();
92
- localPoint = other.localPoint.clone();
91
+ localNormal = new Vec2(other.localNormal);
92
+ localPoint = new Vec2(other.localPoint);
93
93
  pointCount = other.pointCount;
94
94
  type = other.type;
95
95
  // djm: this is correct now
@@ -57,7 +57,7 @@ import org.jbox2d.common.Vec2;
57
57
  * <ul><li>e_circles: the local center of circleB</li>
58
58
  * <li>e_faceA: the local center of cirlceB or the clip point of polygonB</li>
59
59
  * <li>e_faceB: the clip point of polygonA</li></ul>
60
- * This structure is stored across time steps, so we keep it small.<br/>
60
+ * This structure is stored across time steps, so we keep it small.
61
61
  * Note: the impulses are used for internal caching and may not
62
62
  * provide reliable contact forces, especially for high speed collisions.
63
63
  */
@@ -85,7 +85,7 @@ public class ManifoldPoint {
85
85
  * @param cp point to copy from
86
86
  */
87
87
  public ManifoldPoint(final ManifoldPoint cp) {
88
- localPoint = cp.localPoint.clone();
88
+ localPoint = new Vec2(cp.localPoint);
89
89
  normalImpulse = cp.normalImpulse;
90
90
  tangentImpulse = cp.tangentImpulse;
91
91
  id = new ContactID(cp.id);
@@ -84,7 +84,7 @@ public class MassData {
84
84
  public MassData(MassData md) {
85
85
  mass = md.mass;
86
86
  I = md.I;
87
- center = md.center.clone();
87
+ center = new Vec2(md.center);
88
88
  }
89
89
 
90
90
  public void set(MassData md) {
@@ -32,12 +32,15 @@ import java.io.Serializable;
32
32
  */
33
33
  public class Mat22 implements Serializable {
34
34
 
35
- private static final long serialVersionUID = 2L;
35
+ private static final long serialVersionUID = -3851554186221722070L;
36
+
37
+
36
38
 
37
39
  public final Vec2 ex, ey;
38
40
 
39
41
  /**
40
42
  * Convert the matrix to printable format.
43
+ * @return
41
44
  */
42
45
  @Override
43
46
  public String toString() {
@@ -63,8 +66,8 @@ public class Mat22 implements Serializable {
63
66
  * @param c2 Column 2 of matrix
64
67
  */
65
68
  public Mat22(final Vec2 c1, final Vec2 c2) {
66
- ex = c1.clone();
67
- ey = c2.clone();
69
+ ex = new Vec2(c1);
70
+ ey = new Vec2(c2);
68
71
  }
69
72
 
70
73
  /**
@@ -102,16 +105,6 @@ public class Mat22 implements Serializable {
102
105
  return this;
103
106
  }
104
107
 
105
- /**
106
- * Return a clone of this matrix. djm fixed double allocation
107
- *
108
- * @return
109
- */
110
- // @Override // annotation omitted for GWT-compatibility
111
- @Override
112
- public final Mat22 clone() {
113
- return new Mat22(ex, ey);
114
- }
115
108
 
116
109
  /**
117
110
  * Set as a matrix representing a rotation.
@@ -1,7 +1,7 @@
1
- /*******************************************************************************
1
+ /** *****************************************************************************
2
2
  * Copyright (c) 2013, Daniel Murphy
3
3
  * All rights reserved.
4
- *
4
+ *
5
5
  * Redistribution and use in source and binary forms, with or without modification,
6
6
  * are permitted provided that the following conditions are met:
7
7
  * * Redistributions of source code must retain the above copyright notice,
@@ -9,7 +9,7 @@
9
9
  * * Redistributions in binary form must reproduce the above copyright notice,
10
10
  * this list of conditions and the following disclaimer in the documentation
11
11
  * and/or other materials provided with the distribution.
12
- *
12
+ *
13
13
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
14
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
15
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@@ -20,271 +20,291 @@
20
20
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21
21
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22
22
  * POSSIBILITY OF SUCH DAMAGE.
23
- ******************************************************************************/
23
+ ***************************************************************************** */
24
24
  package org.jbox2d.common;
25
25
 
26
26
  import java.io.Serializable;
27
27
 
28
28
  /**
29
29
  * A 3-by-3 matrix. Stored in column-major order.
30
- *
30
+ *
31
31
  * @author Daniel Murphy
32
32
  */
33
33
  public class Mat33 implements Serializable {
34
- private static final long serialVersionUID = 2L;
35
34
 
36
- public static final Mat33 IDENTITY = new Mat33(new Vec3(1, 0, 0), new Vec3(0, 1, 0), new Vec3(0,
37
- 0, 1));
35
+ private static final long serialVersionUID = 536084358893657642L;
36
+ public static final Mat33 IDENTITY = new Mat33(
37
+ new Vec3(1, 0, 0),
38
+ new Vec3(0, 1, 0),
39
+ new Vec3(0, 0, 1)
40
+ );
38
41
 
39
- public final Vec3 ex, ey, ez;
42
+ public final Vec3 ex, ey, ez;
40
43
 
41
- public Mat33() {
42
- ex = new Vec3();
43
- ey = new Vec3();
44
- ez = new Vec3();
45
- }
46
-
47
- public Mat33(float exx, float exy, float exz, float eyx, float eyy, float eyz, float ezx,
48
- float ezy, float ezz) {
49
- ex = new Vec3(exx, exy, exz);
50
- ey = new Vec3(eyx, eyy, eyz);
51
- ez = new Vec3(ezx, ezy, ezz);
52
- }
53
-
54
- public Mat33(Vec3 argCol1, Vec3 argCol2, Vec3 argCol3) {
55
- ex = argCol1.clone();
56
- ey = argCol2.clone();
57
- ez = argCol3.clone();
58
- }
59
-
60
- public void setZero() {
61
- ex.setZero();
62
- ey.setZero();
63
- ez.setZero();
64
- }
65
-
66
- public void set(float exx, float exy, float exz, float eyx, float eyy, float eyz, float ezx,
67
- float ezy, float ezz) {
68
- ex.x = exx;
69
- ex.y = exy;
70
- ex.z = exz;
71
- ey.x = eyx;
72
- ey.y = eyy;
73
- ey.z = eyz;
74
- ez.x = eyx;
75
- ez.y = eyy;
76
- ez.z = eyz;
77
- }
78
-
79
- public void set(Mat33 mat) {
80
- Vec3 vec = mat.ex;
81
- ex.x = vec.x;
82
- ex.y = vec.y;
83
- ex.z = vec.z;
84
- Vec3 vec1 = mat.ey;
85
- ey.x = vec1.x;
86
- ey.y = vec1.y;
87
- ey.z = vec1.z;
88
- Vec3 vec2 = mat.ez;
89
- ez.x = vec2.x;
90
- ez.y = vec2.y;
91
- ez.z = vec2.z;
92
- }
93
-
94
- public void setIdentity() {
95
- ex.x = (float) 1;
96
- ex.y = (float) 0;
97
- ex.z = (float) 0;
98
- ey.x = (float) 0;
99
- ey.y = (float) 1;
100
- ey.z = (float) 0;
101
- ez.x = (float) 0;
102
- ez.y = (float) 0;
103
- ez.z = (float) 1;
104
- }
44
+ public Mat33() {
45
+ ex = new Vec3();
46
+ ey = new Vec3();
47
+ ez = new Vec3();
48
+ }
105
49
 
106
- // / Multiply a matrix times a vector.
107
- public static final Vec3 mul(Mat33 A, Vec3 v) {
108
- return new Vec3(v.x * A.ex.x + v.y * A.ey.x + v.z + A.ez.x, v.x * A.ex.y + v.y * A.ey.y + v.z
109
- * A.ez.y, v.x * A.ex.z + v.y * A.ey.z + v.z * A.ez.z);
110
- }
50
+ public Mat33(float exx, float exy, float exz, float eyx, float eyy, float eyz, float ezx,
51
+ float ezy, float ezz) {
52
+ ex = new Vec3(exx, exy, exz);
53
+ ey = new Vec3(eyx, eyy, eyz);
54
+ ez = new Vec3(ezx, ezy, ezz);
55
+ }
111
56
 
112
- public static final Vec2 mul22(Mat33 A, Vec2 v) {
113
- return new Vec2(A.ex.x * v.x + A.ey.x * v.y, A.ex.y * v.x + A.ey.y * v.y);
114
- }
57
+ public Mat33(Vec3 argCol1, Vec3 argCol2, Vec3 argCol3) {
58
+ ex = new Vec3(argCol1);
59
+ ey = new Vec3(argCol2);
60
+ ez = new Vec3(argCol3);
61
+ }
115
62
 
116
- public static final void mul22ToOut(Mat33 A, Vec2 v, Vec2 out) {
117
- final float tempx = A.ex.x * v.x + A.ey.x * v.y;
118
- out.y = A.ex.y * v.x + A.ey.y * v.y;
119
- out.x = tempx;
120
- }
63
+ public void setZero() {
64
+ ex.setZero();
65
+ ey.setZero();
66
+ ez.setZero();
67
+ }
121
68
 
122
- public static final void mul22ToOutUnsafe(Mat33 A, Vec2 v, Vec2 out) {
123
- assert (v != out);
124
- out.y = A.ex.y * v.x + A.ey.y * v.y;
125
- out.x = A.ex.x * v.x + A.ey.x * v.y;
126
- }
69
+ public void set(float exx, float exy, float exz, float eyx, float eyy, float eyz, float ezx,
70
+ float ezy, float ezz) {
71
+ ex.x = exx;
72
+ ex.y = exy;
73
+ ex.z = exz;
74
+ ey.x = eyx;
75
+ ey.y = eyy;
76
+ ey.z = eyz;
77
+ ez.x = eyx;
78
+ ez.y = eyy;
79
+ ez.z = eyz;
80
+ }
127
81
 
128
- public static final void mulToOut(Mat33 A, Vec3 v, Vec3 out) {
129
- final float tempy = v.x * A.ex.y + v.y * A.ey.y + v.z * A.ez.y;
130
- final float tempz = v.x * A.ex.z + v.y * A.ey.z + v.z * A.ez.z;
131
- out.x = v.x * A.ex.x + v.y * A.ey.x + v.z * A.ez.x;
132
- out.y = tempy;
133
- out.z = tempz;
134
- }
82
+ public void set(Mat33 mat) {
83
+ Vec3 vec = mat.ex;
84
+ ex.x = vec.x;
85
+ ex.y = vec.y;
86
+ ex.z = vec.z;
87
+ Vec3 vec1 = mat.ey;
88
+ ey.x = vec1.x;
89
+ ey.y = vec1.y;
90
+ ey.z = vec1.z;
91
+ Vec3 vec2 = mat.ez;
92
+ ez.x = vec2.x;
93
+ ez.y = vec2.y;
94
+ ez.z = vec2.z;
95
+ }
135
96
 
136
- public static final void mulToOutUnsafe(Mat33 A, Vec3 v, Vec3 out) {
137
- assert (out != v);
138
- out.x = v.x * A.ex.x + v.y * A.ey.x + v.z * A.ez.x;
139
- out.y = v.x * A.ex.y + v.y * A.ey.y + v.z * A.ez.y;
140
- out.z = v.x * A.ex.z + v.y * A.ey.z + v.z * A.ez.z;
141
- }
97
+ public void setIdentity() {
98
+ ex.x = (float) 1;
99
+ ex.y = (float) 0;
100
+ ex.z = (float) 0;
101
+ ey.x = (float) 0;
102
+ ey.y = (float) 1;
103
+ ey.z = (float) 0;
104
+ ez.x = (float) 0;
105
+ ez.y = (float) 0;
106
+ ez.z = (float) 1;
107
+ }
142
108
 
143
- /**
144
- * Solve A * x = b, where b is a column vector. This is more efficient than computing the inverse
145
- * in one-shot cases.
146
- *
147
- * @param b
148
- * @return
149
- */
150
- public final Vec2 solve22(Vec2 b) {
151
- Vec2 x = new Vec2();
152
- solve22ToOut(b, x);
153
- return x;
154
- }
109
+ // / Multiply a matrix times a vector.
110
+ public static final Vec3 mul(Mat33 A, Vec3 v) {
111
+ return new Vec3(v.x * A.ex.x + v.y * A.ey.x + v.z + A.ez.x, v.x * A.ex.y + v.y * A.ey.y + v.z
112
+ * A.ez.y, v.x * A.ex.z + v.y * A.ey.z + v.z * A.ez.z);
113
+ }
155
114
 
156
- /**
157
- * Solve A * x = b, where b is a column vector. This is more efficient than computing the inverse
158
- * in one-shot cases.
159
- *
160
- * @param b
161
- * @return
162
- */
163
- public final void solve22ToOut(Vec2 b, Vec2 out) {
164
- final float a11 = ex.x, a12 = ey.x, a21 = ex.y, a22 = ey.y;
165
- float det = a11 * a22 - a12 * a21;
166
- if (det != 0.0f) {
167
- det = 1.0f / det;
115
+ public static final Vec2 mul22(Mat33 A, Vec2 v) {
116
+ return new Vec2(A.ex.x * v.x + A.ey.x * v.y, A.ex.y * v.x + A.ey.y * v.y);
168
117
  }
169
- out.x = det * (a22 * b.x - a12 * b.y);
170
- out.y = det * (a11 * b.y - a21 * b.x);
171
- }
172
118
 
173
- // djm pooling from below
174
- /**
175
- * Solve A * x = b, where b is a column vector. This is more efficient than computing the inverse
176
- * in one-shot cases.
177
- *
178
- * @param b
179
- * @return
180
- */
181
- public final Vec3 solve33(Vec3 b) {
182
- Vec3 x = new Vec3();
183
- solve33ToOut(b, x);
184
- return x;
185
- }
119
+ public static final void mul22ToOut(Mat33 A, Vec2 v, Vec2 out) {
120
+ final float tempx = A.ex.x * v.x + A.ey.x * v.y;
121
+ out.y = A.ex.y * v.x + A.ey.y * v.y;
122
+ out.x = tempx;
123
+ }
186
124
 
187
- /**
188
- * Solve A * x = b, where b is a column vector. This is more efficient than computing the inverse
189
- * in one-shot cases.
190
- *
191
- * @param b
192
- * @param out the result
193
- */
194
- public final void solve33ToOut(Vec3 b, Vec3 out) {
195
- assert (b != out);
196
- Vec3.crossToOutUnsafe(ey, ez, out);
197
- float det = Vec3.dot(ex, out);
198
- if (det != 0.0f) {
199
- det = 1.0f / det;
125
+ public static final void mul22ToOutUnsafe(Mat33 A, Vec2 v, Vec2 out) {
126
+ assert (v != out);
127
+ out.y = A.ex.y * v.x + A.ey.y * v.y;
128
+ out.x = A.ex.x * v.x + A.ey.x * v.y;
200
129
  }
201
- Vec3.crossToOutUnsafe(ey, ez, out);
202
- final float x = det * Vec3.dot(b, out);
203
- Vec3.crossToOutUnsafe(b, ez, out);
204
- final float y = det * Vec3.dot(ex, out);
205
- Vec3.crossToOutUnsafe(ey, b, out);
206
- float z = det * Vec3.dot(ex, out);
207
- out.x = x;
208
- out.y = y;
209
- out.z = z;
210
- }
211
130
 
212
- public void getInverse22(Mat33 M) {
213
- float a = ex.x, b = ey.x, c = ex.y, d = ey.y;
214
- float det = a * d - b * c;
215
- if (det != 0.0f) {
216
- det = 1.0f / det;
131
+ public static final void mulToOut(Mat33 A, Vec3 v, Vec3 out) {
132
+ final float tempy = v.x * A.ex.y + v.y * A.ey.y + v.z * A.ez.y;
133
+ final float tempz = v.x * A.ex.z + v.y * A.ey.z + v.z * A.ez.z;
134
+ out.x = v.x * A.ex.x + v.y * A.ey.x + v.z * A.ez.x;
135
+ out.y = tempy;
136
+ out.z = tempz;
217
137
  }
218
138
 
219
- M.ex.x = det * d;
220
- M.ey.x = -det * b;
221
- M.ex.z = 0.0f;
222
- M.ex.y = -det * c;
223
- M.ey.y = det * a;
224
- M.ey.z = 0.0f;
225
- M.ez.x = 0.0f;
226
- M.ez.y = 0.0f;
227
- M.ez.z = 0.0f;
228
- }
139
+ public static final void mulToOutUnsafe(Mat33 A, Vec3 v, Vec3 out) {
140
+ assert (out != v);
141
+ out.x = v.x * A.ex.x + v.y * A.ey.x + v.z * A.ez.x;
142
+ out.y = v.x * A.ex.y + v.y * A.ey.y + v.z * A.ez.y;
143
+ out.z = v.x * A.ex.z + v.y * A.ey.z + v.z * A.ez.z;
144
+ }
229
145
 
230
- // / Returns the zero matrix if singular.
231
- public void getSymInverse33(Mat33 M) {
232
- float bx = ey.y * ez.z - ey.z * ez.y;
233
- float by = ey.z * ez.x - ey.x * ez.z;
234
- float bz = ey.x * ez.y - ey.y * ez.x;
235
- float det = ex.x * bx + ex.y * by + ex.z * bz;
236
- if (det != 0.0f) {
237
- det = 1.0f / det;
146
+ /**
147
+ * Solve A * x = b, where b is a column vector. This is more efficient than
148
+ * computing the inverse in one-shot cases.
149
+ *
150
+ * @param b
151
+ * @return
152
+ */
153
+ public final Vec2 solve22(Vec2 b) {
154
+ Vec2 x = new Vec2();
155
+ solve22ToOut(b, x);
156
+ return x;
238
157
  }
239
158
 
240
- float a11 = ex.x, a12 = ey.x, a13 = ez.x;
241
- float a22 = ey.y, a23 = ez.y;
242
- float a33 = ez.z;
159
+ /**
160
+ * Solve A * x = b, where b is a column vector. This is more efficient than
161
+ * computing the inverse in one-shot cases.
162
+ *
163
+ * @param b
164
+ * @param out
165
+ */
166
+ public final void solve22ToOut(Vec2 b, Vec2 out) {
167
+ final float a11 = ex.x, a12 = ey.x, a21 = ex.y, a22 = ey.y;
168
+ float det = a11 * a22 - a12 * a21;
169
+ if (det != 0.0f) {
170
+ det = 1.0f / det;
171
+ }
172
+ out.x = det * (a22 * b.x - a12 * b.y);
173
+ out.y = det * (a11 * b.y - a21 * b.x);
174
+ }
243
175
 
244
- M.ex.x = det * (a22 * a33 - a23 * a23);
245
- M.ex.y = det * (a13 * a23 - a12 * a33);
246
- M.ex.z = det * (a12 * a23 - a13 * a22);
176
+ // djm pooling from below
177
+ /**
178
+ * Solve A * x = b, where b is a column vector. This is more efficient than
179
+ * computing the inverse in one-shot cases.
180
+ *
181
+ * @param b
182
+ * @return
183
+ */
184
+ public final Vec3 solve33(Vec3 b) {
185
+ Vec3 x = new Vec3();
186
+ solve33ToOut(b, x);
187
+ return x;
188
+ }
247
189
 
248
- M.ey.x = M.ex.y;
249
- M.ey.y = det * (a11 * a33 - a13 * a13);
250
- M.ey.z = det * (a13 * a12 - a11 * a23);
190
+ /**
191
+ * Solve A * x = b, where b is a column vector. This is more efficient than
192
+ * computing the inverse in one-shot cases.
193
+ *
194
+ * @param b
195
+ * @param out the result
196
+ */
197
+ public final void solve33ToOut(Vec3 b, Vec3 out) {
198
+ assert (b != out);
199
+ Vec3.crossToOutUnsafe(ey, ez, out);
200
+ float det = Vec3.dot(ex, out);
201
+ if (det != 0.0f) {
202
+ det = 1.0f / det;
203
+ }
204
+ Vec3.crossToOutUnsafe(ey, ez, out);
205
+ final float x = det * Vec3.dot(b, out);
206
+ Vec3.crossToOutUnsafe(b, ez, out);
207
+ final float y = det * Vec3.dot(ex, out);
208
+ Vec3.crossToOutUnsafe(ey, b, out);
209
+ float z = det * Vec3.dot(ex, out);
210
+ out.x = x;
211
+ out.y = y;
212
+ out.z = z;
213
+ }
251
214
 
252
- M.ez.x = M.ex.z;
253
- M.ez.y = M.ey.z;
254
- M.ez.z = det * (a11 * a22 - a12 * a12);
255
- }
215
+ public void getInverse22(Mat33 M) {
216
+ float a = ex.x, b = ey.x, c = ex.y, d = ey.y;
217
+ float det = a * d - b * c;
218
+ if (det != 0.0f) {
219
+ det = 1.0f / det;
220
+ }
221
+
222
+ M.ex.x = det * d;
223
+ M.ey.x = -det * b;
224
+ M.ex.z = 0.0f;
225
+ M.ex.y = -det * c;
226
+ M.ey.y = det * a;
227
+ M.ey.z = 0.0f;
228
+ M.ez.x = 0.0f;
229
+ M.ez.y = 0.0f;
230
+ M.ez.z = 0.0f;
231
+ }
256
232
 
233
+ // / Returns the zero matrix if singular.
234
+ public void getSymInverse33(Mat33 M) {
235
+ float bx = ey.y * ez.z - ey.z * ez.y;
236
+ float by = ey.z * ez.x - ey.x * ez.z;
237
+ float bz = ey.x * ez.y - ey.y * ez.x;
238
+ float det = ex.x * bx + ex.y * by + ex.z * bz;
239
+ if (det != 0.0f) {
240
+ det = 1.0f / det;
241
+ }
242
+
243
+ float a11 = ex.x, a12 = ey.x, a13 = ez.x;
244
+ float a22 = ey.y, a23 = ez.y;
245
+ float a33 = ez.z;
246
+
247
+ M.ex.x = det * (a22 * a33 - a23 * a23);
248
+ M.ex.y = det * (a13 * a23 - a12 * a33);
249
+ M.ex.z = det * (a12 * a23 - a13 * a22);
250
+
251
+ M.ey.x = M.ex.y;
252
+ M.ey.y = det * (a11 * a33 - a13 * a13);
253
+ M.ey.z = det * (a13 * a12 - a11 * a23);
254
+
255
+ M.ez.x = M.ex.z;
256
+ M.ez.y = M.ey.z;
257
+ M.ez.z = det * (a11 * a22 - a12 * a12);
258
+ }
257
259
 
258
- public final static void setScaleTransform(float scale, Mat33 out) {
259
- out.ex.x = scale;
260
- out.ey.y = scale;
261
- }
260
+ public final static void setScaleTransform(float scale, Mat33 out) {
261
+ out.ex.x = scale;
262
+ out.ey.y = scale;
263
+ }
262
264
 
263
- @Override
264
- public int hashCode() {
265
- final int prime = 31;
266
- int result = 1;
267
- result = prime * result + ((ex == null) ? 0 : ex.hashCode());
268
- result = prime * result + ((ey == null) ? 0 : ey.hashCode());
269
- result = prime * result + ((ez == null) ? 0 : ez.hashCode());
270
- return result;
271
- }
265
+ @Override
266
+ public int hashCode() {
267
+ final int prime = 31;
268
+ int result = 1;
269
+ result = prime * result + ((ex == null) ? 0 : ex.hashCode());
270
+ result = prime * result + ((ey == null) ? 0 : ey.hashCode());
271
+ result = prime * result + ((ez == null) ? 0 : ez.hashCode());
272
+ return result;
273
+ }
272
274
 
273
- @Override
274
- public boolean equals(Object obj) {
275
- if (this == obj) return true;
276
- if (obj == null) return false;
277
- if (getClass() != obj.getClass()) return false;
278
- Mat33 other = (Mat33) obj;
279
- if (ex == null) {
280
- if (other.ex != null) return false;
281
- } else if (!ex.equals(other.ex)) return false;
282
- if (ey == null) {
283
- if (other.ey != null) return false;
284
- } else if (!ey.equals(other.ey)) return false;
285
- if (ez == null) {
286
- if (other.ez != null) return false;
287
- } else if (!ez.equals(other.ez)) return false;
288
- return true;
289
- }
275
+ @Override
276
+ public boolean equals(Object obj) {
277
+ if (this == obj) {
278
+ return true;
279
+ }
280
+ if (obj == null) {
281
+ return false;
282
+ }
283
+ if (getClass() != obj.getClass()) {
284
+ return false;
285
+ }
286
+ Mat33 other = (Mat33) obj;
287
+ if (ex == null) {
288
+ if (other.ex != null) {
289
+ return false;
290
+ }
291
+ } else if (!ex.equals(other.ex)) {
292
+ return false;
293
+ }
294
+ if (ey == null) {
295
+ if (other.ey != null) {
296
+ return false;
297
+ }
298
+ } else if (!ey.equals(other.ey)) {
299
+ return false;
300
+ }
301
+ if (ez == null) {
302
+ if (other.ez != null) {
303
+ return false;
304
+ }
305
+ } else if (!ez.equals(other.ez)) {
306
+ return false;
307
+ }
308
+ return true;
309
+ }
290
310
  }