Created
December 2, 2014 21:19
-
-
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}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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