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 +4 -4
- data/lib/gamebox/lib/vector2.rb +7 -7
- data/lib/gamebox/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3008b56dae9d3f599c6ea9cf087fab7eda3f7415
|
4
|
+
data.tar.gz: 839970de9cdc8bf84b494b9235ab00c05c1f905a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f415885718ab713f721576793cd6a40871c65ce6a2d5fbefea48aed95f1b7819de5d9667d467d36e6c5e0918ac34b29ed7bd414728b64d62e5356873cdb854d
|
7
|
+
data.tar.gz: 4016cdab6f3868066794c50aa4b52fe00df4e874ca26f816a8814a15174adce68c36cf3d80b38217e7cb837d683c9610f017e11e8c4409cbff171afa723fb96f
|
data/lib/gamebox/lib/vector2.rb
CHANGED
@@ -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
|
-
|
33
|
-
|
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
|
-
|
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
|
-
|
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 )
|
data/lib/gamebox/version.rb
CHANGED
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.
|
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-
|
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:
|