Advertisement
Frank84

Angle Between

Jan 26th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. // If the player is within the circle and their bounding box's center is
  2. // within 45 * 0.6 degrees from the line down the center of the opening,
  3. // then they are safe.
  4. const float InitialWheelRotation = 90.0f;
  5. float wheelAngleDegrees = m_wheelEntity->getRotation() - InitialWheelRotation;
  6. if (wheelAngleDegrees < -180.0f) wheelAngleDegrees += 360.0f;
  7. float playerAngleDegrees = atan2(playerCenter.y - wheelCenter.y, playerCenter.x - wheelCenter.x) * 180.0f / AGLIB_PI - 90;
  8.  
  9. if (abs(wheelAngleDegrees - playerAngleDegrees) < 45.0f * 0.6f)
  10. {
  11.     // Safe in the gap!
  12.     return false;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement