*/
@Test
public void testAxisSwapping() {
AxisDirection[] srcAxis = {NORTH, EAST, UP};
AxisDirection[] dstAxis = {NORTH, EAST, UP};
GeneralMatrix matrix = new GeneralMatrix(srcAxis, dstAxis);
assertTrue(matrix.isAffine ());
assertTrue(matrix.isIdentity());
dstAxis = new AxisDirection[] {WEST, UP, SOUTH};
matrix = new GeneralMatrix(srcAxis, dstAxis);
assertTrue (matrix.isAffine ());
assertFalse(matrix.isIdentity());
assertEquals(new GeneralMatrix(new double[][] {
{ 0,-1, 0, 0},
{ 0, 0, 1, 0},
{-1, 0, 0, 0},
{ 0, 0, 0, 1}
}), matrix);
dstAxis = new AxisDirection[] {DOWN, NORTH};
matrix = new GeneralMatrix(srcAxis, dstAxis);
assertFalse(matrix.isIdentity());
assertEquals(new GeneralMatrix(new double[][] {
{0, 0,-1, 0},
{1, 0, 0, 0},
{0, 0, 0, 1}
}), matrix);
dstAxis = new AxisDirection[] {DOWN, DOWN};
matrix = new GeneralMatrix(srcAxis, dstAxis);
assertFalse(matrix.isIdentity());
assertEquals(new GeneralMatrix(new double[][] {
{0, 0,-1, 0},
{0, 0,-1, 0},
{0, 0, 0, 1}
}), matrix);
dstAxis = new AxisDirection[] {DOWN, GEOCENTRIC_X};
try {
matrix = new GeneralMatrix(srcAxis, dstAxis);
fail();
} catch (IllegalArgumentException exception) {
// This is the expected exception (axis not in source).
}
srcAxis = dstAxis;
dstAxis = new AxisDirection[] {NORTH, EAST, UP, WEST};
try {
matrix = new GeneralMatrix(srcAxis, dstAxis);
fail();
} catch (IllegalArgumentException exception) {
// This is the expected exception (colinear axis).
}
}