PageRenderTime 61ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/include/Attraction.h

https://github.com/bloomtime/CinderTraer
C Header | 51 lines | 29 code | 20 blank | 2 comment | 0 complexity | c7f3d798f48db8505a3422531f969c0c MD5 | raw file
  1. // attract positive repel negative
  2. #pragma once
  3. #include "Force.h"
  4. #include "Particle.h"
  5. namespace traer { namespace physics {
  6. class Attraction : public Force
  7. {
  8. public:
  9. Particle* a;
  10. Particle* b;
  11. float k;
  12. bool on;
  13. float distanceMin;
  14. float distanceMinSquared;
  15. Attraction( Particle* a, Particle* b, float k, float distanceMin );
  16. float getMinimumDistance();
  17. void setMinimumDistance( float d );
  18. void turnOff();
  19. void turnOn();
  20. void setStrength( float k );
  21. Particle* getOneEnd();
  22. Particle* getTheOtherEnd();
  23. void apply();
  24. float getStrength();
  25. bool isOn() const;
  26. bool isOff() const;
  27. private:
  28. // http://en.wikipedia.org/wiki/Fast_inverse_square_root
  29. float Q_rsqrt( float number );
  30. };
  31. } } // namespace traer::physics