physicist 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aee543d5cc6e018d25dd06a3b84f94490ff77b3f
4
- data.tar.gz: 0e4e0cd6af0872824e244c5a1bdac12acb997dee
3
+ metadata.gz: 359917ba2ec8f06edc33b4d9fbec05dd36e622bc
4
+ data.tar.gz: 9ee416a418160ba5f948f6283a6b572deb300328
5
5
  SHA512:
6
- metadata.gz: c6ac4ad15db33433681017ca4dbeb7ed005ab6fccf0ccb8a4699b2914d21cf4c6498100629d2d3934c912d312d16aec49d4d68d3318eb916f040368e1d4ab49b
7
- data.tar.gz: 7e6e63040ee76e058162cfbf22867d1437add7d6023e93fa363353bf23262e6ead53e6e86ac33363492bfd66dbc08355c5ef39a92f0a042652fbdca7d5b8e5ea
6
+ metadata.gz: e4687ef6776f002b73ade206beab667da15d78767087ba4f222ae587d6d0c2c667fe37e2f1b82fd8af3b860d0bcbc771f2ece0f845bea135cb18170bac6a10a9
7
+ data.tar.gz: 76a2db66b9a93382b8e9b35d5962d5c968ce201ae120ad36d6e1034d42f0df515cf12efa0929e2848028713b7f5ff0b7d347a7e1081b80b1d5f18dee11270cd0
@@ -1,6 +1,7 @@
1
1
  module Physicist
2
2
  class Body
3
3
  attr_reader :position, :velocity, :t0, :dimensions
4
+ attr_accessor :overflow_time
4
5
 
5
6
  def initialize(position:, velocity:, t0:, dimensions:)
6
7
  @position = position
@@ -18,7 +19,7 @@ module Physicist
18
19
  end
19
20
 
20
21
  def gravity
21
- 50.0
22
+ 30.0
22
23
  end
23
24
 
24
25
  def friction
@@ -30,7 +31,31 @@ module Physicist
30
31
  0.00000000001
31
32
  end
32
33
 
33
- def at(t, obstacles:[])
34
+ def planck_time
35
+ 0.0125
36
+ end
37
+
38
+ def at(t, obstacles:[], fixed_timestep: false)
39
+ if fixed_timestep
40
+ # proceed in fixed timesteps...
41
+ dt = t - t0
42
+ acc = 0.0
43
+
44
+ body = self
45
+ while acc < dt + (overflow_time||0.0)
46
+ acc += planck_time
47
+ body = body.predict(t + acc, obstacles: obstacles)
48
+ end
49
+
50
+ # body.overflow_time = acc - (dt + (overflow_time||0.0))
51
+ body
52
+ else
53
+ predict(t, obstacles: obstacles)
54
+ end
55
+ end
56
+
57
+ # predict without proceeding in fixed time-steps from last-updated
58
+ def predict(t, obstacles: [])
34
59
  x0, _ = *position
35
60
  vx0,vy0 = *velocity
36
61
 
@@ -1,4 +1,4 @@
1
1
  module Physicist
2
2
  # physicist version
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
@@ -124,8 +124,8 @@ describe Body do
124
124
  it 'should be in freefall' do
125
125
  _,vy = *body_at_t.velocity
126
126
  _,y = *body_at_t.position
127
- expect(y0 + 50.0).to eq(y)
128
- expect(vy).to eq(50.0)
127
+ expect(y0 + body.gravity).to eq(y)
128
+ expect(vy).to eq(body.gravity)
129
129
  end
130
130
  end
131
131
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: physicist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Weissman