KrisLibrary  1.0.0
GeneralizedBezierCurve.h
1 #ifndef GENERALIZED_BEZIER_CURVE_H
2 #define GENERALIZED_BEZIER_CURVE_H
3 
4 #include "CSpace.h"
5 #include "GeodesicSpace.h"
6 #include <iosfwd>
7 #include <vector>
8 
17 {
18  public:
19  GeneralizedCubicBezierCurve(CSpace* space=NULL,GeodesicSpace* manifold=NULL);
21  void Eval(Real u,Config& x) const;
23  void Deriv(Real u,Config& dx) const;
25  void Accel(Real u,Config& ddx) const;
27  Real OuterLength() const;
28 
30  void GetBounds(Vector& xmin,Vector& xmax) const;
31  void GetDerivBounds(Vector& vmin,Vector& vmax,Vector& amin,Vector& amax) const;
32  void GetDerivBounds(Real u1,Real u2,Vector& vmin,Vector& vmax,Vector& amin,Vector& amax) const;
33 
35  void SetSmoothTangents(const Config* prev=NULL,const Config* next=NULL);
39  void SetSmoothTangents(const Config* prev,const Config* next,Real dtprev,Real dtnext);
42  void SetNaturalTangents(const Vector& dx0,const Vector& dx1);
43 
45  void Midpoint(Vector& x) const;
46  void MidpointDeriv(Vector& v) const;
47  void MidpointTimeDeriv(Real duration,Vector& v) const;
48 
52 
53  CSpace* space;
54  GeodesicSpace* manifold;
55  Config x0,x1,x2,x3;
56 };
57 
58 
63 {
64 public:
65  int ParamToSegment(Real u,Real* segparam=NULL) const;
66  int Eval(Real u,Vector& x) const;
67  int Deriv(Real u,Vector& dx) const;
68  int Accel(Real u,Vector& ddx) const;
69  Real TotalTime() const;
70  const Config& Start() const { return segments.front().x0; }
71  const Config& End() const { return segments.back().x3; }
72  void Append(const GeneralizedCubicBezierCurve& seg,Real duration);
73  void Concat(const GeneralizedCubicBezierSpline& s);
74  void TimeScale(Real scale);
75  //gets the piecewise linear path corresponding to each segment endpoint
76  void GetPiecewiseLinear(std::vector<Real>& times,std::vector<Config>& milestones) const;
77  //bisects every segment (O(n) cost)
78  void Bisect();
79  //bisects one segment at the parameter u (O(n-seg) cost)
80  void Bisect(int seg,Real u=0.5);
81  bool Save(std::ostream& out) const;
82  bool Load(std::istream& in);
83 
84  std::vector<GeneralizedCubicBezierCurve> segments;
85  std::vector<Real> durations;
86 };
87 
88 #endif
A space with geodesics and (optionally) geodesic derivatives.
Definition: GeodesicSpace.h:31
void GetBounds(Vector &xmin, Vector &xmax) const
These work only with cartesian spaces.
Definition: GeneralizedBezierCurve.cpp:298
Vector Config
an alias for Vector
Definition: RobotKinematics3D.h:14
Motion planning configuration space base class. The configuration space implements an interpolation s...
Definition: CSpace.h:39
A generalized Bezier curve that uses the CSpace&#39;s Interpolate routine to generate the smooth interpol...
Definition: GeneralizedBezierCurve.h:16
void Eval(Real u, Config &x) const
Evaluate the bezizer curve at point u.
Definition: GeneralizedBezierCurve.cpp:147
Real OuterLength() const
Evaluates the length of the "frame" from x0->x1->x2->x3.
Definition: GeneralizedBezierCurve.cpp:405
void Accel(Real u, Config &ddx) const
Only works properly if the space is cartesian.
Definition: GeneralizedBezierCurve.cpp:265
A Bezier spline with segment durations.
Definition: GeneralizedBezierCurve.h:62
void SetSmoothTangents(const Config *prev=NULL, const Config *next=NULL)
Helper: sets x1 and x2 to smoothly interpolate from previous/next configs.
Definition: GeneralizedBezierCurve.cpp:58
void Deriv(Real u, Config &dx) const
Only works properly if the space is cartesian or manifold is set.
Definition: GeneralizedBezierCurve.cpp:193
A vector over the field T.
Definition: function.h:9
void SetNaturalTangents(const Vector &dx0, const Vector &dx1)
Definition: GeneralizedBezierCurve.cpp:11
void Midpoint(Vector &x) const
These may be slightly cheaper than Eval(0.5) and Deriv(0.5) for cartesian spaces. ...
Definition: GeneralizedBezierCurve.cpp:413
void Bisect(GeneralizedCubicBezierCurve &c1, GeneralizedCubicBezierCurve &c2) const
Definition: GeneralizedBezierCurve.cpp:439