gamebox 0.5.2 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 487cfbc0092a899c74c2f07629e61103cf260b04
4
- data.tar.gz: af6c816285ad7ec45b7c2d55210a440678369da3
3
+ metadata.gz: 3008b56dae9d3f599c6ea9cf087fab7eda3f7415
4
+ data.tar.gz: 839970de9cdc8bf84b494b9235ab00c05c1f905a
5
5
  SHA512:
6
- metadata.gz: d5697dae2d2c4445f3ad9a3f80d934d7441f7c366e67385b7e217b834c06032e14a591f8b8b3ad3ae2fe69a479b9b1ab6c843acf0e0b5dfa5b1ce51ebb6949ea
7
- data.tar.gz: a919445492b6544466be9732f41db72f0700dfe5034aa8ae4f6350b0618f71f07ef9cbcb0e7d0754e899317b3aa9308aea47e04a508b3fd684cbd8a4f1029e85
6
+ metadata.gz: 8f415885718ab713f721576793cd6a40871c65ce6a2d5fbefea48aed95f1b7819de5d9667d467d36e6c5e0918ac34b29ed7bd414728b64d62e5356873cdb854d
7
+ data.tar.gz: 4016cdab6f3868066794c50aa4b52fe00df4e874ca26f816a8814a15174adce68c36cf3d80b38217e7cb837d683c9610f017e11e8c4409cbff171afa723fb96f
@@ -29,8 +29,8 @@ class Vector2
29
29
 
30
30
  RAD_TO_DEG = 180.0 / Math::PI
31
31
  DEG_TO_RAD = Math::PI / 180.0
32
- MAX_DOT_PRODUCT = 1.0
33
- MIN_DOT_PRODUCT = -1.0
32
+ MAX_UDOT_PRODUCT = 1.0
33
+ MIN_UDOT_PRODUCT = -1.0
34
34
 
35
35
  class << self
36
36
 
@@ -256,7 +256,7 @@ class Vector2
256
256
  # in radians. Use #angle_deg_with for degrees.
257
257
  #
258
258
  def angle_with( vector )
259
- Math.acos( udot(vector) )
259
+ Math.acos( max(min(udot(vector),MAX_UDOT_PRODUCT), MIN_UDOT_PRODUCT) )
260
260
  end
261
261
 
262
262
 
@@ -287,8 +287,7 @@ class Vector2
287
287
 
288
288
  # Returns the dot product between this vector and the other vector.
289
289
  def dot( vector )
290
- unclamped_dot = (@x * vector.at(0)) + (@y * vector.at(1))
291
- max(min(unclamped_dot, MAX_DOT_PRODUCT), MIN_DOT_PRODUCT)
290
+ (@x * vector.at(0)) + (@y * vector.at(1))
292
291
  end
293
292
 
294
293
 
@@ -324,17 +323,18 @@ class Vector2
324
323
  self.class.new( -@y, @x )
325
324
  end
326
325
 
327
-
328
326
  # Sets this vector to the vector projection (aka vector resolute)
329
327
  # of this vector onto the other vector. See also #projected_onto.
330
328
  #
331
329
  def project_onto!( vector )
332
330
  raise "can't modify frozen object" if frozen?
333
- @x, @y = *(vector * vector.dot(self) * (1/vector.magnitude**2))
331
+ b = vector.unit
332
+ @x, @y = *(b.scale(self.dot(b)))
334
333
  @hash = nil
335
334
  self
336
335
  end
337
336
 
337
+
338
338
  # Like #project_onto!, but returns a new vector.
339
339
  def projected_onto( vector )
340
340
  dup.project_onto!( vector )
@@ -2,7 +2,7 @@ module Gamebox
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- TINY = 2
5
+ TINY = 4
6
6
  RC = 0
7
7
 
8
8
  if RC > 0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shawn Anderson
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-01-06 00:00:00.000000000 Z
13
+ date: 2015-01-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: gosu
@@ -563,3 +563,4 @@ test_files:
563
563
  - spec/lib/class_finder_spec.rb
564
564
  - spec/lib/rect_spec.rb
565
565
  - spec/views/graphical_actor_view_spec.rb
566
+ has_rdoc: