Applications of trajectory-based analysis in optimization and control