KrisLibrary  1.0.0
Public Types | Public Member Functions | Public Attributes | List of all members
Spline::PiecewisePolynomial Class Reference

#include <PiecewisePolynomial.h>

Public Types

typedef Polynomial< double > Poly
 

Public Member Functions

 PiecewisePolynomial (const Poly &p, double a, double b)
 
 PiecewisePolynomial (const std::vector< Poly > &_segments, const std::vector< double > &_times, bool relative=false)
 
 PiecewisePolynomial (const std::vector< Poly > &_segments, const std::vector< double > &_times, const std::vector< double > &_timeShifts)
 
int FindSegment (double t) const
 
double Evaluate (double t) const
 
double Derivative (double t) const
 
double Derivative (double t, int n) const
 
double operator() (double t) const
 
PiecewisePolynomial Differentiate (int n=1) const
 
double Start () const
 
double End () const
 
double StartTime () const
 
double EndTime () const
 
void Append (const Poly &p, double t, bool relative=false)
 
void Concat (const PiecewisePolynomial &traj, bool relative=false)
 
void TimeShift (double dt)
 
void ZeroTimeShift ()
 
void Split (double t, PiecewisePolynomial &front, PiecewisePolynomial &back) const
 
void TrimFront (double tstart)
 
void TrimBack (double tend)
 
PiecewisePolynomial Select (double a, double b) const
 
std::pair< double, double > MaxDiscontinuity (int derivative=0) const
 
bool Read (File &f)
 
bool Write (File &f) const
 
void operator+= (double val)
 
void operator-= (double val)
 
void operator*= (double val)
 
void operator/= (double val)
 
void operator+= (const Polynomial< double > &b)
 
void operator-= (const Polynomial< double > &b)
 
void operator*= (const Polynomial< double > &b)
 

Public Attributes

std::vector< Polysegments
 
std::vector< double > timeShift
 
std::vector< double > times
 

Detailed Description

A trajectory y(t) consisting of a set of trajectory segments segments[], split among times times[]. segments[i] is defined over the interval Ii = [times[i],times[i+1]).

The timeShift member is defined to allow a difference between the segment's "local" time versus the "global" time of the overall polynomial. More precisely, over interval Ii, we define:

   y(t)=segments[i](t-timeShift[i])

And the segment's local time is defined over the domain [times[i]-timeShift[i],times[i+1]-timeShift[i]).

Member Function Documentation

void Spline::PiecewisePolynomial::Append ( const Poly p,
double  t,
bool  relative = false 
)

Appends the segment to the trajectory following the final segment in the trajectory.

If relative is true, then T is interpreted as the total length of the segment, and segment(t) is defined on [0,T].

If relative is false, then T is interpreted as the final time of the segment, and segment(t) is defined on [self.endTime(),T]

void Spline::PiecewisePolynomial::Concat ( const PiecewisePolynomial traj,
bool  relative = false 
)

Appends traj to the current trajectory. If relative=true, the domain of traj is shifted forward in time by EndTime() before concatenating

References TimeShift().

Referenced by Split(), TrimBack(), and TrimFront().

std::pair< double, double > Spline::PiecewisePolynomial::MaxDiscontinuity ( int  derivative = 0) const

Computes the maximum discontinuity of the i'th derivative. Return value is the time and absolute magnitude of the maximum discontinuity.

References ReadFile(), Split(), TimeShift(), TrimBack(), TrimFront(), and WriteFile().

PiecewisePolynomial Spline::PiecewisePolynomial::Select ( double  a,
double  b 
) const

Selects a range

References TrimBack(), and TrimFront().

void Spline::PiecewisePolynomial::Split ( double  t,
PiecewisePolynomial front,
PiecewisePolynomial back 
) const

Splits the trajectory in two pieces

References Concat().

Referenced by MaxDiscontinuity().

void Spline::PiecewisePolynomial::TimeShift ( double  dt)

Moves time forward by dt

Referenced by Concat(), and MaxDiscontinuity().

void Spline::PiecewisePolynomial::TrimBack ( double  tend)

Sets a new end time tend

References Concat().

Referenced by MaxDiscontinuity(), and Select().

void Spline::PiecewisePolynomial::TrimFront ( double  tstart)

Sets a new start time tstart

References Concat().

Referenced by MaxDiscontinuity(), and Select().

void Spline::PiecewisePolynomial::ZeroTimeShift ( )

Changes the local time domain of every segment to be defined with timeShift 0.


The documentation for this class was generated from the following files: