Skip to content

Commit

Permalink
fix issue when Bodies.trapezoid slope === 1, closes #138
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Dec 5, 2015
1 parent e04de5f commit 449774c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/factory/Bodies.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,19 @@ var Vector = require('../geometry/Vector');

var x1 = width * slope,
x2 = x1 + roof,
x3 = x2 + x1;
x3 = x2 + x1,
verticesPath;

if (slope < 0.5) {
verticesPath = 'L 0 0 L ' + x1 + ' ' + (-height) + ' L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0';
} else {
verticesPath = 'L 0 0 L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0';
}

var trapezoid = {
label: 'Trapezoid Body',
position: { x: x, y: y },
vertices: Vertices.fromPath('L 0 0 L ' + x1 + ' ' + (-height) + ' L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0')
vertices: Vertices.fromPath(verticesPath)
};

if (options.chamfer) {
Expand Down

0 comments on commit 449774c

Please sign in to comment.