I don't think you can use
switch
in this case because you don't have definite outputs.
Both
min
and
max
have three basic states: negative, zero and positive.
You could make a case for 0 and since positive is correct, you could make it the default case, but you have no way of knowing
a priori the negative values each of them can have.
Or, I mean, you could by using an invented index saying something like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
int _min;
if(0>min)
_min = -1;
else if(0==min)
_min = 0;
switch min_neg
{
case -1:
//...
break;
case 0:
//...
break;
default:
//...
break;
}
|
Or something (then repeat for maj), but I don't think it's worth it, quite honestly.
I'd suggest simply removing the else-if statements and substituting them for simple if-statements. It makes it go through each of them, but it's safer, since you've got so many combinations to watch for.
You can instead simply use
1 2 3 4 5 6 7 8
|
if(0==min)
//no minor axis
else if(0>min)
//negative minor axis
if(0==max)
//no major axis
else if(0>max)
//negative major axis
|
This is also better because it allows the user to input the minor and major axes in any order (you have no check as is). Actually, you should call them x-axis and y-axis, since perhaps your user wants to make a vertical ellipse, not a horizontal one.
As well, what's wrong with negative axes? Aren't their values simply squared?