Fixes for Black Dots

This fixes several Black Dots situation where NaN appear in the colors. 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 many modifications in the core to use 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.