Skip to content

Commit

Permalink
added doc and warning for Bodies.trapezioid slope parameter range, c…
Browse files Browse the repository at this point in the history
…loses #1075
  • Loading branch information
liabru committed Mar 18, 2023
1 parent 6bda7e8 commit 7ea5bc1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/factory/Bodies.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,25 @@ var Vector = require('../geometry/Vector');

/**
* Creates a new rigid body model with a trapezoid hull.
* The `slope` is parameterised as a fraction of `width` and must be < 1 to form a valid trapezoid.
* The options parameter is an object that specifies any properties you wish to override the defaults.
* See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object.
* @method trapezoid
* @param {number} x
* @param {number} y
* @param {number} width
* @param {number} height
* @param {number} slope
* @param {number} slope Must be a number < 1.
* @param {object} [options]
* @return {body} A new trapezoid body
*/
Bodies.trapezoid = function(x, y, width, height, slope, options) {
options = options || {};

if (slope >= 1) {
Common.warn('Bodies.trapezoid: slope parameter must be < 1.');
}

slope *= 0.5;
var roof = (1 - (slope * 2)) * width;

Expand Down

0 comments on commit 7ea5bc1

Please sign in to comment.