title: Determine the index of a grid coordinate centered at 0,0 and increasing in a spiral around the origin
body: <p>This is a reverse question of the following:</p>
  
  <p><a href="https://stackoverflow.com/questions/11550153/determine-position-of-number-in-a-grid-of-numbers-centered-around-0-and-increasi">Determine position of number in a grid of numbers centered around 0 and increasing in spiral</a></p>
  
  <p>The two modalities are:
  index -> coordinate (done, see question above)
  coordinate -> index (my question)</p>
  
  <p>The part I'm stuck on is getting the sector from a raw coordinate without a massive ugly branch of logic. </p>
  
  <p>Is there a simple arithmetic way to determine the sector? How would you reverse this function to take a coordinate pair and return the index?</p>