11th October 2020, 3:38 PM
(10th October 2020, 9:24 PM)Delphinoid Wrote: The way you're using complex numbers right now seems totally unnecessary. The idea is fine, but you don't actually need to use a complex number library, you can stick to regular floats with just sine and cosine if you're concerned with efficiency. I can also help if you'd like more information on how to adapt matrices for rotation, I think they're pretty straightforward, and more importantly there's a lot of really nifty stuff to learn.I was actually already planning to use quaternions to allow programmers to rotate a given object on a given axis, which is enough for what we're probably able to do with this with the limited computation power. It's also pretty convenient to use quaternions, since I already have code for them in the same function block that has the code for complex numbers.
If you're interested, a division algebra also exists in R^4 in the form of quaternions, which can be applied to obtain rotations in R^3 similarly to how regular complex numbers give rise to rotations in R^2. Here's a nice article on them aimed at highschool students. I have an implementation here (quat.h, quat.c) if you want to see what they look like in practice. They do have a speed advantage over matrices, just like using complex numbers in 2D, and they're also very good at spherical linear interpolation.
After saying that, you're probably wondering why matrices are even used. Well, while they're slower than quaternions or complex numbers for individual transformations, the nice thing is that a single matrix can, effectively, store an ordered list of any number of transformations. If you store translation, orientation and scale separately, every time you write to the state, nothing is really preserved from the previous one. In many cases this is fine, but it has issues with things like 3D animation, since there ends up being no way to distinguish between certain orders of transformations that should give different results.
i failed the mario twitter challenge