1mjb – November 16, 2007Oregon State UniversityComputer GraphicsModeling the World as a Mesh of SpringsMike BaileyOregon State Universitymjb – November 16, 2007Oregon State UniversityComputer GraphicsDk = spring stiffness in Newtons/meter or pounds/inch0FDDk=+Force = FHow do Springs Work?D0D0= unloaded spring lengthOr, if you know the displacement, the force exerted by the spring must be:0()FkD D=−2mjb – November 16, 2007Oregon State UniversityComputer GraphicsWeight(,)Fvyt dtm=∑∫(,)Wkyvyt dtm−=∫Solving Motion where there is a Spring0()springFkD D=−voidGetVelAcc( float t, float y, float vy, float *v, float *a ){*v = vy;*a = ( W – K*y ) / MASS;}*a = ( MASS*GRAVITY – K*y ) / MASS;Note that, instead of using weight, we could write that last line with mass:mjb – November 16, 2007Oregon State UniversityComputer GraphicsModeling a String as a Group of Masses Connected by Springs“Lumped Masses”3mjb – November 16, 2007Oregon State UniversityComputer GraphicsComputing Forcesii-1i+1110()ii iiFkD D→− →−=−110()ii iiFkD D→+ →+=−gFMassGravity=×1ˆiiV→−1ˆiiV→+mjb – November 16, 2007Oregon State UniversityComputer GraphicsSumming Forcesii-1i+1110()ii iiFkD D→− →−=−110()ii iiFkDD→+ →+=−gFMass Gravity=×1ˆiiV→−1ˆiiV→+,1,11,1ˆˆix ii x ii ii x iiFVFVFMassx→− →− →+ →+=⋅+⋅=⋅∑,1,11,1ˆˆiy i i y i i i i y i i gFVFVFFMassy→− →− →+ →+=⋅+⋅+=⋅∑4mjb – November 16, 2007Oregon State UniversityComputer GraphicsSolve for Each State as a Whole, not as Individual Links:Do it this Wayfor( int i = 0; i < NUMLINKS; i++ ){ GetVelAccel( i, &vx1[i], &vy1[i], &ax1[i], &ay1[i] );} for( int i = 0; i < NUMLINKS; i++ ){ vxtmp[i] = Links[i].vx + DT * ax1[i];vytmp[i] = Links[i].vy + DT * ay1[i];xtmp[i] = Links[i].x + DT * vx1[i];ytmp[i] = Links[i].y + DT * vy1[i];}for( int i = 0; i < NUMLINKS; i++ ){ GetVelAccel( i, &vx2[i], &vy2[i], &ax2[i], &ay2[i] );} for( int i = 0; i < NUMLINKS; i++ ){ Links[i].vx = Links[i].vx + DT * ( ax1[i] + ax2[i] ) / 2.;Links[i].vy = Links[i].vy + DT * ( ay1[i] + ay2[i] ) / 2.;Links[i].x = Links[i].x + DT * ( vx1[i] + vx2[i] ) / 2.; Links[i].y = Links[i].y + DT * ( vy1[i] + vy2[i] ) / 2.; } Second Order solution:Get allthe velocities and accelerationsApply allthe velocities and accelerationsGet allthe velocities and accelerationsApply allthe velocities and accelerationsmjb – November 16, 2007Oregon State UniversityComputer GraphicsDon’t do it this Way!for( int i = 0; i < NUMLINKS; i++ ){ GetVelAccel( i, &vx1[i], &vy1[i], &ax1[i], &ay1[i] );vxtmp[i] = Links[i].vx + DT * ax1[i];vytmp[i] = Links[i].vy + DT * ay1[i];xtmp[i] = Links[i].x + DT * vx1[i];ytmp[i] = Links[i].y + DT * vy1[i];}for( int i = 0; i < NUMLINKS; i++ ){ GetVelAccel( i, &vx2[i], &vy2[i], &ax2[i], &ay2[i] );Links[i].vx = Links[i].vx + DT * ( ax1[i] + ax2[i] ) / 2.;Links[i].vy = Links[i].vy + DT * ( ay1[i] + ay2[i] ) / 2.;Links[i].x = Links[i].x + DT * ( vx1[i] + vx2[i] ) / 2.; Links[i].y = Links[i].y + DT * ( vy1[i] + vy2[i] ) / 2.; } Second Order solution:5mjb – November 16, 2007Oregon State UniversityComputer GraphicsChanging Variables on-the-flymjb – November 16, 2007Oregon State UniversityComputer GraphicsSimulating a String6mjb – November 16, 2007Oregon State UniversityComputer GraphicsLess Dampingmjb – November 16, 2007Oregon State UniversityComputer GraphicsFirst Order Instability7mjb – November 16, 2007Oregon State UniversityComputer GraphicsPlacing a Physical Barrier in the Scenemjb – November 16, 2007Oregon State UniversityComputer Graphicsif( DoCircle ){ for( int i = 0; i < NUMLINKS; i++ ){ float dx = Links[i].x - CIRCX;float dy = Links[i].y - CIRCY;float rsqd = dx*dx + dy*dy;if( rsqd < CIRCR*CIRCR ){ float r = sqrt( rsqd ); dx /= r;dy /= r;Links[i].x = CIRCX + CIRCR * dx;Links[i].y = CIRCY + CIRCR * dy;Links[i].vx *= dy; Links[i].vy *= -dx; } } } Placing a Physical Barrier in the SceneVector from circle center to the lumped massUnit vector from circle center to the lumped massPush the lumped mass from inside the circle to the circle’s surfaceKeep just the tangential velocityIf the lumped mass is inside the circle …8mjb – November 16, 2007Oregon State UniversityComputer GraphicsModeling Cloth•••mjb – November 16, 2007Oregon State UniversityComputer GraphicsModeling Cloth•••9mjb – November 16, 2007Oregon State UniversityComputer GraphicsExamplesDavid E. Breen Donald H. House, Michael J. Wozny: Predicting the Drape of Woven Cloth Using Interacting Particles Using Interacting Particlesmjb – November 16, 2007Oregon State UniversityComputer GraphicsExamplesMiraLab, University of Geneva10mjb – November 16, 2007Oregon State UniversityComputer GraphicsExamplesPixarmjb – November 16, 2007Oregon State UniversityComputer GraphicsModeling Jello11mjb – November 16, 2007Oregon State UniversityComputer GraphicsExamplesMITmjb – November 16, 2007Oregon State UniversityComputer GraphicsCalifornia Department of TransportationWe can also use this same Method to Model Rigid Objects12mjb – November 16, 2007Oregon State UniversityComputer GraphicsWe can also use this same Method to Model Rigid Objectsmjb – November 16, 2007Oregon State UniversityComputer
View Full Document