Geometry of Patterns