API Docs for: 0.6.1
Show:

File: src/material/ContactMaterial.js

  1. var Utils = require('../utils/Utils');
  2.  
  3. module.exports = ContactMaterial;
  4.  
  5. /**
  6. * Defines what happens when two materials meet.
  7. * @class ContactMaterial
  8. * @constructor
  9. * @param {Material} m1
  10. * @param {Material} m2
  11. * @param {object} [options]
  12. * @param {Number} [options.friction=0.3]
  13. * @param {Number} [options.restitution=0.3]
  14. * @param {number} [options.contactEquationStiffness=1e7]
  15. * @param {number} [options.contactEquationRelaxation=3]
  16. * @param {number} [options.frictionEquationStiffness=1e7]
  17. * @param {Number} [options.frictionEquationRelaxation=3]
  18. */
  19. function ContactMaterial(m1, m2, options){
  20. options = Utils.defaults(options, {
  21. friction: 0.3,
  22. restitution: 0.3,
  23. contactEquationStiffness: 1e7,
  24. contactEquationRelaxation: 3,
  25. frictionEquationStiffness: 1e7,
  26. frictionEquationRelaxation: 3
  27. });
  28.  
  29. /**
  30. * Identifier of this material
  31. * @property {Number} id
  32. */
  33. this.id = ContactMaterial.idCounter++;
  34.  
  35. /**
  36. * Participating materials
  37. * @property {Array} materials
  38. * @todo Should be .materialA and .materialB instead
  39. */
  40. this.materials = [m1, m2];
  41.  
  42. /**
  43. * Friction coefficient
  44. * @property {Number} friction
  45. */
  46. this.friction = options.friction;
  47.  
  48. /**
  49. * Restitution coefficient
  50. * @property {Number} restitution
  51. */
  52. this.restitution = options.restitution;
  53.  
  54. /**
  55. * Stiffness of the produced contact equations
  56. * @property {Number} contactEquationStiffness
  57. */
  58. this.contactEquationStiffness = options.contactEquationStiffness;
  59.  
  60. /**
  61. * Relaxation time of the produced contact equations
  62. * @property {Number} contactEquationRelaxation
  63. */
  64. this.contactEquationRelaxation = options.contactEquationRelaxation;
  65.  
  66. /**
  67. * Stiffness of the produced friction equations
  68. * @property {Number} frictionEquationStiffness
  69. */
  70. this.frictionEquationStiffness = options.frictionEquationStiffness;
  71.  
  72. /**
  73. * Relaxation time of the produced friction equations
  74. * @property {Number} frictionEquationRelaxation
  75. */
  76. this.frictionEquationRelaxation = options.frictionEquationRelaxation;
  77. }
  78.  
  79. ContactMaterial.idCounter = 0;
  80.