# implementing semi implicit euler

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

## Recommended Posts

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.

##### Share on other sites
Does anyone have any ideas?
Does anyone have any information in general about the implementation of a general integrator?
Thanks

##### Share on other sites
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

##### Share on other sites
Thanks for the help, I'll try what you suggested.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633703
• Total Posts
3013455
×