#

API Docs for: 0.6.0
Show: Inherited Protected Private Deprecated

# File: src/material/ContactMaterial.js

    var Utils = require('../utils/Utils');

    module.exports = ContactMaterial;

    /**
     * Defines what happens when two materials meet.
     * @class ContactMaterial
     * @constructor
     * @param {Material} m1
     * @param {Material} m2
     * @param {Number} friction
     * @param {Number} restitution
     */
    function ContactMaterial(m1, m2, options){
        options = Utils.defaults(options, {
            friction: 0.3,
            restitution: 0.3,
            contactEquationStiffness: 1e7,
            contactEquationRelaxation: 3,
            frictionEquationStiffness: 1e7,
            frictionEquationRelaxation: 3
        });

        /**
         * Identifier of this material
         * @property {Number} id
         */
        this.id = ContactMaterial.idCounter++;

        /**
         * Participating materials
         * @property {Array} materials
         * @todo  Should be .materialA and .materialB instead
         */
        this.materials = [m1, m2];

        /**
         * Friction coefficient
         * @property {Number} friction
         */
        this.friction = options.friction;

        /**
         * Restitution coefficient
         * @property {Number} restitution
         */
        this.restitution = options.restitution;

        /**
         * Stiffness of the produced contact equations
         * @property {Number} contactEquationStiffness
         */
        this.contactEquationStiffness = options.contactEquationStiffness;

        /**
         * Relaxation time of the produced contact equations
         * @property {Number} contactEquationRelaxation
         */
        this.contactEquationRelaxation = options.contactEquationRelaxation;

        /**
         * Stiffness of the produced friction equations
         * @property {Number} frictionEquationStiffness
         */
        this.frictionEquationStiffness = options.frictionEquationStiffness;

        /**
         * Relaxation time of the produced friction equations
         * @property {Number} frictionEquationRelaxation
         */
        this.frictionEquationRelaxation = options.frictionEquationRelaxation;
    }

    ContactMaterial.idCounter = 0;