SHARE
TWEET

Untitled

a guest Jan 20th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class StateVector {
  2. protected:
  3.     float* _v;
  4.  
  5. public:
  6.  
  7.     StateVector():_v(new float[size()]) {}
  8.     virtual ~StateVector() { delete [] _v; }
  9.  
  10.     virtual size_t size() = 0;
  11.  
  12.     // ...
  13.  
  14. };
  15.  
  16. class PositionState : public StateVector {
  17. public:
  18.     size_t size() { return 3; }
  19.     float* x()    { return _v; }
  20. };
  21.  
  22. class MovingState : public PositionState {
  23. public:
  24.     size_t size() { return PositionState::size() + 3; }
  25.     float* v()    { return _v + PositionState::size(); }
  26. };
  27.    
  28. template <typename State>
  29. class StateTransition {
  30.  
  31.     Matrix<float> _m;
  32.  
  33.     // constructor for Matrix takes #rows, #cols
  34.     StateTransition():_m(State().size(), State().size()) {}
  35.  
  36.     // ...
  37.  
  38. };
  39.    
  40. class StateVector {
  41.     float* _v;
  42.     StateVector:_v(new float[size()]) {}
  43.  
  44.     virtual static size_t size() = 0;
  45. };
  46.  
  47. class PositionState {
  48.     static size_t size() { return 3; }
  49.     // ...
  50. };
  51.  
  52. // etc.
  53.  
  54. template <typename State>
  55. class StateTransition {
  56.  
  57.     Matrix<float> _m;
  58.  
  59.     StateTransition():_m(State::size(), State::size()) {}
  60. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top