Jump to content
  • Advertisement
Sign in to follow this  
Orsquall

General question about implementing calculus

This topic is 2478 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I'm currently taking a calculus / mechanics courses, and I've started thinking about how one would go and implement stuff like forces and kinematics when writing a physics engine.
My question is a bit abstract and is leaned more towards the math side of things.

My first thought was that each math expression is probably stored as an expression tree, on which you can run more complex calculations like derviations, integrations, limit calculation etc.
But on a second thought, why would you ever want to do that?
All the formulas should be known at compilation time (e.g. velocity and acceleration can be calculated manually by the programmer and added as a formula, or simply "accumulate" for every "time" iteration. Same goes for mass changing bodies or energy calculations (i.e. gravity being a gradiant of energy).

So are there any practical uses for storing expression trees and running derviations / intergrations etc?
Or all calculations are usually done by hand?
If the answer is negative, I'd like to extend my question to other topics as well, such as shaders or AI.

Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Hi!

Usually you don’t want to do symbolic differentiation / simplification or whatever at runtime. The formulas should be known by then.
So, instead you just pick up your favorite computer algebra system (maxima, maple …) enter your expression or energy functional you want to minimize / differentiate / simplify etc and then let it produce you the final formulas, which you simply plug in into your update schemes. (No one has to do such things by hand. smile.png)

Well, at times you want to specify formulas on the UI (not in games, at least I know none, but perhaps in an editor e.g. to specify the update scheme of a particle system). Therefore there are libraries that can do symbolic evaluation, like ROOT or some software even uses Matlab.
Speeking of which. If you have to solve linear systems (e.g. for minimizations) I would recommend using software like BLAS or LAPACK (which is internally used by MatLab). The code itself is rock solid and it is optimized for many architectures, including graphics hardware (CUDABlas).

Cheers!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!