codac 1.5.6
Loading...
Searching...
No Matches
codac::TrajectoryVector Class Reference

n-dimensional trajectory \(\mathbf{x}(\cdot)\), defined as a temporal map of vector values More...

#include <codac_TrajectoryVector.h>

Inheritance diagram for codac::TrajectoryVector:
Collaboration diagram for codac::TrajectoryVector:

Public Member Functions

Definition
 TrajectoryVector (int n)
 Creates a n-dimensional trajectory \(\mathbf{x}(\cdot)\).
 
 TrajectoryVector (const Interval &tdomain, const TFunction &f)
 Creates a n-dimensional trajectory \(\mathbf{x}(\cdot)\) from an analytic expression.
 
 TrajectoryVector (const Interval &tdomain, const TFunction &f, double timestep)
 Creates a n-dimensional trajectory \(\mathbf{x}(\cdot)\) from an analytic expression, and transforms it as a map of values (sampling procedure)
 
 TrajectoryVector (const std::map< double, Vector > &m_map_values)
 Creates a n-dimensional trajectory \(\mathbf{x}(\cdot)\) from a map of vector values.
 
 TrajectoryVector (const std::vector< std::map< double, double > > &v_map_values)
 Creates a n-dimensional trajectory \(\mathbf{x}(\cdot)\) from a vector of maps of scalar values.
 
 TrajectoryVector (const std::list< double > &list_t, const std::list< Vector > &list_x)
 Creates a n-dimensional trajectory \(\mathbf{x}(\cdot)\) from a list of vector values.
 
 TrajectoryVector (std::initializer_list< Trajectory > list)
 Creates a n-dimensional trajectory \(\mathbf{x}(\cdot)\) from a list of Trajectory objects.
 
 TrajectoryVector (const TrajectoryVector &traj)
 Creates a copy of a n-dimensional trajectory \(\mathbf{x}(\cdot)\).
 
 TrajectoryVector (int n, const Trajectory &x)
 Creates a n-dimensional trajectory with all the components initialized to \(x(\cdot)\).
 
 ~TrajectoryVector ()
 TrajectoryVector destructor.
 
const TrajectoryVectoroperator= (const TrajectoryVector &x)
 Returns a copy of a TrajectoryVector.
 
int size () const
 Returns the dimension of the trajectory.
 
const Interval tdomain () const
 Returns the temporal definition domain of this trajectory.
 
void resize (int n)
 Resizes this TrajectoryVector.
 
const TrajectoryVector subvector (int start_index, int end_index) const
 Returns a subvector of this TrajectoryVector.
 
void put (int start_index, const TrajectoryVector &subvec)
 Puts a subvector into this TrajectoryVector at a given position.
 
Accessing values
const IntervalVector codomain () const
 Returns the box of feasible values.
 
Trajectoryoperator[] (int index)
 Returns the ith Trajectory of this TrajectoryVector.
 
const Trajectoryoperator[] (int index) const
 Returns a const reference to the ith Trajectory of this TrajectoryVector.
 
const Vector operator() (double t) const
 Returns the evaluation of this trajectory at \(t\).
 
const IntervalVector operator() (const Interval &t) const
 Returns the interval evaluation of this trajectory over \([t]\).
 
const Vector first_value () const
 Returns the value \(\mathbf{x}(t_0)\).
 
const Vector last_value () const
 Returns the value \(\mathbf{x}(t_f)\).
 
Tests
bool not_defined () const
 Tests whether this trajectory is defined or not.
 
bool operator== (const TrajectoryVector &x) const
 Returns true if this trajectory is equal to \(\mathbf{x}(\cdot)\).
 
bool operator!= (const TrajectoryVector &x) const
 Returns true if this trajectory is different from \(\mathbf{x}(\cdot)\).
 
Setting values
void set (const Vector &y, double t)
 Sets a value \(\mathbf{y}\) at \(t\): \(\mathbf{x}(t)=\mathbf{y}\).
 
TrajectoryVectortruncate_tdomain (const Interval &tdomain)
 Truncates the tdomain of \(\mathbf{x}(\cdot)\).
 
TrajectoryVectorshift_tdomain (double a)
 Shifts the tdomain \([t_0,t_f]\) of \(\mathbf{x}(\cdot)\).
 
bool same_tdomain_forall_components () const
 Checks whether all the Trajectory components have the same tdomain or not.
 
TrajectoryVectorsample (double timestep)
 Transforms an analytic trajectory as a map of values.
 
TrajectoryVectorsample (const Trajectory &x)
 Samples this trajectory so that it will share the same sampling of \(x(\cdot)\).
 
TrajectoryVectorsample (const TrajectoryVector &x)
 Samples this trajectory so that it will share the same sampling of \(\mathbf{x}(\cdot)\).
 
TrajectoryVectormake_continuous ()
 Makes a trajectory continuous by avoiding infinite slopes.
 
Integration
const TrajectoryVector primitive (const Vector &c) const
 Computes an approximative primitive of \(\mathbf{x}(\cdot)\).
 
const TrajectoryVector primitive (const Vector &c, double timestep) const
 Computes an approximative primitive of \(\mathbf{x}(\cdot)\) with some time discretization \(\delta\).
 
const TrajectoryVector diff () const
 Differentiates this trajectory vector.
 
Assignments operators
const TrajectoryVectoroperator+= (double x)
 Operates +=.
 
const TrajectoryVectoroperator+= (const Trajectory &x)
 Operates +=.
 
const TrajectoryVectoroperator+= (const Vector &x)
 Operates +=.
 
const TrajectoryVectoroperator+= (const TrajectoryVector &x)
 Operates +=.
 
const TrajectoryVectoroperator-= (double x)
 Operates -=.
 
const TrajectoryVectoroperator-= (const Trajectory &x)
 Operates -=.
 
const TrajectoryVectoroperator-= (const Vector &x)
 Operates -=.
 
const TrajectoryVectoroperator-= (const TrajectoryVector &x)
 Operates -=.
 
const TrajectoryVectoroperator*= (double x)
 Operates *=.
 
const TrajectoryVectoroperator*= (const Trajectory &x)
 Operates *=.
 
const TrajectoryVectoroperator/= (double x)
 Operates /=.
 
const TrajectoryVectoroperator/= (const Trajectory &x)
 Operates /=.
 
- Public Member Functions inherited from codac::DynamicalItem
virtual ~DynamicalItem ()
 DynamicalItem destructor.
 

Protected Member Functions

 TrajectoryVector ()
 Creates an undefined n-dimensional trajectory.
 
const IntervalVector codomain_box () const
 Returns the box \(\mathbf{x}([t_0,t_f])\).
 

Protected Attributes

int m_n = 0
 dimension of this trajectory
 
Trajectorym_v_trajs = nullptr
 array of components (scalar trajectories)
 

String

const std::string class_name () const
 Returns the name of this class.
 

Additional Inherited Members

- Static Public Member Functions inherited from codac::DynamicalItem
static bool valid_tdomain (const Interval &tdomain)
 Verifies that this interval is a feasible tdomain.
 

Detailed Description

n-dimensional trajectory \(\mathbf{x}(\cdot)\), defined as a temporal map of vector values

Note
Use Trajectory for the one-dimensional case

Constructor & Destructor Documentation

◆ TrajectoryVector() [1/10]

codac::TrajectoryVector::TrajectoryVector ( int n)
explicit

Creates a n-dimensional trajectory \(\mathbf{x}(\cdot)\).

Parameters
ndimension of this trajectory

◆ TrajectoryVector() [2/10]

codac::TrajectoryVector::TrajectoryVector ( const Interval & tdomain,
const TFunction & f )

Creates a n-dimensional trajectory \(\mathbf{x}(\cdot)\) from an analytic expression.

Parameters
tdomaintemporal domain \([t_0,t_f]\)
fTFunction object defining the trajectory: \(\mathbf{x}(t)=\mathbf{f}(t)\)

◆ TrajectoryVector() [3/10]

codac::TrajectoryVector::TrajectoryVector ( const Interval & tdomain,
const TFunction & f,
double timestep )

Creates a n-dimensional trajectory \(\mathbf{x}(\cdot)\) from an analytic expression, and transforms it as a map of values (sampling procedure)

Parameters
tdomaintemporal domain \([t_0,t_f]\)
fTFunction object defining the trajectory: \(\mathbf{x}(t)=\mathbf{f}(t)\)
timestepsampling value \(\delta\) for the temporal discretization (double)

◆ TrajectoryVector() [4/10]

codac::TrajectoryVector::TrajectoryVector ( const std::map< double, Vector > & m_map_values)
explicit

Creates a n-dimensional trajectory \(\mathbf{x}(\cdot)\) from a map of vector values.

Parameters
m_map_valuesmap<t,y> defining the trajectory: \(\mathbf{x}(t)=\mathbf{y}\)

◆ TrajectoryVector() [5/10]

codac::TrajectoryVector::TrajectoryVector ( const std::vector< std::map< double, double > > & v_map_values)
explicit

Creates a n-dimensional trajectory \(\mathbf{x}(\cdot)\) from a vector of maps of scalar values.

Parameters
v_map_valuesset of map<t,y> defining the trajectory: \(\mathbf{x}(t)=\mathbf{y}\)

◆ TrajectoryVector() [6/10]

codac::TrajectoryVector::TrajectoryVector ( const std::list< double > & list_t,
const std::list< Vector > & list_x )
explicit

Creates a n-dimensional trajectory \(\mathbf{x}(\cdot)\) from a list of vector values.

Values and datations are separated into two lists.

Parameters
list_tlist of time keys
list_xlist of vector values

◆ TrajectoryVector() [7/10]

codac::TrajectoryVector::TrajectoryVector ( std::initializer_list< Trajectory > list)

Creates a n-dimensional trajectory \(\mathbf{x}(\cdot)\) from a list of Trajectory objects.

Parameters
listlist of \(x_i(\cdot)\) trajectories

◆ TrajectoryVector() [8/10]

codac::TrajectoryVector::TrajectoryVector ( const TrajectoryVector & traj)

Creates a copy of a n-dimensional trajectory \(\mathbf{x}(\cdot)\).

Parameters
trajTrajectoryVector to be duplicated

◆ TrajectoryVector() [9/10]

codac::TrajectoryVector::TrajectoryVector ( int n,
const Trajectory & x )

Creates a n-dimensional trajectory with all the components initialized to \(x(\cdot)\).

Parameters
ndimension of this trajectory
xTrajectory to be copied for all the components

◆ TrajectoryVector() [10/10]

codac::TrajectoryVector::TrajectoryVector ( )
protected

Creates an undefined n-dimensional trajectory.

Note
Constructor necessary for the deserialize_TrajectoryVector method

Member Function Documentation

◆ operator=()

const TrajectoryVector & codac::TrajectoryVector::operator= ( const TrajectoryVector & x)

Returns a copy of a TrajectoryVector.

Parameters
xthe TrajectoryVector object to be copied
Returns
a new TrajectoryVector object with same values/definition

◆ size()

int codac::TrajectoryVector::size ( ) const
virtual

Returns the dimension of the trajectory.

Returns
n

Implements codac::DynamicalItem.

◆ tdomain()

const Interval codac::TrajectoryVector::tdomain ( ) const
virtual

Returns the temporal definition domain of this trajectory.

Returns
an Interval object \([t_0,t_f]\)

Implements codac::DynamicalItem.

◆ resize()

void codac::TrajectoryVector::resize ( int n)

Resizes this TrajectoryVector.

Note
If the size is increased, the existing components are not modified and the new ones are set to empty trajectories
Parameters
nthe new size to be set

◆ subvector()

const TrajectoryVector codac::TrajectoryVector::subvector ( int start_index,
int end_index ) const

Returns a subvector of this TrajectoryVector.

Parameters
start_indexfirst component index of the subvector to be returned
end_indexlast component index of the subvector to be returned
Returns
a TrajectoryVector extracted from this TrajectoryVector

◆ put()

void codac::TrajectoryVector::put ( int start_index,
const TrajectoryVector & subvec )

Puts a subvector into this TrajectoryVector at a given position.

Parameters
start_indexposition where the subvector will be put
subvecthe TrajectoryVector to put from start_index

◆ codomain()

const IntervalVector codac::TrajectoryVector::codomain ( ) const

Returns the box of feasible values.

Returns
an IntervalVector object \(\mathbf{x}([t_0,t_f])\)

◆ operator[]() [1/2]

Trajectory & codac::TrajectoryVector::operator[] ( int index)

Returns the ith Trajectory of this TrajectoryVector.

Parameters
indexthe index of this ith component
Returns
a reference to the ith component

◆ operator[]() [2/2]

const Trajectory & codac::TrajectoryVector::operator[] ( int index) const

Returns a const reference to the ith Trajectory of this TrajectoryVector.

Parameters
indexthe index of this ith component
Returns
a const reference to the ith component

◆ operator()() [1/2]

const Vector codac::TrajectoryVector::operator() ( double t) const

Returns the evaluation of this trajectory at \(t\).

Note
Be careful, if the trajectory is defined from an analytic function, then an approximation will be made (since the TFunction returns a boxed evaluation, while the expected returned value is a real here). Please use the operator(Interval(double)) for a reliable evaluation.
Parameters
tthe temporal key (double, must belong to the trajectory's tdomain)
Returns
real vector value \(\mathbf{x}(t)\)

◆ operator()() [2/2]

const IntervalVector codac::TrajectoryVector::operator() ( const Interval & t) const

Returns the interval evaluation of this trajectory over \([t]\).

Parameters
tthe subtdomain (Interval, must be a subset of the trajectory's tdomain)
Returns
IntervalVector envelope \(\mathbf{x}([t])\)

◆ first_value()

const Vector codac::TrajectoryVector::first_value ( ) const

Returns the value \(\mathbf{x}(t_0)\).

Returns
real value \(\mathbf{x}(t_0)\)

◆ last_value()

const Vector codac::TrajectoryVector::last_value ( ) const

Returns the value \(\mathbf{x}(t_f)\).

Returns
real value \(\mathbf{x}(t_f)\)

◆ not_defined()

bool codac::TrajectoryVector::not_defined ( ) const

Tests whether this trajectory is defined or not.

Returns
false in case of non-empty map, or definition from a TFunction object, true otherwise

◆ operator==()

bool codac::TrajectoryVector::operator== ( const TrajectoryVector & x) const

Returns true if this trajectory is equal to \(\mathbf{x}(\cdot)\).

Parameters
xthe TrajectoryVector object
Returns
true in case of equality

◆ operator!=()

bool codac::TrajectoryVector::operator!= ( const TrajectoryVector & x) const

Returns true if this trajectory is different from \(\mathbf{x}(\cdot)\).

Parameters
xthe TrajectoryVector object
Returns
true in case of difference

◆ set()

void codac::TrajectoryVector::set ( const Vector & y,
double t )

Sets a value \(\mathbf{y}\) at \(t\): \(\mathbf{x}(t)=\mathbf{y}\).

Parameters
ylocal vector value of the trajectory
tthe temporal key (double, must belong to the trajectory's tdomain)

◆ truncate_tdomain()

TrajectoryVector & codac::TrajectoryVector::truncate_tdomain ( const Interval & tdomain)

Truncates the tdomain of \(\mathbf{x}(\cdot)\).

Note
The new tdomain must be a subset of the old one
Parameters
tdomainnew temporal domain \([t_0,t_f]\)
Returns
a reference to this trajectory

◆ shift_tdomain()

TrajectoryVector & codac::TrajectoryVector::shift_tdomain ( double a)

Shifts the tdomain \([t_0,t_f]\) of \(\mathbf{x}(\cdot)\).

Note
If the trajectory is defined from a map of values, the key of each value will be shifted. In case of a definition from an analytic function, only the tdomain will be changed.
Parameters
athe offset value so that \([t_0,t_f]:=[t_0-a,t_f-a]\)
Returns
a reference to this trajectory

◆ same_tdomain_forall_components()

bool codac::TrajectoryVector::same_tdomain_forall_components ( ) const

Checks whether all the Trajectory components have the same tdomain or not.

Returns
true in case of temporal consistency

◆ sample() [1/3]

TrajectoryVector & codac::TrajectoryVector::sample ( double timestep)

Transforms an analytic trajectory as a map of values.

Note
Sampling only available for trajectories firstly defined as analytic functions
Parameters
timestepsampling value \(\delta\) for the temporal discretization (double)
Returns
a reference to this trajectory

◆ sample() [2/3]

TrajectoryVector & codac::TrajectoryVector::sample ( const Trajectory & x)

Samples this trajectory so that it will share the same sampling of \(x(\cdot)\).

Note
If the trajectory is defined as an analytic function, then the object is transformed into a map of values and the TFunction object is deleted.
The previous sampling of this trajectory is preserved
Parameters
xthe Trajectory from which the new sampling will come from
Returns
a reference to this trajectory

◆ sample() [3/3]

TrajectoryVector & codac::TrajectoryVector::sample ( const TrajectoryVector & x)

Samples this trajectory so that it will share the same sampling of \(\mathbf{x}(\cdot)\).

Note
If the trajectory is defined as an analytic function, then the object is transformed into a map of values and the TFunction object is deleted.
The previous sampling of this trajectory is preserved
Parameters
xthe TrajectoryVector from which the new sampling will come from
Returns
a reference to this trajectory

◆ make_continuous()

TrajectoryVector & codac::TrajectoryVector::make_continuous ( )

Makes a trajectory continuous by avoiding infinite slopes.

Note
This is mainly used when angles are expressed between \([-\pi,\pi]\), which produces troublesome discontinuities. For instance, a tube directly built from such discontinuous trajectory will be made of very large slices, inducing unwanted pessimism.
The previous sampling of this trajectory is preserved
Returns
a reference to this trajectory

◆ primitive() [1/2]

const TrajectoryVector codac::TrajectoryVector::primitive ( const Vector & c) const

Computes an approximative primitive of \(\mathbf{x}(\cdot)\).

Note
The trajectory must not be defined from an analytic function. Please use the other method with time discretization for such case.
Parameters
cthe constant of integration
Returns
a new TrajectoryVector object with the same temporal keys

◆ primitive() [2/2]

const TrajectoryVector codac::TrajectoryVector::primitive ( const Vector & c,
double timestep ) const

Computes an approximative primitive of \(\mathbf{x}(\cdot)\) with some time discretization \(\delta\).

Parameters
cthe constant of integration
timestepsampling value \(\delta\) for the temporal discretization (double)
Returns
a new TrajectoryVector object with the specified time discretization

◆ diff()

const TrajectoryVector codac::TrajectoryVector::diff ( ) const

Differentiates this trajectory vector.

Note
If the trajectory is defined from an analytic function, the exact differentiation is returned. Otherwise, from a map of values, finite differences are computed.
Returns
a derivative trajectory vector

◆ operator+=() [1/4]

const TrajectoryVector & codac::TrajectoryVector::operator+= ( double x)

Operates +=.

Parameters
xdouble
Returns
(*this)+=x

◆ operator+=() [2/4]

const TrajectoryVector & codac::TrajectoryVector::operator+= ( const Trajectory & x)

Operates +=.

Parameters
xTrajectory
Returns
(*this)+=x

◆ operator+=() [3/4]

const TrajectoryVector & codac::TrajectoryVector::operator+= ( const Vector & x)

Operates +=.

Parameters
xVector
Returns
(*this)+=x

◆ operator+=() [4/4]

const TrajectoryVector & codac::TrajectoryVector::operator+= ( const TrajectoryVector & x)

Operates +=.

Parameters
xTrajectoryVector
Returns
(*this)+=x

◆ operator-=() [1/4]

const TrajectoryVector & codac::TrajectoryVector::operator-= ( double x)

Operates -=.

Parameters
xdouble
Returns
(*this)-=x

◆ operator-=() [2/4]

const TrajectoryVector & codac::TrajectoryVector::operator-= ( const Trajectory & x)

Operates -=.

Parameters
xTrajectory
Returns
(*this)-=x

◆ operator-=() [3/4]

const TrajectoryVector & codac::TrajectoryVector::operator-= ( const Vector & x)

Operates -=.

Parameters
xVector
Returns
(*this)-=x

◆ operator-=() [4/4]

const TrajectoryVector & codac::TrajectoryVector::operator-= ( const TrajectoryVector & x)

Operates -=.

Parameters
xTrajectoryVector
Returns
(*this)-=x

◆ operator*=() [1/2]

const TrajectoryVector & codac::TrajectoryVector::operator*= ( double x)

Operates *=.

Parameters
xdouble
Returns
(this)=x

◆ operator*=() [2/2]

const TrajectoryVector & codac::TrajectoryVector::operator*= ( const Trajectory & x)

Operates *=.

Parameters
xTrajectory
Returns
(this)=x

◆ operator/=() [1/2]

const TrajectoryVector & codac::TrajectoryVector::operator/= ( double x)

Operates /=.

Parameters
xdouble
Returns
(*this)/=x

◆ operator/=() [2/2]

const TrajectoryVector & codac::TrajectoryVector::operator/= ( const Trajectory & x)

Operates /=.

Parameters
xTrajectory
Returns
(*this)/=x

◆ class_name()

const std::string codac::TrajectoryVector::class_name ( ) const
inlinevirtual

Returns the name of this class.

Note
Only used for some generic display method
Returns
the predefined name

Implements codac::DynamicalItem.

497{ return "TrajectoryVector"; };

◆ codomain_box()

const IntervalVector codac::TrajectoryVector::codomain_box ( ) const
protectedvirtual

Returns the box \(\mathbf{x}([t_0,t_f])\).

Note
Used for genericity purposes
Returns
the envelope of codomain values

Implements codac::DynamicalItem.


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