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,7 @@
1
+ ---
2
+ layout: page
3
+ title: "World Builder"
4
+ permalink: /classes/world_builder/
5
+ ---
6
+
7
+ @box2d = WorldBuilder.build(app: self, gravity: [0, -20])
@@ -0,0 +1,32 @@
1
+ # Site settings
2
+ port: 4000
3
+ title: PBox2D for JRubyArt
4
+ email: mamba2928@yahoo.co.uk
5
+ description: > # this means to ignore newlines until "baseurl:"
6
+ PBox2D is a ruby wrapper for JBox2D, so you can use the physics engine with JRubyArt or propane (NB: original ruby-processing is no longer supported).
7
+ baseurl: "" # the subpath of your site, e.g. /blog
8
+ url: "https://ruby-processing.github.io/pbox2d"
9
+ urls:
10
+ bugs: http://github.com/ruby-processing/pbox2d/issues
11
+ github: http://github.com/ruby-processing/pbox2d/
12
+ twitter_username: monkstoneT
13
+ github_username: monkstone
14
+ include: [collections]
15
+ collections:
16
+ classes:
17
+ output: true
18
+ permalink: /classes/:path
19
+ methods:
20
+ output: true
21
+ permalink: /methods/:path
22
+ modules:
23
+ output: true
24
+ permalink: /modules/:path
25
+
26
+ syntax-highlighting:
27
+ enabled: true
28
+
29
+ # Build settings
30
+ markdown: kramdown
31
+ gems:
32
+ - jekyll-sitemap
@@ -0,0 +1,55 @@
1
+ <footer class="site-footer">
2
+
3
+ <div class="wrapper">
4
+
5
+ <h2 class="footer-heading">{{ site.title }}</h2>
6
+
7
+ <div class="footer-col-wrapper">
8
+ <div class="footer-col footer-col-1">
9
+ <ul class="contact-list">
10
+ <li>{{ site.title }}</li>
11
+ <li><a href="mailto:{{ site.email }}">{{ site.email }}</a></li>
12
+ </ul>
13
+ </div>
14
+
15
+ <div class="footer-col footer-col-2">
16
+ <ul class="social-media-list">
17
+ {% if site.github_username %}
18
+ <li>
19
+ <a href="https://github.com/{{ site.github_username }}">
20
+ <span class="icon icon--github">
21
+ <svg viewBox="0 0 16 16">
22
+ <path fill="#828282" d="M7.999,0.431c-4.285,0-7.76,3.474-7.76,7.761 c0,3.428,2.223,6.337,5.307,7.363c0.388,0.071,0.53-0.168,0.53-0.374c0-0.184-0.007-0.672-0.01-1.32 c-2.159,0.469-2.614-1.04-2.614-1.04c-0.353-0.896-0.862-1.135-0.862-1.135c-0.705-0.481,0.053-0.472,0.053-0.472 c0.779,0.055,1.189,0.8,1.189,0.8c0.692,1.186,1.816,0.843,2.258,0.645c0.071-0.502,0.271-0.843,0.493-1.037 C4.86,11.425,3.049,10.76,3.049,7.786c0-0.847,0.302-1.54,0.799-2.082C3.768,5.507,3.501,4.718,3.924,3.65 c0,0,0.652-0.209,2.134,0.796C6.677,4.273,7.34,4.187,8,4.184c0.659,0.003,1.323,0.089,1.943,0.261 c1.482-1.004,2.132-0.796,2.132-0.796c0.423,1.068,0.157,1.857,0.077,2.054c0.497,0.542,0.798,1.235,0.798,2.082 c0,2.981-1.814,3.637-3.543,3.829c0.279,0.24,0.527,0.713,0.527,1.437c0,1.037-0.01,1.874-0.01,2.129 c0,0.208,0.14,0.449,0.534,0.373c3.081-1.028,5.302-3.935,5.302-7.362C15.76,3.906,12.285,0.431,7.999,0.431z"/>
23
+ </svg>
24
+ </span>
25
+
26
+ <span class="username">{{ site.github_username }}</span>
27
+ </a>
28
+ </li>
29
+ {% endif %}
30
+
31
+ {% if site.twitter_username %}
32
+ <li>
33
+ <a href="https://twitter.com/{{ site.twitter_username }}">
34
+ <span class="icon icon--twitter">
35
+ <svg viewBox="0 0 16 16">
36
+ <path fill="#828282" d="M15.969,3.058c-0.586,0.26-1.217,0.436-1.878,0.515c0.675-0.405,1.194-1.045,1.438-1.809
37
+ c-0.632,0.375-1.332,0.647-2.076,0.793c-0.596-0.636-1.446-1.033-2.387-1.033c-1.806,0-3.27,1.464-3.27,3.27 c0,0.256,0.029,0.506,0.085,0.745C5.163,5.404,2.753,4.102,1.14,2.124C0.859,2.607,0.698,3.168,0.698,3.767 c0,1.134,0.577,2.135,1.455,2.722C1.616,6.472,1.112,6.325,0.671,6.08c0,0.014,0,0.027,0,0.041c0,1.584,1.127,2.906,2.623,3.206 C3.02,9.402,2.731,9.442,2.433,9.442c-0.211,0-0.416-0.021-0.615-0.059c0.416,1.299,1.624,2.245,3.055,2.271 c-1.119,0.877-2.529,1.4-4.061,1.4c-0.264,0-0.524-0.015-0.78-0.046c1.447,0.928,3.166,1.469,5.013,1.469 c6.015,0,9.304-4.983,9.304-9.304c0-0.142-0.003-0.283-0.009-0.423C14.976,4.29,15.531,3.714,15.969,3.058z"/>
38
+ </svg>
39
+ </span>
40
+
41
+ <span class="username">{{ site.twitter_username }}</span>
42
+ </a>
43
+ </li>
44
+ {% endif %}
45
+ </ul>
46
+ </div>
47
+
48
+ <div class="footer-col footer-col-3">
49
+ <p class="text">{{ site.description }}</p>
50
+ </div>
51
+ </div>
52
+
53
+ </div>
54
+
55
+ </footer>
@@ -0,0 +1,18 @@
1
+ <head>
2
+ <meta charset="utf-8">
3
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
4
+ <meta name="viewport" content="width=device-width, initial-scale=1">
5
+ {% if page.keywords %}
6
+ <meta name="keywords" content="{{ page.keywords }}" />
7
+ {% else %}
8
+ <meta name="keywords" content="art, JRubyArt, code, blog, ruby" />
9
+ {% endif %}<title>{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}</title>
10
+ <meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
11
+
12
+ <link rel="stylesheet" href="https://ruby-processing.github.io/JRubyArt/css/main.css"/>
13
+ <link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.github.url | prepend: site.url }}">
14
+ <link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.github.url | prepend: site.url }}" />
15
+ </head>
16
+
17
+
18
+
@@ -0,0 +1,27 @@
1
+ <header class="site-header">
2
+
3
+ <div class="wrapper">
4
+
5
+ <a class="site-title" href="{{ site.github.url }}/">{{ site.title }}</a>
6
+
7
+ <nav class="site-nav">
8
+ <a href="#" class="menu-icon">
9
+ <svg viewBox="0 0 18 15">
10
+ <path fill="#424242" d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.031C17.335,0,18,0.665,18,1.484L18,1.484z"/>
11
+ <path fill="#424242" d="M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0c0-0.82,0.665-1.484,1.484-1.484 h15.031C17.335,6.031,18,6.696,18,7.516L18,7.516z"/>
12
+ <path fill="#424242" d="M18,13.516C18,14.335,17.335,15,16.516,15H1.484C0.665,15,0,14.335,0,13.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.031C17.335,12.031,18,12.696,18,13.516L18,13.516z"/>
13
+ </svg>
14
+ </a>
15
+
16
+ <div class="trigger">
17
+ {% for page in site.pages %}
18
+ {% if page.title %}
19
+ <a class="page-link" href="{{ page.url | prepend: site.github.url }}">{{ page.title }}</a>
20
+ {% endif %}
21
+ {% endfor %}
22
+ </div>
23
+ </nav>
24
+
25
+ </div>
26
+
27
+ </header>
@@ -0,0 +1,8 @@
1
+ <nav class="menu">
2
+ <ul>
3
+ <li><a href="#">Products</a></li>
4
+ <li><a href="#">Download</a></li>
5
+ <li><a href="#">Support</a></li>
6
+ <li><a href="#">Buy Now</a></li>
7
+ </ul>
8
+ </nav>
@@ -0,0 +1,24 @@
1
+ {% capture html %}
2
+ <ul>
3
+ {% if include.context == "/" %}
4
+ <li class="{% if page.url == "/" %}active{% endif %}">
5
+ <a href="{{ site.github.url }}/">{{ site.title }}</a>
6
+ </li>
7
+ {% endif %}
8
+
9
+ {% assign entries = site.pages | sort: "path" %}
10
+ {% for entry in entries %}
11
+
12
+ {% capture slug %}{{ entry.url | split: "/" | last }}{% endcapture %}
13
+ {% capture current %}{{ entry.url | remove: slug | remove: "//" | append: "/" }}{% endcapture %}
14
+
15
+ {% if current == include.context %}
16
+ <li class="{% if page.url contains entry.url %}active{% endif %}">
17
+ <a href="{{ site.github.url }}{{ entry.url }}">{{ entry.title }}</a>
18
+ {% include navigation.html context=entry.url %}
19
+ </li>
20
+ {% endif %}
21
+
22
+ {% endfor %}
23
+ </ul>
24
+ {% endcapture %}{{ html | strip_newlines | replace:' ','' | replace:' ','' | replace:' ',' ' }}
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ {% include head.html %}
5
+
6
+ <body>
7
+
8
+ {% include header.html %}
9
+
10
+ <div class="page-content">
11
+ <div class="wrapper">
12
+ {{ content }}
13
+ </div>
14
+ </div>
15
+
16
+ {% include footer.html %}
17
+
18
+ </body>
19
+
20
+ </html>
@@ -0,0 +1,14 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+ <div class="post">
5
+
6
+ <header class="post-header">
7
+ <h1 class="post-title">{{ page.title }}</h1>
8
+ </header>
9
+
10
+ <article class="post-content">
11
+ {{ content }}
12
+ </article>
13
+
14
+ </div>
@@ -0,0 +1,15 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+ <div class="post">
5
+
6
+ <header class="post-header">
7
+ <h1 class="post-title">{{ page.title }}</h1>
8
+ <p class="post-meta">{{ page.date | date: "%b %-d, %Y" }}{% if page.author %} • {{ page.author }}{% endif %}{% if page.meta %} • {{ page.meta }}{% endif %}</p>
9
+ </header>
10
+
11
+ <article class="post-content">
12
+ {{ content }}
13
+ </article>
14
+
15
+ </div>
@@ -0,0 +1,28 @@
1
+ ---
2
+ layout: post
3
+ title: "init_options"
4
+ permalink: /methods/init_options/
5
+ ---
6
+
7
+ ### init_options method ###
8
+ Need not called directly if using [WorldBuilder][world_builder]
9
+ ```ruby
10
+ def init_options(args = {})
11
+ args = defaults.merge(args)
12
+ set_options(args[:scale],
13
+ args[:gravity].to_java(Java::float),
14
+ args[:warm],
15
+ args[:continuous]
16
+ )
17
+ end
18
+ ```
19
+
20
+ ### related default options ###
21
+ Provides defaults for init_options
22
+ ```ruby
23
+ def defaults
24
+ { scale: 10.0, gravity: [0, -10], warm: true, continuous: true }
25
+ end
26
+ ```
27
+
28
+ [world_builder]:{{ site.github.url }}/modules/world_builder/
@@ -0,0 +1,29 @@
1
+ ---
2
+ layout: post
3
+ title: "processing_to_world"
4
+ permalink: /methods/processing_to_world/
5
+ ---
6
+ From sketch to physics world and vice versa
7
+
8
+ Because of the peculiar choice by the processing guys down is up (dimensions in pixels) jbox2d doesn't like to live in the pixel world (where up is really up), and prefers meters or feet and inches (whatever). What this means is that there is a need to scale between the two worlds using [world_to_processing][world_to_processing] and processing_to_world methods provided. You should study the included example sketches.
9
+
10
+
11
+ The java code ([PBox2D][pbox2d] inherits this from [Box2DProcessing][pbox2d])
12
+ ### public Vec2 processingToWorld(float worldX, float worldY) ###
13
+ ```java
14
+ public Vec2 processingToWorld(float pixelX, float pixelY) {
15
+ float worldX = map(pixelX, parent.width / 2, parent.width / 2 + scaleFactor, 0f, 1f);
16
+ float worldY = map(pixelY, parent.height / 2, parent.height / 2 + scaleFactor, 1f, 0f);
17
+ return new Vec2(worldX, worldY);
18
+ }
19
+ ```
20
+
21
+ ### Ruby usage ###
22
+ Use camel case
23
+ ```ruby
24
+ processing_to_world(x, y) # returns new Vec2 instance (in the PBox2D world)
25
+ ```
26
+
27
+ [pbox2d]:{{ site.github.url }}/classes/pbox2d/
28
+ [world_to_processing]:{{ site.github.url }}/methods/world_to_processing/
29
+ [examples]:https://github.com/ruby-processing/JRubyArt-examples/tree/master/external_library/gem/pbox2d/
@@ -0,0 +1,24 @@
1
+ ---
2
+ layout: post
3
+ title: "scale_to_processing"
4
+ permalink: /methods/scale_to_processing/
5
+ ---
6
+ From sketch to physics world and vice versa
7
+
8
+ The java code ([PBox2D][pbox2d] inherits this from [Box2DProcessing][pbox2d])
9
+ ### public float scaleToProcessing(float val) ###
10
+ ```java
11
+ public float scaleToProcessing(float val) {
12
+ return val * scaleFactor;
13
+ }
14
+ ```
15
+
16
+ ### Ruby usage ###
17
+ Use camel case
18
+ ```ruby
19
+ scale_to_processing(val)
20
+ ```
21
+
22
+ [pbox2d]:{{ site.github.url }}/classes/pbox2d/
23
+ [world_to_processing]:{{ site.github.url }}/methods/world_to_processing/
24
+ [examples]:https://github.com/ruby-processing/JRubyArt-examples/tree/master/external_library/gem/pbox2d/
@@ -0,0 +1,29 @@
1
+ ---
2
+ layout: post
3
+ title: "scale_to_world"
4
+ permalink: /methods/scale_to_world/
5
+ ---
6
+ From sketch to physics world
7
+
8
+ Because of the peculiar choice by the processing guys down is up (dimensions in pixels) jbox2d doesn't like to live in the pixel world (where up is really up), and prefers meters or feet and inches (whatever). What this means is that there is a need to scale between the two worlds using [world_to_processing][world_to_processing] and processing_to_world methods provided. You should study the included example sketches.
9
+
10
+
11
+ The java code ([PBox2D][pbox2d] inherits this from [Box2DProcessing][pbox2d])
12
+ ### public Vec2 scaleToWorld(float worldX, float worldY) ###
13
+ ```java
14
+ public Vec2 scaleToWorld(float pixelX, float pixelY) {
15
+ float worldX = map(pixelX, parent.width / 2, parent.width / 2 + scaleFactor, 0f, 1f);
16
+ float worldY = map(pixelY, parent.height / 2, parent.height / 2 + scaleFactor, 1f, 0f);
17
+ return new Vec2(worldX, worldY);
18
+ }
19
+ ```
20
+
21
+ ### Ruby usage ###
22
+ Use camel case
23
+ ```ruby
24
+ scale_to_world(x, y) # returns new Vec2 instance (in the PBox2D world)
25
+ ```
26
+
27
+ [pbox2d]:{{ site.github.url }}/classes/pbox2d/
28
+ [world_to_processing]:{{ site.github.url }}/methods/world_to_processing/
29
+ [examples]:https://github.com/ruby-processing/JRubyArt-examples/tree/master/external_library/gem/pbox2d/
@@ -0,0 +1,25 @@
1
+ ---
2
+
3
+ layout: post
4
+ title: "step_options"
5
+ permalink: /methods/step_options/
6
+ ---
7
+ Need not be called directly especially when using [WorldBuilder][world_builder]
8
+
9
+ ```ruby
10
+ def step_options(args = {})
11
+ default_step.merge(args)
12
+ # now call the java method
13
+ set_step(args[:time_step], args[:velocity_iter], args[:position_iter])
14
+ end
15
+ ```
16
+
17
+ The default options
18
+
19
+ ```ruby
20
+ def default_step
21
+ { time_step: 1.0 / 60, velocity_iter: 8, position_iter: 10 }
22
+ end
23
+ ```
24
+
25
+ [world_builder]:{{ site.github.url }}/modules/world_builder/
@@ -0,0 +1,30 @@
1
+ ---
2
+ layout: post
3
+ title: "world_to_processing"
4
+ date: 2016-05-23 05:04:00
5
+ categories: jruby_art update
6
+ permalink: /methods/world_to_processing/
7
+ ---
8
+ From physics world to sketch
9
+
10
+ Because of the peculiar choice by the processing guys down is up (dimensions in pixels) jbox2d doesn't like to live in the pixel world (where up is really up), and prefers meters or feet and inches (whatever). What this means is that there is a need to scale between the two worlds using world_to_processing and [processing_to_world][processing_to_world] methods provided. You should also study the included [example sketches][examples].
11
+
12
+ The java code ([PBox2D][pbox2d] inherits this from [Box2DProcessing][pbox2d])
13
+ ### public Vec2 worldToProcessing(float worldX, float worldY) ###
14
+ ```java
15
+ public Vec2 worldToProcessing(float worldX, float worldY) {
16
+ float pixelX = map(worldX, 0f, 1f, parent.width / 2, parent.width / 2 + scaleFactor);
17
+ float pixelY = map(worldY, 1f, 0f, parent.height / 2, parent.height / 2 + scaleFactor);
18
+ return new Vec2(pixelX, pixelY);
19
+ }
20
+ ```
21
+
22
+ ### Ruby usage ###
23
+ Use camel case
24
+ ```ruby
25
+ world_to_processing(x, y) # returns new Vec2 instance (in processing world)
26
+ ```
27
+
28
+ [pbox2d]:{{ site.github.url }}/classes/pbox2d/
29
+ [processing_to_world]:{{ site.github.url }}/methods/processing_to_world/
30
+ [examples]:https://github.com/ruby-processing/JRubyArt-examples/tree/master/external_library/gem/pbox2d/
@@ -0,0 +1,25 @@
1
+ ---
2
+ layout: page
3
+ title: "PB (namespace)"
4
+ permalink: /modules/world_builder/
5
+ ---
6
+ ```ruby
7
+ # Import into module namespace to avoid likely clashes
8
+ module PB
9
+ particle = %w(
10
+ ParticleColor
11
+ ParticleContact
12
+ ParticleGroupDef
13
+ ParticleBodyContact
14
+ ParticleGroup
15
+ ParticleType
16
+ ParticleGroupType
17
+ ParticleGroupDef
18
+ ParticleSystem
19
+ StackQueue
20
+ VoronoiDiagram
21
+ )
22
+ particle_format = 'org.jbox2d.particle.%s'
23
+ import_class_list(particle, particle_format)
24
+ end
25
+ ```
@@ -0,0 +1,26 @@
1
+ ---
2
+ layout: page
3
+ title: "World Builder"
4
+ permalink: /modules/world_builder/
5
+ ---
6
+ The WorldBuilder module is a factory, that provides a flexible options signature, and hides the post intialization of Box2D. Note that `app:` is a required keyword.
7
+ ```ruby
8
+ module WorldBuilder
9
+ def self.build(app:, **opts)
10
+ b2d = Box2D.new(app)
11
+ b2d.init_options(opts)
12
+ b2d.create_world
13
+ b2d
14
+ end
15
+ end
16
+ ```
17
+
18
+ Usage:
19
+ Strictly the `gravity:` option is optional here, it is only used to demonstrate a valid argument. No acceleration in horizontal plane and negative (falling) acceleration in vertical plane.
20
+ ```ruby
21
+ @box2d = WorldBuilder.build(app: self, gravity: [0, -20])
22
+ ```
23
+
24
+ See [:init_options][init_options] and [:defaults][init_options] methods for a list of available options
25
+
26
+ [init_options]:{{ site.github.url }}/methods/init_options/