title: How to avoid if / else if chain when classifying a heading into 8 directions?
body: <p>I have the following code:</p>
  
  <pre><code>if (this-&gt;_car.getAbsoluteAngle() &lt;= 30 || this-&gt;_car.getAbsoluteAngle() &gt;= 330)
    this-&gt;_car.edir = Car::EDirection::RIGHT;
  else if (this-&gt;_car.getAbsoluteAngle() &gt; 30 &amp;&amp; this-&gt;_car.getAbsoluteAngle() &lt;= 60)
    this-&gt;_car.edir = Car::EDirection::UP_RIGHT;
  else if (this-&gt;_car.getAbsoluteAngle() &gt; 60 &amp;&amp; this-&gt;_car.getAbsoluteAngle() &lt;= 120)
    this-&gt;_car.edir = Car::EDirection::UP;
  else if (this-&gt;_car.getAbsoluteAngle() &gt; 120 &amp;&amp; this-&gt;_car.getAbsoluteAngle() &lt;= 150)
    this-&gt;_car.edir = Car::EDirection::UP_LEFT;
  else if (this-&gt;_car.getAbsoluteAngle() &gt; 150 &amp;&amp; this-&gt;_car.getAbsoluteAngle() &lt;= 210)
    this-&gt;_car.edir = Car::EDirection::LEFT;
  else if (this-&gt;_car.getAbsoluteAngle() &gt; 210 &amp;&amp; this-&gt;_car.getAbsoluteAngle() &lt;= 240)
    this-&gt;_car.edir = Car::EDirection::DOWN_LEFT;
  else if (this-&gt;_car.getAbsoluteAngle() &gt; 240 &amp;&amp; this-&gt;_car.getAbsoluteAngle() &lt;= 300)
    this-&gt;_car.edir = Car::EDirection::DOWN;
  else if (this-&gt;_car.getAbsoluteAngle() &gt; 300 &amp;&amp; this-&gt;_car.getAbsoluteAngle() &lt;= 330)
    this-&gt;_car.edir = Car::EDirection::DOWN_RIGHT;
  </code></pre>
  
  <p>I want to avoid the <code>if</code>s chain; it's really ugly. Is there a another, possibly cleaner, way of writing this?</p>