Recent advances in cementless hip replacement surgery have significantly improve the accuracy of bone cavity preparation and custom implant shape design. With the increased accuracy and tighter fit, determining whether the implant can actually be inserted to its final working position inside the cavity during surgery is essential to guarantee full implant functionality. This paper presents an implemented algorithm for determining if an implant can be successfully inserted into a cavity. The program computes an insertion trajectory consisting of small implant motion steps. Motion steps are computed by solving a series of linear optimization problems whose solution corresponds to the maximum allowed displacement in a preferred direction satisfying localized motion constraints.