Advertisement

The main idea of suspesion

Started by August 07, 2002 12:42 PM
8 comments, last by aash29 22 years, 6 months ago
Also wanted to discuss the main idea of suspension: I stored an array of vertices and checked them for collisions. Whenever I had one, I changed the velocity of the point of a spring which collided. To keep vertices where they had to stay, I used only that part of their velocity that was along the line of spring to change their position. \ /s2 V1-- \ / -------S \ / s1 Here S:=(s2-s1) is a spring vector; to get part of velocity that acts along it I: Nomalize(S); - normalize spring vector to get direction n:=(S)*V1; - dot product newVelocity:=S*n;- here we are; Is that right? They still get out of control sometimes and start bouncing around
aash29,

Could you please correct your figure? It doesn''t display correctly, so I don''t fully understand what you are describing. You can wrap the figure with "" and "" to maintain spacing. (Remove the space between "[" and "c".)

As for the out-of-control instability, that is possibly related to the method of integration you are using. Some integration methods, including the simple Euler method that most people use when first implementing a physics engine, simply cannot handle springs at all. If you''re using the simple Euler method (which is like a simple forward difference in time), you will need to either add damping to your springs or (better choice) using something other than Euler, such as Runge Kutta or a Verlet integrator.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Advertisement
   \    /s2V1--\  / -------S     \/     s1 

S:=(s2-s1) is a spring vector
V1- velocity vector
Thanx for answering. Yes,I''m using Euler method but I''m dealing with constants only, no air drag ,nothing like that, so new integrator won''t help much I think. Instability is a minor problem, the real one is, I''m not sure if I''m doing the right thing at all.
I want to simulate a car with suspension,
I''ve got an array of points, some of them are bound to the car, some aren''t. They''re connected with springs.
   ___________  ¦           ¦   v--------v-----"car"   ¦        ¦   ¦        ¦-----suspesion   v        v 

"v"''s are verticles in the array

At each moment I can calculate force acting along the spring, and with force value, I can calculate new acceleration,velocity and position of the verticle. If the verticle''s fixed, I can apply force to a "car" instead.

If I have a collison with the ground, I alter the velocity of the verticle, but to get new position I use only part of it which acts along the spting (see my previous post).

As the vehicle can rotate, to keep the springs where they should be I do the following: I take curent length of the spring("Length")

vPos is the initial position of a fixed verticle (with no rotation):
 vPos(x,y,z)      ¦      ¦      ¦ vPos2(x,y,z-"Length") 


And then I rotate this vector by the same angles the "car" is rotated to get new positiong of the spring.

Is the main idea right? I''ve digged through the net trying to find any articles about simulating car suspension, and, though it''s done in hundreds of games , not a word.


Search for ''spring damping''.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
A random comment: In some programs I''ve made, I calculate a sine table by using simple Euler integration to simulate an oscillating spring, and the values are perfect. Maybe it''s fine because I only simulate for a very short amount of time, but it does work.
thanks for the links, but I''ve searched through, and scored 0 points on most of them..There are some articles on gamasutra, but they''re about springs in general and cloth simulation
Advertisement
Your calculations seemed to be quite ok. If your springs start bouncing, then add that damping factor to them (so that they lose energy all the time). Also make sure that the applied velocities are not too strong.
What about damping constants? I''m currently using expression Fd=Kd(v1-v2) with Kd=15
Also, I'm not sure if you need to link your springs to certain vertexes.. If that is easier/faster then sure, but otherwise it might not be necessary..

Are v1 and v2 velocity vectors? what are they for?

You can also contact me through ICQ if you want.. My # is 60259177.

[edited by - dr_w0rd on August 12, 2002 3:07:36 PM]
v1 and v2 are velocities of points connected with spring
        

faster they go, more ''friction'' they receive.
Any other ways to add damping?

thnx for the number

This topic is closed to new replies.

Advertisement