code: private static final Direction drawOrthogonalLineSegment(final NFastDoubleArrayJSO buffer, final Direction direction, Direction nextDirection, final double p1x, final double p1y, final double p2x, final double p2y, final double p3x, final double p3y, final boolean write)
      {
          if (nextDirection == null)
          {
              nextDirection = getNextDirection(direction, p1x, p1y, p2x, p2y);
          }
          if ((nextDirection == SOUTH) || (nextDirection == NORTH))
          {
              if (p1x == p2x)
              {
                  // points are already on a straight line, so don't try and apply an orthogonal line
                  addPoint(buffer, p2x, p2y, write);
              }
              else
              {
                  addPoint(buffer, p1x, p2y, p2x, p2y, write);
              }
              if (p1x < p2x)
              {
                  return EAST;
              }
              else if (p1x > p2x)
              {
                  return WEST;
              }
              else
              {
                  return nextDirection;
              }
          }
          else
          {
              if (p1y != p2y)
              {
                  addPoint(buffer, p2x, p1y, p2x, p2y, write);
              }
              else
              {
                  // points are already on a straight line, so don't try and apply an orthogonal line
                  addPoint(buffer, p2x, p2y, write);
              }
              if (p1y > p2y)
              {
                  return NORTH;
              }
              else if (p1y < p2y)
              {
                  return SOUTH;
              }
              else
              {
                  return nextDirection;
              }
          }
      }
docs: Draws an orthogonal line between two points, it uses the previous direction to determine the new direction. It
  will always attempt to continue the line in the same direction if it can do so, without requiring a corner.
  If the line goes back on itself, it'll go 50% of the way  and then go perpendicular, so that it no longer goes back on itself.