final int dimension = getDimension();
for (int i=0; i<dimension; i++) {
final AxisDirection axis0 = getAxis(i).getDirection();
for (int j=i; ++j<dimension;) {
final AxisDirection axis1 = getAxis(j).getDirection();
final Angle angle = CoordinateSystems.angle(axis0, axis1);
/*
* The angle may be null for grid directions (COLUMN_POSITIVE, COLUMN_NEGATIVE,
* ROW_POSITIVE, ROW_NEGATIVE). We conservatively accept those directions even if
* they are not really for Cartesian CS because we do not know the grid geometry.
*/
if (angle != null && Math.abs(angle.degrees()) != 90) {
throw new IllegalArgumentException(Errors.format(
Errors.Keys.NonPerpendicularDirections_2, axis0, axis1));
}
}
}