11 #ifndef IMPKINEMATICS_DOF_VALUES_H
12 #define IMPKINEMATICS_DOF_VALUES_H
16 #include <boost/serialization/access.hpp>
17 #include <boost/serialization/vector.hpp>
18 #include <boost/serialization/base_object.hpp>
20 IMPKINEMATICS_BEGIN_NAMESPACE
23 class IMPKINEMATICSEXPORT
DOFValues :
public std::vector<double> {
28 for (
unsigned int i = 0; i < dofs.size(); i++)
29 push_back(dofs[i]->get_value());
37 double get_distance2(
const DOFValues& other_dof_values)
const {
39 for(
unsigned int i=0; i<size(); i++) {
40 double diff1 = ((*this)[i] - other_dof_values[i]);
43 double diff = std::min(std::fabs(diff1), std::min(diff2, diff3));
49 double get_distance2(
const DOFValues& other_dof_values,
50 const std::vector<bool>& active_dofs)
const {
52 unsigned int asize = 0;
53 for(
unsigned int i=0; i<size(); i++) {
54 if(active_dofs.size() == 0 || active_dofs[i]) {
55 double diff1 = ((*this)[i] - other_dof_values[i]);
58 double diff = std::min(std::fabs(diff1), std::min(diff2, diff3));
66 double get_distance(
const DOFValues& other_dof_values)
const {
67 return sqrt(get_distance2(other_dof_values));
71 const std::vector<bool>& active_dofs)
const {
72 return sqrt(get_distance2(other_dof_values, active_dofs));
81 for (
unsigned int i = 1; i < size(); i++) {
82 out <<
"," << operator[](i);
88 friend class boost::serialization::access;
90 template<
class Archive>
void serialize(Archive &ar,
const unsigned int) {
91 ar & boost::serialization::base_object<std::vector<double> >(*this);
97 IMPKINEMATICS_END_NAMESPACE
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
static const double PI
the constant pi
DOFValues()
Empty Constructor.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
DOFValues(const DOFs &dofs)
Constructor from DOFs.
A class that holds DOF values for DOFs.
Various useful constants.
double get_distance(const Line3D &s, const Vector3D &p)
Get closest distance between a line and a point.