How can I calculate the displacement of an object?