Commit aefa6394 authored by Steve T's avatar Steve T
Browse files

ndcurves is the final name

parent b1e1168a
......@@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
# Project properties
SET(PROJECT_ORG loco-3d)
SET(PROJECT_NAME nd_curves)
SET(PROJECT_NAME ndcurves)
SET(PROJECT_DESCRIPTION "creatie and manipulate spline and bezier curves.")
SET(PROJECT_URL "https://github.com/${PROJECT_ORG}/${PROJECT_NAME}")
......
......@@ -20,7 +20,7 @@
#include <vector>
#include <utility>
namespace nd_curves {
namespace ndcurves {
/// \brief An inverse kinematics architecture enforcing an arbitrary number of strict priority levels (Reference : Boulic et Al. 2003)
template <typename _Matrix_Type_>
void PseudoInverse(_Matrix_Type_& pinvmat) {
......@@ -50,5 +50,5 @@ Matrix3 skew(const Point& x) {
static const double MARGIN(0.001);
} // namespace nd_curves
} // namespace ndcurves
#endif //_SPLINEMATH
......@@ -17,7 +17,7 @@
#include <vector>
#include <stdexcept>
namespace nd_curves {
namespace ndcurves {
/// \brief Computes a binomial coefficient .
/// \param n : an unsigned integer.
/// \param k : an unsigned integer.
......@@ -54,8 +54,8 @@ struct Bern {
/// \param other : the other Bernstein polynomial to check.
/// \return true if the two Bernstein polynomials are approximately equals.
virtual bool operator==(const Bern& other) const {
return nd_curves::isApprox<Numeric>(m_minus_i, other.m_minus_i) && nd_curves::isApprox<Numeric>(i_, other.i_) &&
nd_curves::isApprox<Numeric>(bin_m_i_, other.bin_m_i_);
return ndcurves::isApprox<Numeric>(m_minus_i, other.m_minus_i) && ndcurves::isApprox<Numeric>(i_, other.i_) &&
ndcurves::isApprox<Numeric>(bin_m_i_, other.bin_m_i_);
}
/// \brief Check if actual Bernstein polynomial and other are different.
......@@ -92,8 +92,8 @@ std::vector<Bern<Numeric> > makeBernstein(const unsigned int n) {
}
return res;
}
} // namespace nd_curves
} // namespace ndcurves
DEFINE_CLASS_TEMPLATE_VERSION(typename Numeric, nd_curves::Bern<Numeric>)
DEFINE_CLASS_TEMPLATE_VERSION(typename Numeric, ndcurves::Bern<Numeric>)
#endif //_CLASS_BERNSTEIN
......@@ -22,7 +22,7 @@
#include <iostream>
namespace nd_curves {
namespace ndcurves {
/// \class BezierCurve.
/// \brief Represents a Bezier curve of arbitrary dimension and order.
/// For degree lesser than 4, the evaluation is analitycal. Otherwise
......@@ -68,7 +68,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Safe, Point> {
mult_T_(mult_T),
size_(std::distance(PointsBegin, PointsEnd)),
degree_(size_ - 1),
bernstein_(nd_curves::makeBernstein<num_t>((unsigned int)degree_))
bernstein_(ndcurves::makeBernstein<num_t>((unsigned int)degree_))
{
if (bernstein_.size() != size_) {
throw std::invalid_argument("Invalid size of polynomial");
......@@ -103,7 +103,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Safe, Point> {
mult_T_(mult_T),
size_(std::distance(PointsBegin, PointsEnd) + 4),
degree_(size_ - 1),
bernstein_(nd_curves::makeBernstein<num_t>((unsigned int)degree_))
bernstein_(ndcurves::makeBernstein<num_t>((unsigned int)degree_))
{
if (Safe && (size_ < 1 || T_max_ <= T_min_)) {
throw std::invalid_argument("can't create bezier min bound is higher than max bound");
......@@ -156,9 +156,9 @@ struct bezier_curve : public curve_abc<Time, Numeric, Safe, Point> {
* @return true if the two curves are approximately equals
*/
bool isApprox(const bezier_curve_t& other, const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision()) const {
bool equal = nd_curves::isApprox<num_t>(T_min_, other.min()) && nd_curves::isApprox<num_t>(T_max_, other.max()) &&
bool equal = ndcurves::isApprox<num_t>(T_min_, other.min()) && ndcurves::isApprox<num_t>(T_max_, other.max()) &&
dim_ == other.dim() && degree_ == other.degree() && size_ == other.size_ &&
nd_curves::isApprox<Numeric>(mult_T_, other.mult_T_) && bernstein_ == other.bernstein_;
ndcurves::isApprox<Numeric>(mult_T_, other.mult_T_) && bernstein_ == other.bernstein_;
if (!equal) return false;
for (size_t i = 0; i < size_; ++i) {
if (!control_points_.at(i).isApprox(other.control_points_.at(i), prec)) return false;
......@@ -471,7 +471,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Safe, Point> {
n_ij = bin(n,i-j);
mn_i = bin(m+n,i);
num_t mul = num_t(mj*n_ij) / num_t(mn_i);
current_point += mul*nd_curves::cross(waypointAtIndex(j), g.waypointAtIndex(i-j));
current_point += mul*ndcurves::cross(waypointAtIndex(j), g.waypointAtIndex(i-j));
}
new_waypoints.push_back(current_point);
}
......@@ -492,7 +492,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Safe, Point> {
throw std::invalid_argument("Can't perform cross product on Bezier curves with dimensions != 3 ");
t_point_t new_waypoints;
for(typename t_point_t::const_iterator cit = waypoints().begin(); cit != waypoints().end(); ++cit){
new_waypoints.push_back(nd_curves::cross(*cit, point));
new_waypoints.push_back(ndcurves::cross(*cit, point));
}
return bezier_curve_t(new_waypoints.begin(),new_waypoints.end(),min(),max(),mult_T_);
}
......@@ -728,9 +728,9 @@ bezier_curve<T,N,S,P> operator*(const double k, const bezier_curve<T,N,S,P>& p1)
return res*=k;
}
} // namespace nd_curves
} // namespace ndcurves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point),
SINGLE_ARG(nd_curves::bezier_curve<Time, Numeric, Safe, Point>))
SINGLE_ARG(ndcurves::bezier_curve<Time, Numeric, Safe, Point>))
#endif //_CLASS_BEZIERCURVE
......@@ -11,7 +11,7 @@
#include "curve_abc.h"
namespace nd_curves {
namespace ndcurves {
/// \class constant_curve.
/// \brief Represents a constant_curve curve, always returning the same value and a null derivative
///
......@@ -115,7 +115,7 @@ struct constant_curve : public curve_abc<Time, Numeric, Safe, Point, Point_deriv
*/
virtual bool isApprox(const constant_curve_t& other,
const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision()) const {
return nd_curves::isApprox<num_t>(T_min_, other.min()) && nd_curves::isApprox<num_t>(T_max_, other.max()) &&
return ndcurves::isApprox<num_t>(T_min_, other.min()) && ndcurves::isApprox<num_t>(T_max_, other.max()) &&
dim_ == other.dim() && value_.isApprox(other.value_, prec);
}
......@@ -169,9 +169,9 @@ struct constant_curve : public curve_abc<Time, Numeric, Safe, Point, Point_deriv
}
}; // struct constant_curve
} // namespace nd_curves
} // namespace ndcurves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point, typename Point_derivate),
SINGLE_ARG(nd_curves::constant_curve<Time, Numeric, Safe, Point, Point_derivate>))
SINGLE_ARG(ndcurves::constant_curve<Time, Numeric, Safe, Point, Point_derivate>))
#endif // _CLASS_CONSTANTCURVE
......@@ -8,9 +8,9 @@
#ifndef _CLASS_CROSSIMP
#define _CLASS_CROSSIMP
#include "nd_curves/fwd.h"
#include "ndcurves/fwd.h"
namespace nd_curves {
namespace ndcurves {
inline
Eigen::Vector3d cross(const Eigen::VectorXd& a, const Eigen::VectorXd& b){
Eigen::Vector3d c;
......@@ -32,5 +32,5 @@ template<typename N, bool S>
linear_variable<N,S> cross(const linear_variable<N,S>& a, const linear_variable<N,S>& b){
return a.cross(b);
}
} // namespace nd_curves
} // namespace ndcurves
#endif //_CLASS_CROSSIMP
......@@ -21,7 +21,7 @@
#include <boost/serialization/utility.hpp> // To serialize std::pair
namespace nd_curves {
namespace ndcurves {
/// \class CubicHermiteSpline.
/// \brief Represents a set of cubic hermite splines defining a continuous function \f$p(t)\f$.
/// A hermite cubic spline is a minimal degree polynom interpolating a function in two
......@@ -118,7 +118,7 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Safe, Point> {
*/
bool isApprox(const cubic_hermite_spline_t& other,
const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision()) const {
bool equal = nd_curves::isApprox<num_t>(T_min_, other.min()) && nd_curves::isApprox<num_t>(T_max_, other.max()) &&
bool equal = ndcurves::isApprox<num_t>(T_min_, other.min()) && ndcurves::isApprox<num_t>(T_max_, other.max()) &&
dim_ == other.dim() && degree_ == other.degree() && size_ == other.size() &&
time_control_points_ == other.time_control_points_ && duration_splines_ == other.duration_splines_;
if (!equal) return false;
......@@ -366,8 +366,8 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Safe, Point> {
ar& boost::serialization::make_nvp("degree", degree_);
}
}; // End struct Cubic hermite spline
} // namespace nd_curves
} // namespace ndcurves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point),
SINGLE_ARG(nd_curves::cubic_hermite_spline<Time, Numeric, Safe, Point>))
SINGLE_ARG(ndcurves::cubic_hermite_spline<Time, Numeric, Safe, Point>))
#endif //_CLASS_CUBICHERMITESPLINE
......@@ -19,7 +19,7 @@
#include <boost/smart_ptr/shared_ptr.hpp>
#include <functional>
namespace nd_curves {
namespace ndcurves {
template <typename T>
bool isApprox(const T a, const T b, const T eps = 1e-6) {
......@@ -76,7 +76,7 @@ struct curve_abc : std::unary_function<Time, Point>, public serialization::Seria
*/
bool isEquivalent(const curve_t* other, const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision(),
const size_t order = 5) const {
bool equal = nd_curves::isApprox<num_t>(min(), other->min()) && nd_curves::isApprox<num_t>(max(), other->max()) &&
bool equal = ndcurves::isApprox<num_t>(min(), other->min()) && ndcurves::isApprox<num_t>(max(), other->max()) &&
(dim() == other->dim());
if (!equal) {
return false;
......@@ -144,8 +144,8 @@ struct curve_abc : std::unary_function<Time, Point>, public serialization::Seria
}
};
BOOST_SERIALIZATION_ASSUME_ABSTRACT(curve_abc)
} // namespace nd_curves
} // namespace ndcurves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point, typename Point_derivate),
SINGLE_ARG(nd_curves::curve_abc<Time, Numeric, Safe, Point, Point_derivate>))
SINGLE_ARG(ndcurves::curve_abc<Time, Numeric, Safe, Point, Point_derivate>))
#endif //_STRUCT_CURVE_ABC
......@@ -17,7 +17,7 @@
#include <functional>
#include <vector>
namespace nd_curves {
namespace ndcurves {
template <typename Point>
struct curve_constraints : serialization::Serializable {
typedef Point point_t;
......@@ -83,5 +83,5 @@ struct curve_constraints : serialization::Serializable {
ar& boost::serialization::make_nvp("dim", dim_);
}
};
} // namespace nd_curves
} // namespace ndcurves
#endif //_CLASS_CUBICZEROVELACC
......@@ -12,7 +12,7 @@
#include <iostream>
namespace nd_curves {
namespace ndcurves {
/// \brief Converts a cubic hermite spline or a bezier curve to a polynomial.
/// \param curve : the bezier curve/cubic hermite spline defined between [Tmin,Tmax] to convert.
/// \return the equivalent polynomial.
......@@ -94,5 +94,5 @@ Hermite hermite_from_curve(const typename Hermite::curve_abc_t& curve) {
time_control_points.push_back(T_max);
return Hermite(control_points.begin(), control_points.end(), time_control_points);
}
} // namespace nd_curves
} // namespace ndcurves
#endif //_CLASS_CURVE_CONVERSION
......@@ -29,7 +29,7 @@
#include <functional>
#include <vector>
namespace nd_curves {
namespace ndcurves {
/// \class ExactCubic.
/// \brief Represents a set of cubic splines defining a continuous function
/// crossing each of the waypoint given in its initialization.
......@@ -308,9 +308,9 @@ struct exact_cubic : public piecewise_curve<Time, Numeric, Safe, Point> {
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(piecewise_curve_t);
}
};
} // namespace nd_curves
} // namespace ndcurves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point,
typename T_Point, typename SplineBase),
SINGLE_ARG(nd_curves::exact_cubic<Time, Numeric, Safe, Point, T_Point, SplineBase>))
SINGLE_ARG(ndcurves::exact_cubic<Time, Numeric, Safe, Point, T_Point, SplineBase>))
#endif //_CLASS_EXACTCUBIC
......@@ -13,7 +13,7 @@
#include <vector>
#include <boost/smart_ptr/shared_ptr.hpp>
namespace nd_curves {
namespace ndcurves {
template <typename Time, typename Numeric, bool Safe, typename Point, typename Point_derivate>
struct curve_abc;
......@@ -107,6 +107,6 @@ typedef SO3Linear<double, double, true> SO3Linear_t;
typedef SE3Curve<double, double, true> SE3Curve_t;
typedef piecewise_curve<double, double, true, transform_t, point6_t, curve_SE3_t> piecewise_SE3_t;
} // namespace nd_curves
} // namespace ndcurves
#endif // CURVES_FWD_H
......@@ -19,9 +19,9 @@
#ifndef _CLASS_EFFECTORSPLINE
#define _CLASS_EFFECTORSPLINE
#include "nd_curves/exact_cubic.h"
#include "ndcurves/exact_cubic.h"
namespace nd_curves {
namespace ndcurves {
namespace helpers {
typedef double Numeric;
typedef double Time;
......@@ -111,5 +111,5 @@ exact_cubic_t* effector_spline(In wayPointsBegin, In wayPointsEnd, const Point&
return new exact_cubic_t(splines);
}
} // namespace helpers
} // namespace nd_curves
} // namespace ndcurves
#endif //_CLASS_EFFECTORSPLINE
......@@ -19,11 +19,11 @@
#ifndef _CLASS_EFFECTOR_SPLINE_ROTATION
#define _CLASS_EFFECTOR_SPLINE_ROTATION
#include "nd_curves/helpers/effector_spline.h"
#include "nd_curves/curve_abc.h"
#include "ndcurves/helpers/effector_spline.h"
#include "ndcurves/curve_abc.h"
#include <Eigen/Geometry>
namespace nd_curves {
namespace ndcurves {
namespace helpers {
typedef Eigen::Matrix<Numeric, 4, 1> quat_t;
typedef Eigen::Ref<quat_t> quat_ref_t;
......@@ -82,7 +82,7 @@ class rotation_spline : public curve_abc_quat_t {
*/
bool isApprox(const rotation_spline& other,
const Numeric prec = Eigen::NumTraits<Numeric>::dummy_precision()) const {
return nd_curves::isApprox<Numeric>(min_, other.min_) && nd_curves::isApprox<Numeric>(max_, other.max_) &&
return ndcurves::isApprox<Numeric>(min_, other.min_) && ndcurves::isApprox<Numeric>(max_, other.max_) &&
dim_ == other.dim_ && quat_from_.isApprox(other.quat_from_, prec) &&
quat_to_.isApprox(other.quat_to_, prec) && time_reparam_.isApprox(other.time_reparam_, prec);
}
......@@ -288,5 +288,5 @@ class effector_spline_rotation {
}; // End class effector_spline_rotation
} // namespace helpers
} // namespace nd_curves
} // namespace ndcurves
#endif //_CLASS_EFFECTOR_SPLINE_ROTATION
......@@ -21,7 +21,7 @@
#include <Eigen/Core>
#include <stdexcept>
namespace nd_curves {
namespace ndcurves {
template <typename Numeric = double, bool Safe = true>
struct linear_variable : public serialization::Serializable {
typedef Eigen::Matrix<Numeric, Eigen::Dynamic, 1> vector_x_t;
......@@ -116,7 +116,7 @@ struct linear_variable : public serialization::Serializable {
// (B1 x + c1) X (B2 x + c2) = (-c2X B1) x + (bX B2) x + b1Xb2
typename linear_variable_t::matrix_3_t newB = skew<typename linear_variable_t::matrix_3_t, typename linear_variable_t::vector_3_t>(-other.c()) * B() +
skew<typename linear_variable_t::matrix_3_t, typename linear_variable_t::vector_3_t>(c()) * other.B();
typename linear_variable_t::vector_3_t newC = nd_curves::cross(c(),other.c());
typename linear_variable_t::vector_3_t newC = ndcurves::cross(c(),other.c());
return linear_variable_t(newB,newC);
}
......@@ -226,8 +226,8 @@ std::ostream &operator<<(std::ostream &os, const linear_variable<N, S>& l) {
return os << "linear_variable: \n \t B:\n"<< l.B() << "\t c: \n" << l.c().transpose();
}
} // namespace nd_curves
} // namespace ndcurves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Numeric, bool Safe),
SINGLE_ARG(nd_curves::linear_variable<Numeric, Safe>))
SINGLE_ARG(ndcurves::linear_variable<Numeric, Safe>))
#endif //_CLASS_LINEAR_VARIABLE
......@@ -9,12 +9,12 @@
#ifndef _CLASS_DEFINITIONS_H
#define _CLASS_DEFINITIONS_H
#include <nd_curves/bezier_curve.h>
#include <nd_curves/linear_variable.h>
#include <nd_curves/quadratic_variable.h>
#include <nd_curves/curve_constraint.h>
#include <ndcurves/bezier_curve.h>
#include <ndcurves/linear_variable.h>
#include <ndcurves/quadratic_variable.h>
#include <ndcurves/curve_constraint.h>
namespace nd_curves {
namespace ndcurves {
namespace optimization {
enum constraint_flag {
......@@ -81,5 +81,5 @@ struct problem_definition : public curve_constraints<Point> {
};
} // namespace optimization
} // namespace nd_curves
} // namespace ndcurves
#endif //_CLASS_DEFINITIONS_H
......@@ -9,13 +9,13 @@
#ifndef _CLASS_LINEAR_PROBLEM_DETAILS
#define _CLASS_LINEAR_PROBLEM_DETAILS
#include <nd_curves/bezier_curve.h>
#include <nd_curves/linear_variable.h>
#include <nd_curves/curve_constraint.h>
#include <nd_curves/optimization/definitions.h>
#include <nd_curves/bernstein.h>
#include <ndcurves/bezier_curve.h>
#include <ndcurves/linear_variable.h>
#include <ndcurves/curve_constraint.h>
#include <ndcurves/optimization/definitions.h>
#include <ndcurves/bernstein.h>
namespace nd_curves {
namespace ndcurves {
namespace optimization {
template <typename Point, typename Numeric, bool Safe = true>
struct problem_data {
......@@ -338,5 +338,5 @@ inline constraint_flag& operator^=(constraint_flag& a, constraint_flag b) {
}
} // namespace optimization
} // namespace nd_curves
} // namespace ndcurves
#endif //_CLASS_LINEAR_PROBLEM_DETAILS
......@@ -9,12 +9,12 @@
#ifndef _CLASS_QUADRATIC_COST
#define _CLASS_QUADRATIC_COST
#include "nd_curves/optimization/definitions.h"
#include "nd_curves/optimization/details.h"
#include "ndcurves/optimization/definitions.h"
#include "ndcurves/optimization/details.h"
#include <Eigen/Core>
namespace nd_curves {
namespace ndcurves {
namespace optimization {
enum integral_cost_flag {
......@@ -47,5 +47,5 @@ quadratic_variable<Numeric> compute_integral_cost(const problem_data<Point, Nume
}
} // namespace optimization
} // namespace nd_curves
} // namespace ndcurves
#endif //_CLASS_QUADRATIC_COST
......@@ -9,13 +9,13 @@
#ifndef _CLASS_LINEAR_PROBLEM
#define _CLASS_LINEAR_PROBLEM
#include "nd_curves/optimization/definitions.h"
#include "nd_curves/optimization/details.h"
#include "nd_curves/optimization/integral_cost.h"
#include "ndcurves/optimization/definitions.h"
#include "ndcurves/optimization/details.h"
#include "ndcurves/optimization/integral_cost.h"
#include <Eigen/Core>
namespace nd_curves {
namespace ndcurves {
namespace optimization {
template <typename Point, typename Numeric, bool Safe>
......@@ -38,5 +38,5 @@ quadratic_problem<Point, Numeric> generate_problem(const problem_definition<Poin
return prob;
}
} // namespace optimization
} // namespace nd_curves
} // namespace ndcurves
#endif //_CLASS_LINEAR_PROBLEM
......@@ -15,7 +15,7 @@
#include <fstream>
#include <sstream>
namespace nd_curves {
namespace ndcurves {
/// \class PiecewiseCurve.
/// \brief Represent a piecewise curve. We can add some new curve,
/// but the starting time of the curve to add should be equal to the ending time of the actual
......@@ -601,10 +601,10 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point, Point_deri
ar& boost::serialization::make_nvp("T_max", T_max_);
}
}; // End struct piecewise curve
} // namespace nd_curves
} // namespace ndcurves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point,
typename Point_derivate, typename CurveType),
SINGLE_ARG(nd_curves::piecewise_curve<Time, Numeric, Safe, Point, Point_derivate, CurveType>))
SINGLE_ARG(ndcurves::piecewise_curve<Time, Numeric, Safe, Point, Point_derivate, CurveType>))
#endif // _CLASS_PIECEWISE_CURVE
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment