Skip to content

Instantly share code, notes, and snippets.

@Pyromuffin
Last active July 10, 2018 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pyromuffin/03da4469a607ea35fdf37a1a7af93bb3 to your computer and use it in GitHub Desktop.
Save Pyromuffin/03da4469a607ea35fdf37a1a7af93bb3 to your computer and use it in GitHub Desktop.
uint2 IntegerRotate(int2 right, int2 up, int2 offset, uint2 pos)
{
static const int BIG_NUMBER_EXPONENT = 20;
uint2 rotatedPos;
rotatedPos.x = pos.x * right.x + pos.y * right.y;
rotatedPos.y = pos.x * up.x + pos.y * up.y;
rotatedPos += offset;
rotatedPos = rotatedPos >> BIG_NUMBER_EXPONENT;
return rotatedPos;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment