b2Angle.cpp 401 B

12345678910111213141516171819202122
  1. //
  2. // Created by jovian on 31/07/17.
  3. //
  4. #include "b2Angle.h"
  5. float b2Angle(const b2Vec2 &u, const b2Vec2 &v) {
  6. float rep(std::acos(b2Dot(u, v)));
  7. if ( b2Cross(u, v) > 0.0f )
  8. rep *= -1.0f;
  9. return rep;
  10. }
  11. float b2Angle(const b2Vec2 &u) {
  12. return b2Angle(u, b2Vec2(1.0f, 0.0f));
  13. }
  14. b2Vec2 b2Dir(const float angle) {
  15. return b2Vec2((float) cos(angle), (float) sin(angle));
  16. }