I've written a little method that returns the index of the maximum of 3 numbers (0, 1 or 2):
public static int Max3Index(float val1, float val2, float val3)
{
int index = val1 > val2 ? 0 : 1;
if (index == 0)
{
index = val1 > val3 ? 0 : 2;
}
else
{
index = val2 > val3 ? 1 : 2;
}
return index;
}
This works until 2 or more numbers are equal. What the heck should I do when this condition occurs?