Poll: lua is
You do not have permission to vote in this poll.
yes
50.00%
3 50.00%
no
50.00%
3 50.00%
Total 6 vote(s) 100%
* You voted for this item. [Show Results]

Using Lua to create games in PR3R
#8
(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.

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 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.
i failed the mario twitter challenge
Reply


Messages In This Thread
Using Lua to create games in PR3R - by ThePizzaEater1000 - 22nd September 2020, 8:26 PM
RE: Using Lua to create games in PR3R - by Camer the Dragon - 23rd September 2020, 4:22 PM
RE: Using Lua to create games in PR3R - by ThePizzaEater1000 - 23rd September 2020, 10:03 PM
RE: Using Lua to create games in PR3R - by Mia - 23rd September 2020, 11:15 PM
RE: Using Lua to create games in PR3R - by Northadox - 24th September 2020, 10:12 AM
RE: Using Lua to create games in PR3R - by ThePizzaEater1000 - 26th September 2020, 2:46 PM
RE: Using Lua to create games in PR3R - by Camer the Dragon - 30th October 2020, 11:20 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)