Matter-js: Setting chamfer rotates bodies

Created on 8 Oct 2016  路  2Comments  路  Source: liabru/matter-js

I only tested this using the Matter.Bodies.rectangle(x, y, width, height, {chamfer: {radius: n}}) constructor.

It seems like setting a chamfered rectangle causes it to spawn counter-clockwisely rotated. This side effect increases proportionally to the chamfering amount. angle property remains zero, but the shape is visibly rotated.
This is not corrected by increasing chamfer.quality, but it gets better.

The following screenshot was set with chamfer: {radius: 5, quality: 1}. Setting quality to 10 prevents the cats from sliding quickly, but they'll still fall after some time (because I've set no friction).

Two cats lying on a green ground, all slightly rotated by one or two degrees CCW

This problem can be reproduced by:

  • Going to the demo page
  • In the sidebar:

    • Click the _clear_ button under the _World_ section

    • Set gravity to zero

    • Change the _chamfer_ setting under _Add Body_ to 5

    • Click addBody

  • Notice how the shape isn't straight and it's angle indicator is slightly rotated.

While it may seem a small side effect, this problem will cause large static rectangles placed side-by-side not to be leveled in relation to each other.

bug

Most helpful comment

Interesting, looks like there is something slightly off with the chamfering algorithm. Will need to check this out, thanks.

All 2 comments

Interesting, looks like there is something slightly off with the chamfering algorithm. Will need to check this out, thanks.

Hi, can we get a status update on this? Seems to be open since 2016

Was this page helpful?
0 / 5 - 0 ratings