title: I have a brain freeze, help me make this method efficient :>
body: <p>I have the following code, and I can see that there is a connection between the values. I can however not get my head together and figure out how to remove the switch statements with some add subtract modelo haxx. Would really appriciate some help to get this method smoother.</p>
  
  <p>The heading variable is either 0, 1, 2 or 3.</p>
  
  <pre><code>public static int getRotation(Point currentPoint, Point nextPoint, int heading) {
      int rotation = -1;
      if(currentPoint.getX() &lt; nextPoint.getX()) /* DRIVE WEST */  {
          switch(heading) {
              case 0: rotation = 1; break;
              case 1: rotation = 0; break;
              case 2: rotation = 3; break;
              case 3: rotation = 2; break;
          }
      } else if(currentPoint.getX() &gt; nextPoint.getX()) /* DRIVE EAST */ {
          switch(heading) {
              case 0: rotation = 3; break;
              case 1: rotation = 2; break;
              case 2: rotation = 1; break;
              case 3: rotation = 0; break;
          }
      } else if(currentPoint.getY() &lt; nextPoint.getY()) /* DRIVE  NORTH */ {
          switch(heading) {
              case 0: rotation = 0; break;
              case 1: rotation = 3; break;
              case 2: rotation = 2; break;
              case 3: rotation = 1; break;
          }
      }  else if(currentPoint.getY() &gt; nextPoint.getY()) /* DRIVE SOUTH */ {
          switch(heading) {
              case 0: rotation = 2; break;
              case 1: rotation = 1; break;
              case 2: rotation = 0; break;
              case 3: rotation = 3; break;
          }
      }
  
      return rotation;
  }
  </code></pre>
  
  <p>EDIT: I did forget to mention that nextPoint can only be +-x or y compared to currentPoint. if currentPoint is (0,0) newPoint must be either (-1,0), (1,0), (0,-1) or (0,1).</p>