Jump to content
  • Advertisement
Sign in to follow this  
PrestoChung

How is Euler integration for rigid body simulation?

This topic is 3088 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

I understand that Euler integration can be unstable for spring type oscillators, such as in a cloth simulation but is it okay for simple parabolic movement/elastic collision of rigid bodies?

I'm not aiming for numerical accuracy, just to be believable in appearance behavior and intuition to increase the number of objects able to be simulated in real time.

Is it good enough for this or do I need to implement RK4?

Thanks

Share this post


Link to post
Share on other sites
Advertisement
Erm, well I don't have any physics at the moment. I want to give physics meaning for my player class to start off with which looks like


class Player
{
public:

unsigned int sector_x, sector_z;

float myX, myY, myZ; //position
float myLX, myLY, myLZ; //look at

bool mydirX, mydirY, mydirZ; //movement toggles

float mySpd;

float myTheta, myPhi; //pitch, yaw

Player();

// void interpY(Distant& theDistant, World& theWorld);
int inSector(World& theWorld);
void moveMe(Distant& theDistant, World& theWorld);
};



My first question is there a difference between

class Vectorf
{
public:
float vector[3];
};


and


class Vectorf
{
public:
float x;
float y;
float z;
};


?

Share this post


Link to post
Share on other sites
Quote:
Original post by PrestoChung
I understand that Euler integration can be unstable for spring type oscillators, such as in a cloth simulation but is it okay for simple parabolic movement/elastic collision of rigid bodies?
For ballistic trajectories (parabolic motion) it's fine, and by adding (1/2)aΔt2 to the position you can get exact results. In the case of collisions, it depends on how you're handling them; penalty-force-based collisions will have the same energy problems as spring-based cloth.

Share this post


Link to post
Share on other sites
Doesn't really affect them, but can cause problems depending on how you're doing contact resolution.

Share this post


Link to post
Share on other sites

Using arrays incur additional overheads vs using standard floats.

Also you will have to refer to them as variable.vector[1] vs variable.x.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kalten
Using arrays incur additional overheads vs using standard floats.
Say what? How so, in this, situation?

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
Quote:
Original post by Kalten
Using arrays incur additional overheads vs using standard floats.
Say what? How so in this situation?


In this case probably not so much so...

From my experience however, and this may only be me, my code has been as much as 2% slower using a large number of arrays for information that is being stored in the exact same way as indicated previously. This was profiling the use of for loops to translate data from one array to another, as well as hard coding array references for output, vs simply referring to variable. For loops were slower on average, with hard coded references to both array and variable being pretty much the same.

I'd argue, that if you are planning on using a struct for the storage of a math vector of x,y,z using an array[3] within a struct is counter productive, because what you will effectively be doing is structure.array.x/y/z vs structure.x/y/z

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!