phantasm
phantasm

Reputation: 572

Sum of two angles

  1. We have an angle in radians, from -PI to +PI
  2. We have an offset (0.2rad for instance)

How can I add this offset to an angle and get a resulting value which should also be from -PI to PI ? Feeling a lil' stupid...

Upvotes: 0

Views: 2031

Answers (1)

Daniel
Daniel

Reputation: 42748

Just use %:

angle = (angle + 0.2 + pi) % (2*pi) - pi

Upvotes: 1

Related Questions