Skip to content

Instantly share code, notes, and snippets.

@jwvg0425
Last active April 15, 2016 08:01
Show Gist options
  • Save jwvg0425/1fed9754c7a70b91167c6ea3abfcdb54 to your computer and use it in GitHub Desktop.
Save jwvg0425/1fed9754c7a70b91167c6ea3abfcdb54 to your computer and use it in GitHub Desktop.
8dir
#include <iostream>
using namespace std;
inline int deltaTable(int idx) { return (idx-4)%4 * (abs(i-4)-4) / 3; }
int main()
{
for(int i =0; i < 8; i++)
{
int x = deltaTable(i);
int y = deltaTable((i+6)%8);
cout << "(" << x << "," << y << ")" << endl;
}
/* output
(0,-1)
(1,-1)
(1,0)
(1,1)
(0,1)
(-1,1)
(-1,0)
(-1,-1)
*/
//straight -> cross
for(int i =0; i < 8; i++)
{
int idx = (i*2-1) % 7 + 1;
int x = deltaTable(idx);
int y = deltaTable((idx+6)%8);
cout << "(" << x << "," << y << ")" << endl;
}
/* output
(0,-1)
(1,0)
(0,1)
(-1,0)
(1,-1)
(1,1)
(-1,1)
(-1,-1)
*/
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment