Skip to content

Commit 6c9bfdc

Browse files
committed
flesh out readme
1 parent 88ee79b commit 6c9bfdc

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,28 @@ to run
1313
math_demo
1414
```
1515

16+
### Now you've installed propane! Get more examples to try:-
17+
18+
```bash
19+
propane --install samples
20+
```
21+
The samples get copied to `~/propane_samples`, NB: depends on `wget`. for a simple demo of circumcircle math see `~/propane_samples/processing_app/library/vecmath/vec2d/circumcircle_sketch.rb` or to run samples as a demo:-
22+
```bash
23+
cd ~/propane_samples
24+
rake
25+
# Some sketches require opengl which doesn't get installed on windows.
26+
# For other libraries see below
27+
```
28+
Or to run individual sketches `cd` to directory and:-
29+
```bash
30+
jruby sketch_name.rb
31+
```
32+
Or explore using `atom` editor and use `script` plugin to run (NB: make sure the file type is `Ruby` or `JRubyArt`, sketches wont run with type as `Ruby on Rails`) also make sure `jruby` is on your `path`.
33+
34+
### Propane documentation
35+
36+
[Propane web-site](https://ruby-processing.github.io/propane/)
37+
1638
### Scope for improvement
1739

1840
In theory we should be able to use nmatrix (jruby version) in the matrix calculation, possibly on the gpu https://groups.google.com/forum/#!topic/sciruby-dev/CIC0EuTRNAk

lib/math_demo/t_points.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require 'forwardable'
33
MAX_POINT = 3
44
# A collection of a maximum of 3 points in the processing world
5-
# includes a collinearity test using Vec2D
5+
# includes a collinearity test using Vec2D positions
66
class TrianglePoints
77
extend Forwardable
88
def_delegators(:@points, :each, :map, :size, :shift, :clear, :[])
@@ -20,8 +20,8 @@ def <<(pt)
2020
end
2121

2222
def collinear?
23-
pos1 = positions[1]
24-
full? ? (positions[0] - pos1).cross(pos1 - positions[2]).zero? : false
23+
first, second, third = positions
24+
full? ? (first - second).cross(second - third).zero? : false
2525
end
2626

2727
# returns positions as an array of Vec2D

lib/math_demo/triangle_point.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
# particle and triangle point
33
class TPoint
44
include Propane::Proxy
5-
attr_reader :pos, :vel, :accel, :xbound, :ybound
5+
attr_reader :pos, :vel, :accel, :bounds
66
# attr_reader :width, :height # uncomment for testing
77

88
def initialize(position)
99
@pos = position
1010
@vel = Vec2D.new
1111
@accel = Vec2D.random
12-
@xbound = Boundary.new(0, width)
13-
@ybound = Boundary.new(0, height)
12+
@bounds = [Boundary.new(0, width), Boundary.new(0, height)]
1413
end
1514

1615
def direction(acc)
@@ -33,8 +32,8 @@ def update
3332
private
3433

3534
def check_bounds
36-
@vel.x *= -1 if xbound.exclude? pos.x
37-
@vel.y *= -1 if ybound.exclude? pos.y
35+
@vel.x *= -1 if bounds[0].exclude? pos.x
36+
@vel.y *= -1 if bounds[1].exclude? pos.y
3837
end
3938
end
4039

0 commit comments

Comments
 (0)