API Docs for: 0.6.1
Show:

File: src/equations/FrictionEquation.js

  1. module.exports = FrictionEquation;
  2.  
  3. var Equation = require('./Equation');
  4. var Vec3 = require('../math/Vec3');
  5. var Mat3 = require('../math/Mat3');
  6.  
  7. /**
  8. * Constrains the slipping in a contact along a tangent
  9. * @class FrictionEquation
  10. * @constructor
  11. * @author schteppe
  12. * @param {Body} bodyA
  13. * @param {Body} bodyB
  14. * @param {Number} slipForce should be +-F_friction = +-mu * F_normal = +-mu * m * g
  15. * @extends Equation
  16. */
  17. function FrictionEquation(bodyA, bodyB, slipForce){
  18. Equation.call(this,bodyA, bodyB, -slipForce, slipForce);
  19. this.ri = new Vec3();
  20. this.rj = new Vec3();
  21. this.t = new Vec3(); // tangent
  22. }
  23.  
  24. FrictionEquation.prototype = new Equation();
  25. FrictionEquation.prototype.constructor = FrictionEquation;
  26.  
  27. var FrictionEquation_computeB_temp1 = new Vec3();
  28. var FrictionEquation_computeB_temp2 = new Vec3();
  29. FrictionEquation.prototype.computeB = function(h){
  30. var a = this.a,
  31. b = this.b,
  32. bi = this.bi,
  33. bj = this.bj,
  34. ri = this.ri,
  35. rj = this.rj,
  36. rixt = FrictionEquation_computeB_temp1,
  37. rjxt = FrictionEquation_computeB_temp2,
  38. t = this.t;
  39.  
  40. // Caluclate cross products
  41. ri.cross(t,rixt);
  42. rj.cross(t,rjxt);
  43.  
  44. // G = [-t -rixt t rjxt]
  45. // And remember, this is a pure velocity constraint, g is always zero!
  46. var GA = this.jacobianElementA,
  47. GB = this.jacobianElementB;
  48. t.negate(GA.spatial);
  49. rixt.negate(GA.rotational);
  50. GB.spatial.copy(t);
  51. GB.rotational.copy(rjxt);
  52.  
  53. var GW = this.computeGW();
  54. var GiMf = this.computeGiMf();
  55.  
  56. var B = - GW * b - h * GiMf;
  57.  
  58. return B;
  59. };
  60.