Ellipsoid { public void setOrientation(final Matrix3dc semiAxes) { final Vector3d u = new Vector3d(); semiAxes.getColumn(0, u); final Vector3d v = new Vector3d(); semiAxes.getColumn(1, v); final Vector3d w = new Vector3d(); semiAxes.getColumn(2, w); setOrientation(u, v, w); } Ellipsoid(final double a, final double b, final double c);  Ellipsoid(final Vector3dc u, final Vector3dc v, final Vector3dc w); double getA(); void setA(final double a); double getB(); void setB(final double b); double getC(); void setC(final double c); Vector3d getCentroid(); void setCentroid(final Vector3dc centroid); Matrix4d getOrientation(); void setOrientation(final Matrix3dc semiAxes); List<Vector3d> getSemiAxes(); double getVolume(); @SuppressWarnings("unchecked") void initSampling(final OpEnvironment ops); List<Vector3d> samplePoints(final long n); void setSemiAxes(final Vector3dc u, final Vector3dc v,
		final Vector3dc w);  }
@Test public void testSetOrientation() { final Ellipsoid ellipsoid = new Ellipsoid(1, 2, 4); final Matrix3d orientation = new Matrix3d( 0, -1, 0, 1, 0, 0, 0, 0, 1 ); final Matrix3dc original = new Matrix3d(orientation); ellipsoid.setOrientation(orientation); orientation.scale(1.234); final Matrix4d m = ellipsoid.getOrientation(); final Matrix3dc result = new Matrix3d( m.m00(), m.m01(), m.m02(), m.m10(), m.m11(), m.m12(), m.m20(), m.m21(), m.m22() ); assertEquals("Setter copied values incorrectly or set a reference", original, result); }
@Test public void testSetOrientationAllowsLeftHandedBasis() { final Ellipsoid ellipsoid = new Ellipsoid(1, 2, 4); final Matrix3dc leftHanded = new Matrix3d( 1, 0, 0, 0, 1, 0, 0, 0, -1 ); ellipsoid.setOrientation(leftHanded); }
@Test public void testSetOrientationThrowsIAEIfNotOrthogonalVectors() { final Ellipsoid ellipsoid = new Ellipsoid(1, 2, 3); final Matrix3d uVNotOrthogonal = new Matrix3d( 1, 1, 0, 0, 1, 0, 0, 0, 1 ); final Matrix3d uWNotOrthogonal = new Matrix3d( 1, 0, 1, 0, 1, 0, 0, 0, 1 ); final Matrix3d vWNotOrthogonal = new Matrix3d( 1, 0, 0, 0, 1, 1, 0, 0, 1 ); final List<Matrix3d> testMatrices = Arrays.asList(uVNotOrthogonal, uWNotOrthogonal, vWNotOrthogonal); int exceptions = 0; for (final Matrix3d matrix : testMatrices) { try { ellipsoid.setOrientation(matrix); } catch (final IllegalArgumentException e) { assertEquals("Vectors must be orthogonal", e.getMessage()); exceptions++; } } assertEquals("All non-orthogonal matrices should have thrown an exception", testMatrices.size(), exceptions); }
@Test(expected = NullPointerException.class) public void testSetOrientationThrowsNPEIfMatrixNull() { final Ellipsoid ellipsoid = new Ellipsoid(1, 2, 3); ellipsoid.setOrientation(null); }