Probabilistic matching of solid shapes in arbitrary dimension