Fixes for Black Dots

This fixes several Black Dots situations where NaN appear in the color calculations. Apparently this can be caused by two circumstances:
* Usage of 32bit float numbers within 64bit double acos() functions.
* Sometimes, for some reason, the input to the acos() function is very slightly outside of the [-1,1] domain, causing a NaN. Perhaps that could be caused by the normal accumulative 32bit float calculation errors?

Therefore, I have done several modifications in the Core code to use, instead of the standard double acos() funcion, an inline fAcos() function defined both as a float and as a double, depending on the type of number being used.
* I have also added runtime-checks of the domain validity. If the input number is outside the domain, it's considered as being at the end of the domain. For example, -1.0001 would be considered as -1.0 for the acos calculation.
* I have used acosf() instead of acos() for the 32bit floating point numbers. That also caused problems when the input 32bit number was at the exremes of the domain.