Public Group

# 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.

## 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 on other sites
Could you show us the equations you are trying to evaluate please?

##### Share on other sites
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 on other sites
Quote:
 Original post by PrestoChungI 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 on other sites
Thanks. How about impulse based collision models?

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

##### Share on other sites

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

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

##### Share on other sites
Quote:
Original post by Sneftel
Quote:
 Original post by KaltenUsing 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

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633768
• Total Posts
3013747
×