Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elements of homogeneous matrices are not initialized when using 2D systems #22

Open
omgm opened this issue Sep 2, 2014 · 0 comments · May be fixed by #23
Open

Elements of homogeneous matrices are not initialized when using 2D systems #22

omgm opened this issue Sep 2, 2014 · 0 comments · May be fixed by #23

Comments

@omgm
Copy link

omgm commented Sep 2, 2014

This issue was found thanks to performing mutation analysis with Mutator (http://ortask.com/mutator/) on test suite homog-test.js.

The constructor for Homog (homog.js) seems to support 2D systems by accepting a 2D rotation matrix and 2D vector as parameters. However, the resulting matrix is not initialized properly.

In particular, I added the following test to homog-test.js as suggested by mutation analysis:

  it('creates matrix with good values for 2D systems', function () {
    var Rz = new Matrix(2, 2);
    var Trans = new Vector(0,0)
    var H1 = new Homog(Rz, Trans);
    H1.m.should.eql([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]);
  });

but get the following error when running the tests:

  1) Create a homogenous matrix creates matrix with good values for 2D systems:

      AssertionError: expected [ [ 0, 0, , 0 ], [ 0, 0, , 0 ], [ 0, 0, 1, 0 ], [
 0, 0, 0, 1 ] ] to equal [ [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 1, 0 ], [ 0,
0, 0, 1 ] ]
      + expected - actual

       [
         [
           0
           0
      -    null
           0
      +    0
         ]
         [
           0
           0
      -    null
           0
      +    0
         ]
         [
           0
           0

Inspecting the constructor for Homog, it seems that the following loop only sets the first four elements of the matrix (as that is the limit when passing in a 2x2 rotation matrix), but leaves elements (0,2) and (1,2) uninitialized (i.e. as null):

  // fill in the rotation part
  for (var r = 0; r < rot.rows; ++r) {
    for (var c = 0; c < rot.cols; ++c) {
      H.set(r, c, rot.get(r, c));
    }
  }
@omgm omgm changed the title Creating homogenous matrix does not support 2D systems correctly Elements of homogeneous matrices are not initialized when using 2D systems Sep 2, 2014
omgm added a commit to omgm/vektor that referenced this issue Sep 4, 2014
Mutation analysis was performed on homog-test.js with Mutator (http://ortask.com/mutator/). I improved the test suite's mutation score from 0.63 to 0.8. 

In order to get to raise the quality of the test suite to 1.0, the following issue needs to be resolved: rockbot#22
@omgm omgm linked a pull request Sep 4, 2014 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant