Aikido
aikido::common::StepSequence Class Reference

An iterator that returns a sequence of numbers between start point and end point stepping at a fixed stepsize. More...

#include <aikido/common/StepSequence.hpp>

Classes

class  const_iterator
 

Public Member Functions

 StepSequence (double stepSize, bool includeStartpoint=true, bool includeEndpoint=true, double startPoint=0.0, double endPoint=1.0)
 Constructor. More...
 
 StepSequence (double startPoint, double endPoint, std::size_t numSteps, bool includeEndpoint=true)
 Constructs StepSequence in Matlab's linspace() style. More...
 
const_iterator begin () const
 Returns an iterator to the first element of the sequence. More...
 
const_iterator end () const
 Returns an iterator to the element following the last element of the sequence. More...
 
double operator[] (std::size_t n) const
 Returns the n-th element of the sequence. More...
 
std::size_t getLength () const
 Returns the total length of sequence. More...
 

Private Member Functions

void updateNumSteps ()
 Computes the total length of sequence given step size. More...
 
void updateStepSize ()
 Computes the step size of sequence given number of steps. More...
 

Private Attributes

double mStepSize
 Step size increments from the start point to the end point. More...
 
const bool mIncludeStartPoint
 Whether the start point in the sequence will be the start point. More...
 
const bool mIncludeEndPoint
 Whether the end point in the sequence will be the end point. More...
 
const double mStartPoint
 The start point that defines the sequence. More...
 
const double mEndPoint
 The end point that defines the sequence. More...
 
std::size_t mNumSteps
 The total length of sequence. More...
 

Detailed Description

An iterator that returns a sequence of numbers between start point and end point stepping at a fixed stepsize.

Constructor & Destructor Documentation

◆ StepSequence() [1/2]

aikido::common::StepSequence::StepSequence ( double  stepSize,
bool  includeStartpoint = true,
bool  includeEndpoint = true,
double  startPoint = 0.0,
double  endPoint = 1.0 
)

Constructor.

Parameters
stepSizeStep size increments from the start point to the end point.
includeStartpointIf includeStartpoint is true then the start point in the sequence will be the start point; else the start point in the sequence will be the start point plus the stepSize (if it is larger than the end point, it will be the end point.
includeEndpointIf includeEndpoint is true then the final point in the sequence will be the end point, even if it is at less than stepSize from the second to last point.
startPointThe start point that defines the sequence.
endPointThe end point that defines the sequence.

◆ StepSequence() [2/2]

aikido::common::StepSequence::StepSequence ( double  startPoint,
double  endPoint,
std::size_t  numSteps,
bool  includeEndpoint = true 
)

Constructs StepSequence in Matlab's linspace() style.

Member Function Documentation

◆ begin()

const_iterator aikido::common::StepSequence::begin ( ) const

Returns an iterator to the first element of the sequence.

Returns
Iterator to the first element of the sequence.

◆ end()

const_iterator aikido::common::StepSequence::end ( ) const

Returns an iterator to the element following the last element of the sequence.

Returns
Iterator followin the last element of the sequence.

◆ getLength()

std::size_t aikido::common::StepSequence::getLength ( ) const

Returns the total length of sequence.

Returns
Non-negative number of the tatal length of sequence.

◆ operator[]()

double aikido::common::StepSequence::operator[] ( std::size_t  n) const

Returns the n-th element of the sequence.

Returns
Element in the sequence.

◆ updateNumSteps()

void aikido::common::StepSequence::updateNumSteps ( )
private

Computes the total length of sequence given step size.

This is only called in the contructor.

◆ updateStepSize()

void aikido::common::StepSequence::updateStepSize ( )
private

Computes the step size of sequence given number of steps.

This is only called in the contructor.

Member Data Documentation

◆ mEndPoint

const double aikido::common::StepSequence::mEndPoint
private

The end point that defines the sequence.

◆ mIncludeEndPoint

const bool aikido::common::StepSequence::mIncludeEndPoint
private

Whether the end point in the sequence will be the end point.

◆ mIncludeStartPoint

const bool aikido::common::StepSequence::mIncludeStartPoint
private

Whether the start point in the sequence will be the start point.

◆ mNumSteps

std::size_t aikido::common::StepSequence::mNumSteps
private

The total length of sequence.

◆ mStartPoint

const double aikido::common::StepSequence::mStartPoint
private

The start point that defines the sequence.

◆ mStepSize

double aikido::common::StepSequence::mStepSize
private

Step size increments from the start point to the end point.