### Couple of bugs found!!!

Posted:

**Mon Nov 23, 2015 12:09 am**Hello William,

while developing simulator I found couple of small bugs in dyn4j library

1. Rectangle class in Geometry package

2. Polygon Class in Geometry package

These bugs create problem in multi-fixture body with fixture as rectangle rotated by some angle. The angle of rotation is then calculated about wrongly transformed normals.

Anyway Dyn4j is one of the best thing I learnt so far.

Regards..

while developing simulator I found couple of small bugs in dyn4j library

1. Rectangle class in Geometry package

Code: Select all

`/**`

* Returns the rotation about the local center in radians.

* @return double the rotation in radians

* @since 3.0.1

*/

public double getRotation() {

// when the shape is created normals[1] will always be the positive x-axis

// we can get the rotation by comparing it to the positive x-axis

// since the normal vectors are rotated with the vertices when

// a shape is rotated

// return this.normals[1].getAngleBetween(Vector2.X_AXIS); //original

return -this.normals[1].getAngleBetween(Vector2.X_AXIS); //corrected

}

2. Polygon Class in Geometry package

Code: Select all

` @Override`

public void rotate(double theta, double x, double y) {

super.rotate(theta, x, y);

int size = this.vertices.length;

for (int i = 0; i < size; i++) {

this.vertices[i].rotate(theta, x, y);

// this.normals[i].rotate(theta, x,y);//original

this.normals[i].rotate(theta); //corrected==>normals are not supposed to be rotated about point

}

}

These bugs create problem in multi-fixture body with fixture as rectangle rotated by some angle. The angle of rotation is then calculated about wrongly transformed normals.

Anyway Dyn4j is one of the best thing I learnt so far.

Regards..