In Tumble, my senior game project, players can select objects with the mouse and place it in the world. The object needs to snap to whatever is underneath it. This function computes the position of that object: