# TestLine Unit test failing on testOrthogonalLineFit()

I was just messing around and ran some of the newly added jME unit tests, and on my system the TestLine unit test is failing in the testOrthogonalLineFit() test case.

```    public void testOrthogonalLineFit() {       Line ls = new Line();       FloatBuffer points = BufferUtils.createFloatBuffer(18);       points.put(6).put(3).put(9);       points.put(16).put(-3).put(0);       points.put(4.5f).put(8).put(32);       points.put(0).put(0).put(1);       points.put(10).put(3).put(76);       points.put(-8).put(-45).put(-1.5f);       ls.orthogonalLineFit(points);       assertTrue(ls.getDirection().equals(new Vector3f(0.12209535f, 0.3713143f, 0.92044467f)));       assertTrue(ls.getOrigin().equals(new Vector3f(4.75f, -5.666667f, 19.416668f)));    }    ```

The assertion that's failing is:

``` assertTrue(ls.getDirection().equals(new Vector3f(0.12209535f,  0.3713143f, 0.92044467f))); ```

It looks like ls.getDirection() is:

``` com.jme.math.Vector3f [X=-0.12209535, Y=-0.3713143, Z=-0.92044467] ```

I gave a lazy attempt at debugging it but due to lack of time and patience  all I can tell is that I think it's going wrong somewhere in Eigne3f's computeVectors(), or perhaps in the Vector3f generateComplementBasis()..

Or is it computing the right answer just the test is expecting the wrong value?  I need to brush up on my linear algebra and eigenvectors, maybe I'll take a look at it later tonight.

Is this a Ray?  Otherwise, the "direction" should be valid in both directions.  (Or if it's a segment, then the endpoint could be on the other end of the segment and the direction flipped.)

Ahh I see! It’s a Line so I guess both positive or negative directions are valid.

The Unit test I found the error in is from the jME source code so should that be updated to something like:

LineTest.java

```     @Test     public void testOrthogonalLineFit() {         Line ls = new Line();         FloatBuffer points = BufferUtils.createFloatBuffer(18);         points.put(6).put(3).put(9);         points.put(16).put(-3).put(0);         points.put(4.5f).put(8).put(32);         points.put(0).put(0).put(1);         points.put(10).put(3).put(76);         points.put(-8).put(-45).put(-1.5f);         ls.orthogonalLineFit(points);         Vector3f direction = ls.getDirection();         Vector3f expectedDirection = new Vector3f(                                             0.12209535f,                                             0.3713143f,                                             0.92044467f);         // The direction of a Line can be in either direction so check equality         // for both directions         assertTrue(direction.equals(expectedDirection) ||                    direction.equals(expectedDirection.negate()));         assertTrue(ls.getOrigin().equals(                 new Vector3f(4.75f, -5.666667f, 19.416668f)));     } ```

Also I think the TestBoundingCapsule has the same issue.

TestBoundingCapsule.java

```    @Test     public void testOrthogonalLineFit() {         FloatBuffer points = BufferUtils.createFloatBuffer(18);         points.put(6).put(3).put(9);         points.put(16).put(-3).put(0);         points.put(4.5f).put(8).put(32);         points.put(0).put(0).put(1);         points.put(10).put(3).put(76);         points.put(-8).put(-45).put(-1.5f);         BoundingCapsule bc = new BoundingCapsule();         bc.computeFromPoints(points);         assertTrue(bc.getRadius() == 29.883142f);         assertTrue(bc.getLineSegment().getOrigin().equals(                 new Vector3f(4.367725f, -6.829235f, 16.534798f)));         Vector3f direction = bc.getLineSegment().getDirection();         Vector3f expectedDirection = new Vector3f(0.12209535f, 0.3713143f,                 0.92044467f);         // The direction of a Line can be in either direction so check equality         // for both directions         assertTrue(direction.equals(expectedDirection) ||                    direction.equals(expectedDirection.negate()));         assertTrue(bc.getLineSegment().getExtent() == 32.27561f);     } ```

Hmm, I don't have these tests locally…  can one of the other devs check on this?

why are the new unittests located under the jmetest package(jmetest.unit.xxx) and not under the junit folder? unittests should have the same package structure as the classes they are testing to be able to have full access(package friendly)…