next up previous
Next: Integrate Newton's Equations Up: Pressure Force Previous: Volume of The Body

Pressure Force Distribution

From an equation (2) we calculate vector components of pressure force. A $P$ scalar value is taken experimental and does not fit any real physics model. Of course there is a field for some further research to find properly values which will be relative to some real situations, but let us assume that we are interested in properly behavior of soft body, not in its physics properties.

Following part of accumulation procedure calculates value of pressure force:

for(i=1 ; i<=NUMS-1 ; i++)
{
  x1 = myRelPoints[ mySprings[i].i ].x;	
  y1 = myRelPoints[ mySprings[i].i ].y;
  x2 = myRelPoints[ mySprings[i].j ].x;
  y2 = myRelPoints[ mySprings[i].j ].y;

  // calculate sqr(distance)
  r12d = sqrt ( 
         (x1 - x2) *(x1 - x2) +  
         (y1 - y2) * (y1 - y2) );  

  pressurev = r12d * Pressure * (1.0f/volume);

  myPoints[ mySprings[i].i ].fx += 
   mySprings[ i ].nx * pressurev;

  myPoints[ mySprings[i].i ].fy += 
   mySprings[ i ].ny * pressurev;

  myPoints[ mySprings[i].j ].fx += 
   mySprings[ i ].nx * pressurev;
  
  myPoints[ mySprings[i].j ].fy += 
   mySprings[ i ].ny * pressurev;
}

As we can see in above procedure it is very simple to calculate pressure force. A smart idea of volume of the body calculation with simple expression for pressure gives us little piece of code which have to be added to spring-mass model to get soft body behavior.



Maciej Matyka 2004-03-30