{"id":17679333,"url":"https://github.com/bbkane/cross_tile","last_synced_at":"2025-03-30T18:28:06.377Z","repository":{"id":87170771,"uuid":"98775084","full_name":"bbkane/cross_tile","owner":"bbkane","description":"Fun with tile shapes and JavaScript","archived":false,"fork":false,"pushed_at":"2017-08-01T04:36:42.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T19:49:32.647Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bbkane.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-30T04:31:54.000Z","updated_at":"2017-09-01T17:51:55.000Z","dependencies_parsed_at":"2023-03-13T19:44:50.394Z","dependency_job_id":null,"html_url":"https://github.com/bbkane/cross_tile","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbkane%2Fcross_tile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbkane%2Fcross_tile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbkane%2Fcross_tile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbkane%2Fcross_tile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bbkane","download_url":"https://codeload.github.com/bbkane/cross_tile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246361251,"owners_count":20764896,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-24T08:22:07.559Z","updated_at":"2025-03-30T18:28:06.350Z","avatar_url":"https://github.com/bbkane.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tiling Crosses\n\nI was doodling with crosses on graph paper and was surpised to see that I could cover the graph paper with only cross shapes. They also look pretty neat when colored oddly, so I wrote this code to play with them more efficiently.\n\n## The logic behind `transform_point`:\n\nI wanted to note how I came up with the formula for `transform_point`. I need to talk to my old Linear Algebra professor to get his perspective on how I might have been able to solve this more efficiently somehow.\n\nThe goal is to map a point in `p` (a square field of points (really also squares))\nto the center of a cross in `c` (a square field of crosses turned caddy-corner).\n\nGraph paper and square counting led to the following table (where x is the row, y is the column and indices start at 1):\n\n\n| side length of `p` (called `n`) | 1 | 2 | 3 | 4  |\n|--------------------|---|---|---|----|\n| side length of `c` | 3 | 6 | 9 | 12 |\n| x_0 in `c`         | 2 | 3 | 4 | 5  |\n| y_0 in `c`         | 2 | 2 | 2 | 2  |\n\n\nThose are some very easily predicted patterns and we can get the following information from them:\n\n- the origin in `p` : `(1, 1)` is mapped onto `(n + 1, 2)` in `c`\n- the number of tiles required to map a `p` of size `n` to `c` is `n * 3`\n\nBy inspecting the graph, we can also see the following shifts:\n\n- `(x + 1, y)` corresponds to `(x + 2, y + 1)`. When you shift a square to the right in `p`, the corresponding center square in `c` is shifted to the right 2 and down 1 (In graphics, the vertival axis typically goes from top to bottom).\n- `(x, y + 1)` corresponds to `(x - 1, y + 2)`. Similar explanation to the above.\n\nNow a formula can start to be derived. We can scale the shifts in `x` and `y` by multiplying by a constant and to make it a real formula instead of just a correlation we simply add the offset from the orgin:\n\n`(x + dx, y + dy) -\u003e (n + 1, 2) + dx(x + 2, y + 1) + dy(x -1, y + 2)`\n\nIf we simply set `x` and `y` to `0`, we end up with a formula for coordinates from the origin:\n\n`(dx, dy) -\u003e (n + 1, 2) + dx(2, 1) + dy(-1, 2)`\n\nFinally, though I've been using indices starting at one, in programming we usually start indices at zero. It's a simple matter to subtract one from the origin part of the formula. In this final form, I'm also renaming `dx` to `x` and `dy` to `y` because at this point they're offsets from the origin just like any other points.\n\n\n`(x, y) -\u003e (n, 1) + x(2, 1) + y(-1, 2)`\n\n\n### Generalization\n\nI'm pretty sure this generalizes to vector spaces of any dimensionality. To get from space `A` to space `B`, add the origin in `B` to a constant times a whatever the unit vector in `A` maps to in `B` for each unit vector in A.\n\n## TypeScript\n\nThis is also the first time I've really used TypeScript. By opening the directory in VSCode and Running the build task once, I get compilation on save! NOTE: I'm putting all js/ts files in the ts/ folder. The js/ folder is a build artifact of the ts/ folder and I'm having git ignore it!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbkane%2Fcross_tile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbkane%2Fcross_tile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbkane%2Fcross_tile/lists"}