My equations work by rotating some stuff, then splitting that stuff into triangles and calculating some stuff of each triangle. However, my MATLAB implementation splits it up into triangles before rotating (due to the way a particular function in MATLAB works). What this means, is that for an n-sided polygon, the MATLAB code is calculating 3n-6 triangles, where my equations only require n triangles. For example, a hexagon will take 12 triangles in the code, but only needs 6. What that means is that the code is running many many more calculations than it needs to. It’s still correct, it’s just doing it inefficiently.
I’ve been considering this problem for a while now, and yesterday I started trying to solve it. Like I mentioned above, it’s still correct, but it’s slower than it needs to be. One of the motivations for coming up with these equations is that they are much faster than using computer simulations, so we want these equations to be implemented efficiently to increase that advantage.
It turns out that this problem is much more difficult to solve than I anticipated. It’s making me think and try various methods – and I’m loving it! This is the sort of stuff I love doing: problem solving. Working out ways to make stuff better.
Right now my code is calculating what I want in the order of ~30-50 milliseconds, but I think it could be reduced to 20-30 milliseconds with some tweaking. Hopefully I’ll be able to work this thing out!