It is well known that there is an analogy between optics and mechanics that prompted much of the classical theory of mechanics and indeed extended it to the theory of quantum mechanics. We develop here an optical mechanical analogy for a prototypical nonholonomic mechanical system, a knife edge moving on a plane under the influence of a potential. We show that this approach is related to but different from the classical theory of Hamiltonization of nonholonomic systems.