Skip to content

Instantly share code, notes, and snippets.

@nicloay
Created December 2, 2014 21:19
Show Gist options
  • Select an option

  • Save nicloay/4d0d45a09229b36745bc to your computer and use it in GitHub Desktop.

Select an option

Save nicloay/4d0d45a09229b36745bc to your computer and use it in GitHub Desktop.
Rotate elements in 2d array around pivot point (in my case i hardcoded pivot at {2:2} position}
static int cos90 = 0;
static int sin90 = 1;
void RotateAroundCenter(ref int x, ref int y){
int xNew, yNew;
x -= 2; //piwot point x = 2
y -= 2; //piwot point y = 2;
xNew = x * cos90 - y * sin90;
yNew = x * sin90 + y * cos90;
x = xNew + 2;
y = yNew + 2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment