Complex motion formulas?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
raidho36
Party member
Posts: 1954
Joined: Mon Jun 17, 2013 12:00 pm

Complex motion formulas?

Post by raidho36 » Sat Jul 27, 2013 10:48 am

Just wonder, how often do you use, if ever, complex motion formulas (besides box2d)? Like former vs. latter?

Code: Select all

x = x + dx * dt + 0.5 * a * dt ^ 2
dx = dx + a * dt

dx = dx + a * dt
x = x + dx * dt
I suppose latter is good enough for most cases and variety of dt doesn't cause any trouble as well although it's not entirely precise and could act funny if dt goes nuts.

User avatar
Omnivore
Prole
Posts: 18
Joined: Fri Jun 28, 2013 12:51 am
Location: West Coast

Re: Complex motion formulas?

Post by Omnivore » Sat Jul 27, 2013 11:00 am

raidho36 wrote:Just wonder, how often do you use, if ever, complex motion formulas (besides box2d)? Like former vs. latter?
One area I found the various popular physics engines lacking in was newtonian (or quasi-newtonian) movement in space. Oh I'm sure they could be used but I found it easier to write my own motion formulas so I could ignore some things like planetary gravity and angular momentum, while concentrating on the acceleration/time/position problems.

In doing so, to avoid whacky dt problems, I simply defined a dt interval I used as my 'physics engine' step constant. I tracked the error of actual dt vs step-wise dt and inserted extra steps or skipped steps as appropriate depending on the circumstances. I found it useful to ignore excessive dt error and clamp it to one extra step insertion at most.
Lua lou aye, ah no its, lua louie

User avatar
Roland_Yonaba
Inner party member
Posts: 1562
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Complex motion formulas?

Post by Roland_Yonaba » Sat Jul 27, 2013 5:43 pm

The second method (Euler integration) is faster, simple and works for most cases.
When you really need accurate moves, and when you want to have framerate independant motion, you will have to start dealing with delta times. ANd that's how you will look into some more accurate time integration methods (Verlet, RK4, etc...).
By the way, you might find some interest in this little experiment of mine on the subject.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests