A three dimensional magnetic sensor attached to a surgical nail is located based on an applied monotonic magnetic field gradient. Another three dimensional magnetic sensor locates a surgical drill. A display generates a real time image of the relative alignment of the surgical drill and of the surgical nail, allowing a surgeon to repair bone fractures.