Skip to main content
gamedev.net
🔒 Locked

implementing semi implicit euler

Started by daniel_i_l 2 replies 2.1k views
Original Post
daniel_i_l
daniel_i_l
I'm currently trying to write a general integrator. Most of the material on the web recommends making the integrate function receive a vector of doubles as the state and a function pointer to a "getDerivative" function which the integrator can use to figure out the derivative at some future point in time. This is needed for RK4 for example. So the integrate function looks like: integrate(double[] initial, double[] final, time t0, time t1, getDerivative) where initial and final are vectors constructed from all the state information (positions, velocities, rotations,...) But I don't understand how this information can be used to implement a semi implicit euler integrator. For the SIEI to work it has to first integrate the velocities and then use those to get the new positions. But if the input is just an array of doubles how does it know which part of the input is the velocity and which is the position? Thanks.
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
daniel_i_l
daniel_i_l
Does anyone have any ideas?
Does anyone have any information in general about the implementation of a general integrator?
Thanks
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
h4tt3n
h4tt3n
Quote:
Original post by daniel_i_l
... if the input is just an array of doubles how does it know which part of the input is the velocity and which is the position?
Thanks.


Hi Daniel,

Rather than simply feeding the integration function with an array, I'd give it a predefined struct with clearly defined position, velocity, and force vectors, like this particle struct I use for various different simulation purposes.

//  point mass structurestruct PointMass{	float mass;               //  mass	float radius;             //  radius	vec2f frc;                //  force vector	vec2f acc;                //  accelleration vector	vec2f vel;                //  velocity vector	vec2f psn;                //  position vector};


Although I'm not using the integration method you request, you may find it useful to look at this example (c++ source code + exe).

http://www.jernmager.dk/stuff/cpp/softbody_glfw.zip

Don't know if I can be of more help...

Cheers & gl,
Mike

daniel_i_l
daniel_i_l
Thanks for the help, I'll try what you suggested.
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.