Foundations of Geometric Cognition