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.
General question about implementing calculus
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. )
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!
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. )
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!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement