steering_behaviors 1.0.1 → 1.0.2

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.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog for steering-behaviors
2
2
 
3
+ ## 1.0.2, 31 July 2013
4
+ * Bugfixes in ortho/bside; cleanup of align/match
5
+
3
6
  ## 1.0.1, 31 July 2013
4
7
  * Some mild optimizations in Vector (caching, Pi calcs)
5
8
 
@@ -17,10 +17,9 @@ class SteeringBehaviors::Align
17
17
  # -
18
18
  #
19
19
  def self.steer(hunter_kinematic, quarry_kinematic)
20
- course_diff = ( ( quarry_kinematic.heading_vec.radians - hunter_kinematic.heading_vec.radians + 3*Math::PI ) % (2*Math::PI) ) - Math::PI
20
+ desired_velocity = quarry_kinematic.heading_vec * hunter_kinematic.velocity_vec.length
21
21
 
22
- target_local = SteeringBehaviors::Vector.new(course_diff * hunter_kinematic.speed, 0)
23
- target_local.rotate!(hunter_kinematic.heading_vec.radians)
22
+ return desired_velocity - hunter_kinematic.velocity_vec
24
23
  end
25
24
 
26
25
  end
@@ -27,7 +27,9 @@ class SteeringBehaviors::Broadside
27
27
 
28
28
  best_hdg_vec = (da < db ? option_a : option_b)
29
29
 
30
- desired_velocity = best_hdg_vec * hunter_kinematic.velocity_vec.length
30
+ desired_velocity = best_hdg_vec.normalize * hunter_kinematic.velocity_vec.length
31
+
32
+ return desired_velocity - hunter_kinematic.velocity_vec
31
33
  end
32
34
 
33
35
  end
@@ -17,12 +17,9 @@ class SteeringBehaviors::Match
17
17
  # - the steering force
18
18
  #
19
19
  def self.steer(hunter_kinematic, quarry_kinematic)
20
- course_diff = ( ( quarry_kinematic.heading_vec.radians - hunter_kinematic.heading_vec.radians + 3*Math::PI ) % (2*Math::PI) ) - Math::PI
20
+ desired_velocity = quarry_kinematic.heading_vec * quarry_kinematic.velocity_vec.length
21
21
 
22
- speed_diff = quarry_kinematic.speed - hunter_kinematic.speed
23
-
24
- target_local = SteeringBehaviors::Vector.new(course_diff * quarry_kinematic.speed, speed_diff)
25
- target_local.rotate!(hunter_kinematic.heading_vec.radians)
22
+ return desired_velocity - hunter_kinematic.velocity_vec
26
23
  end
27
24
 
28
25
  end
@@ -26,6 +26,8 @@ class SteeringBehaviors::Orthogonal
26
26
  best_hdg_vec = (da < db ? option_a : option_b)
27
27
 
28
28
  desired_velocity = best_hdg_vec * hunter_kinematic.velocity_vec.length
29
+
30
+ return desired_velocity - hunter_kinematic.velocity_vec
29
31
  end
30
32
 
31
33
  end
@@ -16,9 +16,8 @@ class SteeringBehaviors::Steering
16
16
  # - +kinematic+ -> the kinematic thing
17
17
  # - +steering_force+ -> force vector supplied by a steering behavior
18
18
  # - +delta+ -> time delta (in seconds) used for scaling the result
19
- # - +accelerative+ -> whether you want the steering to change the thing's velocity (default true)
20
19
  #
21
- def self.feel_the_force(kinematic, steering_force, delta, accelerative=true) #, mobile, position)
20
+ def self.feel_the_force(kinematic, steering_force, delta)
22
21
  acceleration = steering_force / kinematic.mass
23
22
 
24
23
  # Compute the new, proposed velocity vector.
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: steering_behaviors
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.1
5
+ version: 1.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Chris Powell