48 #ifndef ILQGAMES_DYNAMICS_SINGLE_PLAYER_POINT_MASS_2D_H 49 #define ILQGAMES_DYNAMICS_SINGLE_PLAYER_POINT_MASS_2D_H 51 #include <ilqgames/dynamics/single_player_dynamical_system.h> 52 #include <ilqgames/utils/types.h> 63 VectorXf Evaluate(Time t,
const VectorXf& x,
const VectorXf& u)
const;
66 void Linearize(Time t,
const VectorXf& x,
const VectorXf& u,
67 Eigen::Ref<MatrixXf> A, Eigen::Ref<MatrixXf> B)
const;
70 float DistanceBetween(
const VectorXf& x0,
const VectorXf& x1)
const;
73 std::vector<Dimension> PositionDimensions()
const {
return {kPxIdx, kPyIdx}; }
76 static const Dimension kNumXDims;
77 static const Dimension kPxIdx;
78 static const Dimension kPyIdx;
79 static const Dimension kVxIdx;
80 static const Dimension kVyIdx;
83 static const Dimension kNumUDims;
84 static const Dimension kAxIdx;
85 static const Dimension kAyIdx;
90 inline VectorXf SinglePlayerPointMass2D::Evaluate(Time t,
const VectorXf& x,
91 const VectorXf& u)
const {
93 xdot(kPxIdx) = x(kVxIdx);
94 xdot(kPyIdx) = x(kVyIdx);
95 xdot(kVxIdx) = u(kAxIdx);
96 xdot(kVyIdx) = u(kAyIdx);
101 inline void SinglePlayerPointMass2D::Linearize(Time t,
const VectorXf& x,
103 Eigen::Ref<MatrixXf> A,
104 Eigen::Ref<MatrixXf> B)
const {
105 A(kPxIdx, kVxIdx) += time::kTimeStep;
106 A(kPyIdx, kVyIdx) += time::kTimeStep;
108 B(kVxIdx, kAxIdx) = time::kTimeStep;
109 B(kVyIdx, kAyIdx) = time::kTimeStep;
112 inline float SinglePlayerPointMass2D::DistanceBetween(
113 const VectorXf& x0,
const VectorXf& x1)
const {
115 const float dx = x0(kPxIdx) - x1(kPxIdx);
116 const float dy = x0(kPyIdx) - x1(kPyIdx);
117 return dx * dx + dy * dy;