Skip to content

Instantly share code, notes, and snippets.

@Pyromuffin
Created July 10, 2018 07:55
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/e934b7188f82c5466f14f686b6a22054 to your computer and use it in GitHub Desktop.
Save Pyromuffin/e934b7188f82c5466f14f686b6a22054 to your computer and use it in GitHub Desktop.
Matrix4x4 mat;
mat = Matrix4x4.Translate(new Vector3(centerPoint.x, centerPoint.y));
mat *= Matrix4x4.Rotate(Quaternion.AngleAxis(degrees, Vector3.forward));
mat *= Matrix4x4.Translate(new Vector3(-centerPoint.x, -centerPoint.y));
IntegerBasis basis;
basis.right = new Vector2Int( Mathf.RoundToInt(mat.m00 * BIG_NUMBER), Mathf.RoundToInt(mat.m01 * BIG_NUMBER));
basis.up = new Vector2Int( Mathf.RoundToInt(mat.m10 * BIG_NUMBER), Mathf.RoundToInt(mat.m11 * BIG_NUMBER));
basis.offset = new Vector2Int( Mathf.RoundToInt(mat.m03 * BIG_NUMBER), Mathf.RoundToInt(mat.m13 * BIG_NUMBER));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment