Keep Math.acos() argument between -1 and 1.

Closes #482.