// Rectify the transformation matrix representing the orientation of the ellipse
// We need to make sure that is *special* orthogonal, not just orthogonal
// Flip the signs of eigenvectors that point opposite the first quadrant
// Sum of the elements is the same as a dot product with (1, 1, 1)
// We want this so that the directions of the eigenvectors is consistent,
// and because this makes transform have determinant 1
for(intcol=0;col<transform.cols();++col)
{
if(transform.col(col).sum()<0.0)
{
transform.col(col)*=-1.0;
}
}
// if the matrix still has determinant smaller than one, just flip one of the vectors back. This may be the case if all of the columns point opposite (1, 1, 1)