UNPKG

cannon

Version:

A lightweight 3D physics engine written in JavaScript.

43 lines (36 loc) 970 B
module.exports = JacobianElement; var Vec3 = require('./Vec3'); /** * An element containing 6 entries, 3 spatial and 3 rotational degrees of freedom. * @class JacobianElement * @constructor */ function JacobianElement(){ /** * @property {Vec3} spatial */ this.spatial = new Vec3(); /** * @property {Vec3} rotational */ this.rotational = new Vec3(); } /** * Multiply with other JacobianElement * @method multiplyElement * @param {JacobianElement} element * @return {Number} */ JacobianElement.prototype.multiplyElement = function(element){ return element.spatial.dot(this.spatial) + element.rotational.dot(this.rotational); }; /** * Multiply with two vectors * @method multiplyVectors * @param {Vec3} spatial * @param {Vec3} rotational * @return {Number} */ JacobianElement.prototype.multiplyVectors = function(spatial,rotational){ return spatial.dot(this.spatial) + rotational.dot(this.rotational); };