?>


A math puzzle with real-world application
Posted: Posted October 4th
Edited October 4th by Xhin
View Source Report Thread Views

I recently used the things I learned from Polar Coordinates to build a different graphics plugin I've wanted to build for a very long time, which can basically do things like this:







This was by far the most complicated plugin I've made to date. The planning alone took three full drafts before I knew what I was doing.

While planning it out though, I noticed that there were a LOT of potential solutions. I ended up using three very different ones before finding a good method that combined the best parts of each. While my current algorithm has some elegance to it compared to my other ideas, there's probably room for improvement, and I'm just overall very curious what you guys will come up with -- those of you with strong math backgrounds, or strong IT backgrounds, will probably come up with very different answers.

In any case, let's look at the actual problem.

The Problem

The goal is, given some image, to take an arbitrary triangle of it and then tile it around the whole image in a hexagonal lattice-like way.



For example, with the image seen here, you can take this triangle



And tile it like this.

This is a particularly easy case because the hexagon's top and bottom sides are the image's top and bottom.



However, it gets a lot more complicated when you want to make something like this.



You could also think of this problem as tiling a hexagon made from that triangle around the image -- in that particular case you don't have to rotate the hexagon or anything because of how the triangle placement works. It's the same hexagon repeated over and over.

The setup

The variables that you're given are the centerpoint and the triangle radius. You also know the image's width and height.



The centerpoint is the centerpoint of the hexagon that gets repeated around the image. For now, let's say the centerpoint is the exact middle of the image both horizontally and vertically.

The radius, meanwhile, is the length of any triangle or hexagon side. Usefully this means it's the length of every line in the lattice, so this speeds up the math a lot.

As for which triangle to use, well build your hexagon grid however you want and pick one! Switching to different triangles (or rotations around the centerpoint) was definitely the easiest part of making my plugin, so don't worry about that kind of thing.

What I'm expecting for a solution

I'm definitely not expecting you to create a program to do this. You also don't necessarily have to figure out how to fit your model into a programmable algorithm. Instead I mostly just want to see your ideas for coming up with a solution. Having a complete model that works both as math and as an algorithm for each individual pixel is great, but it took me three tries to come up with one of those, and it ended up still requiring 5-6 steps, plus a lot of math and trigonometry.

Instead, having some ideas with some math (and ideally pictures) behind them is really all I'm looking for here with this challenge. But the more you can come up with, the better! I personally had a lot of fun designing my solution and I learned a lot along the way. I'll share it down below once some other posts have been made.

There are 3 Replies

So your question is, given this:



how do you create this?:



Posted October 6th by EN
View Source Quote Report
EN

Something like that yeah.

That doesn't appear to be the correct piece because when I latticed it, I got this:



But yeah, that's the basic idea -- take a triangle and copy it around the image in a lattice-like way

Posted October 7th by Xhin
View Source Quote Report
Xhin
Ground's what's around

While I think about this, have you ever read about aperiodic tilings, such as Penrose's kites and darts? https://en.wikipedia.org/wiki/Penrose_tiling

Posted October 7th by EN
View Source Quote Report
EN
Reply to: A math puzzle with real-world application
Enter your message here

Rules | Report Issue | Request Feature | Roadmap Facebook Page | Discord Group
GTX0 © 2009-2019 Xhin GameTalk © 1999-2008 lives on
You are not forgotten, Kevin, Liane, Norma, Jason, and Garrett