Add buildTrajectory method.