Guest User

Untitled

a guest
Jan 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. tVec3f tRigidBody::fComputeImpulseToChangeRelativePointVel( f32 dt, const tVec3f& worldPointa, const tVec3f& worldPointb, const tVec3f& direction, float magnitude, const tRigidBody& otherBody )
  2. {
  3. tVec3f offsetA = worldPointa - fTransform( ).fGetTranslation( );
  4. tVec3f offsetCrossNA = offsetA.fCross( direction );
  5. offsetCrossNA = mWorldInertiaInv.fXformVector( offsetCrossNA );
  6. offsetCrossNA = offsetCrossNA.fCross( offsetA );
  7. f32 offsetCrossNSquaredA = offsetCrossNA.fDot( direction );
  8.  
  9. tVec3f offsetB = worldPointb - otherBody.fTransform( ).fGetTranslation( );
  10. tVec3f offsetCrossNB = offsetB.fCross(direction);
  11. offsetCrossNB = otherBody.fWorldInertiaInv( ).fXformVector( offsetCrossNB );
  12. offsetCrossNB = offsetCrossNB.fCross( offsetB );
  13. f32 offsetCrossNSquaredB = offsetCrossNB.fDot( direction );
  14.  
  15. //j = magnitude
  16. // ----------------------------------------------
  17. // 1/ma + 1/mb + Dot(N, ((rap x direction) / Ia) x rap) + Dot(N, ((rbp x direction)2 / Ib) / rbp)
  18.  
  19. f32 denominator = 1 / mMass + 1 / otherBody.fMass( ) + offsetCrossNSquaredA + offsetCrossNSquaredB;
  20. f32 j = magnitude / denominator;
  21.  
  22. tVec3f impulse = direction * j;
  23. return impulse;
  24. }
Add Comment
Please, Sign In to add comment