/Hammy/src/dynamics/Derivative.as

https://bitbucket.org/peterm/hammy-as3 · ActionScript · 32 lines · 22 code · 6 blank · 4 comment · 0 complexity · 85cecbc34ef8ec9baef00e17981a5221 MD5 · raw file

  1. package dynamics
  2. {
  3. import math.Vec2;
  4. /**
  5. * ...
  6. * @author Peter Mackay
  7. */
  8. internal final class Derivative
  9. {
  10. internal var velocity:Vec2;
  11. internal var acceleration:Vec2;
  12. public function Derivative(velocity:Vec2, acceleration:Vec2)
  13. {
  14. this.velocity = velocity;
  15. this.acceleration = acceleration;
  16. }
  17. public function add(other:Derivative):Derivative
  18. {
  19. return new Derivative(velocity.add(other.velocity), acceleration.add(other.acceleration));
  20. }
  21. public function mul(dt:Number):Derivative
  22. {
  23. return new Derivative(velocity.mul(dt), acceleration.mul(dt));
  24. }
  25. }
  26. }