21 #ifndef B3_TRAJECTORY_H
22 #define B3_TRAJECTORY_H
31 #include <boost/bind.hpp>
51 template<
class VecIter>
55 template<
class VecIter>
59 template<
class VecIter>
63 template<
class VecIter>
70 "Cannot get position: trajector is empty.");
73 "Cannot get position: frame out of range.");
75 size_t t = frame -
start();
89 template<
class VecIter>
90 void copy(VecIter out)
const;
96 "Cannot get dim: trajectory is empty.");
99 "Cannot get dth dimension of trajectory; d is too large.");
101 return trajectory_[d];
107 if(trajectory_.empty())
return 0;
108 return trajectory_.size();
112 size_t start()
const {
return start_; }
121 return trajectory_[0].size();
126 std::vector<vec_t> trajectory_;
131 template<
class VecIter>
134 typedef typename std::iterator_traits<VecIter>::value_type Vec;
138 size_t sz = std::distance(first, last);
145 trajectory_.resize(dim,
vec_t(static_cast<int>(sz)));
146 for(
size_t d = 0; d <
dim; d++)
150 trajectory_[d].begin(),
152 static_cast<const double&(Vec::*)(
int) const
>(&Vec::at),
159 template<
class VecIter>
164 size_t dim = std::distance(first, last);
167 size_t sz = first->size();
171 trajectory_.resize(dim);
172 std::copy(first, last, trajectory_.begin());
175 for(
size_t d = 0; d <
dim; d++)
178 "Cannot set trajectory dimensions; they must be same size.");
184 template<
class VecIter>
188 "Cannot append positions: trajectory empty.");
190 typedef typename std::iterator_traits<VecIter>::value_type Vec;
192 size_t sz = std::distance(first, last);
197 "Cannot append positions: dimension mismatch");
199 size_t new_sz =
size() + sz;
200 for(
size_t d = 0; d <
dim; d++)
202 trajectory_[d].reserve(new_sz);
205 std::back_inserter(trajectory_[d]),
207 static_cast<const double&(Vec::*)(
int) const
>(&Vec::at),
210 assert(trajectory_[d].
size() ==
size());
216 template<
class VecIter>
220 "Cannot append positions: trajectory empty.");
222 size_t dim = std::distance(first, last);
224 "Cannot append positions: dimension mismatch");
226 size_t sz = first->size();
229 size_t new_sz =
size() + sz;
230 for(
size_t d = 0; d <
dim; d++, first++)
232 trajectory_[d].reserve(new_sz);
236 std::back_inserter(trajectory_[d]));
238 assert(trajectory_[d].
size() ==
size());
244 template<
class VecIter>
249 const size_t s =
start();
250 const size_t e =
end();
251 for(
size_t t = s; t <= e; t++)
size_type size() const
Alias to get_length(). Required to comply with stl Container concept.
Definition: m_vector.h:510
size_t size() const
Gets the size of this person.
Definition: bbb_trajectory.h:118
size_t end() const
Gets the end frame of this person.
Definition: bbb_trajectory.h:115
Vector vec_t
Definition: bbb_trajectory.h:44
Value_type & at(int i)
Safely subscript vector, e.g., A.at(10), to get an lvalue.
Definition: m_vector.h:991
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
std::ostream & operator<<(std::ostream &ost, const Activity_sequence &aseq)
Push an activity sequence to an output stream.
#define IFT(a, ex, msg)
Definition: l_exception.h:101
const vec_t & dim(size_t d) const
Gets the trajectory of this person.
Definition: bbb_trajectory.h:93
iterator begin()
Definition: m_vector.h:537
Definition: bbb_trajectory.h:41
x
Definition: APPgetLargeConnectedEdges.m:100
void set_positions(size_t st, VecIter first, VecIter last)
Set points of this trajectory.
Definition: bbb_trajectory.h:132
vec_t pos(size_t frame) const
Gets the position of this person at the given frame.
Definition: bbb_trajectory.h:67
void copy(VecIter out) const
Gets the trajectory of this person.
Definition: bbb_trajectory.h:245
void append_dimensions(VecIter first, VecIter last)
Append by dimension.
Definition: bbb_trajectory.h:217
Trajectory()
Create an empty trajectory.
Definition: bbb_trajectory.h:48
void append_positions(VecIter first, VecIter last)
Append by position.
Definition: bbb_trajectory.h:185
Object thrown when an argument to a function is not acceptable.
Definition: l_exception.h:377
void set_dimensions(size_t st, VecIter first, VecIter last)
Set dimensions of this trajectory.
Definition: bbb_trajectory.h:160
size_t start() const
Gets the start frame of this person.
Definition: bbb_trajectory.h:112
Support for error handling exception classes in libKJB.
size_t dimensions() const
Gets the dimensionality of this person's trajectory.
Definition: bbb_trajectory.h:105
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
Object thrown when computation fails somehow during execution.
Definition: l_exception.h:321