Math: scalar/vector implementation of min(), max() and clamp().

This is gonna be some ugly template hell.