My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
gcp::util::QuadraticInterpolator Class Reference

#include <QuadraticInterpolator.h>

Inheritance diagram for gcp::util::QuadraticInterpolator:
gcp::util::QuadraticInterpolatorNormal gcp::util::QuadraticInterpolatorPositiveAngle gcp::util::QuadraticInterpolatorSignedAngle

Public Types

enum  QuadType { QP_NORMAL, QP_SIGNED_ANGLE, QP_POSITIVE_ANGLE }
 

Public Member Functions

virtual ~QuadraticInterpolator ()
 
void empty ()
 
void extend (double x, double y)
 
double evaluate (double x)
 
double gradient (double x)
 
void lock ()
 
void unlock ()
 
bool tryLock ()
 
bool canBracket (double x)
 
unsigned getNpt ()
 
double getXmin ()
 
double getXmax ()
 

Static Public Attributes

static const double pi_ = 3.1415926535897932384626433832795028841971693993751
 
static const double twopi_ = 6.2831853071795864769252867665590057683943387987502
 

Protected Member Functions

 QuadraticInterpolator ()
 
void setEmptyValue (double emptyValue)
 

Protected Attributes

QuadType type_
 

Friends

std::ostream & gcp::util::operator<< (std::ostream &os, QuadraticInterpolator &quad)
 

Detailed Description

The QuadraticInterpolator class is used to perform quadrature interpolation of arbitrary continuous functions, as well as certain periodic functions (angles).

This class will store up to three (x,y) pairs of a function to be interpolated, and provide a public interface to return the value and gradient of the function at arbitrary x, through the eval() and grad() methods. The behaviors of these methods under different conditions are described in the documentation below.

The class is initialized with a value to be returned until valid samples of a function have been loaded, as well as the type of function being interpolated.

Samples are loaded using the extend() method (see documentation below). As new samples are installed, they are appended or prepended to an internal circular buffer of samples, according to the x values of the pairs.

At a discontinuity (say, when preparing to interpolate the ephemerides of a new source), the user should discard old samples via the empty() method.

Member Enumeration Documentation

Enumerate the various types of ephemeris types we might handle.

Enumerator
QP_NORMAL 

A continuous function.

QP_SIGNED_ANGLE 

Angles defined modulo 2.pi between -pi <= v < pi.

QP_POSITIVE_ANGLE 

Angles defined modulo 2.pi between 0 <= v < 2.pi.

Constructor & Destructor Documentation

QuadraticInterpolator::~QuadraticInterpolator ( )
virtual

Destructor.

QuadraticInterpolator::QuadraticInterpolator ( )
protected

Constructor function. Making this protected prevents instantiation of the base class.

Parameters
emptyValueThe value to return until at least one coordinate pair has been added.
Exceptions
Exception....................................................................... Create a new QuadraticInterpolator object.

Input:

emptyVal double The value to return until at least one coordinate pair has been added.

Member Function Documentation

bool QuadraticInterpolator::canBracket ( double  x)

A method to query if the container can bracket the requested value

....................................................................... A method to query if the container can bracket the requested value

void QuadraticInterpolator::empty ( )

Empty the coordinate table of a QuadraticInterpolator object.

After this call the value of the empty_value argument that was presented to QuadraticInterpolator::QuadraticInterpolator() will be returned until extend() is next called.

Exceptions
Exception
double QuadraticInterpolator::evaluate ( double  x)

Return the value of the function at x.

void QuadraticInterpolator::extend ( double  x,
double  y 
)

Append or prepend an x,y coordinate pair to the three-entry circular table of a quadratic interpolation object. Entries are kept in ascending order of x, so if the new x value is larger than any currently in the table, it will be appended, and if it is smaller it will be prepended. If there are already three entries in the table the one at the other end of the table will be discarded and the table rotated over it to make room for the new sample.

If the new x value is within the range of x values already covered by the table, the interpolator will be left unchanged.

Each time a new entry is added, the three quadratic polynomial coefficients a,b,c (ie. a.x^2+b.x+c) are recomputed for use by eval().

The coefficients are initialized according to the number of entries in the interpolation table. After just one coordinate pair has been entered via this function, eval() returns its y-value irrespective of the target x-value. After a second point has been added, the coefficients implement linear interpolation of the two coordinate pairs. After 3 or more points have been added, the three coefficients implement a quadratic interpolation of the last three points entered.

Note that calls to this function and set() can be interleaved. In fact this function itself calls set().

Parameters
xdouble The X coordinate of the point to add.
ydouble The Y coordinate of the point to add.
unsigned QuadraticInterpolator::getNpt ( )

A method to query the number of points currently in our interpolation container.

....................................................................... A method to query the number of points currently in our interpolation container.

double QuadraticInterpolator::getXmax ( )

A method to query the maximum x-value in our interpolation container.

....................................................................... A method to query the maximum x-value in our interpolation container.

double QuadraticInterpolator::getXmin ( )

A method to query the minimum x-value in our interpolation container.

....................................................................... A method to query the minimum x-value in our interpolation container.

double QuadraticInterpolator::gradient ( double  x)

Return the gradient of the function at x.

void QuadraticInterpolator::lock ( )

A public method to lock this container

....................................................................... A public method to lock this container

void QuadraticInterpolator::setEmptyValue ( double  emptyValue)
protected

A method to set the value to be returned while the interpolation container is empty.

....................................................................... Set the value to return while the interpolation contained is empty.

bool QuadraticInterpolator::tryLock ( )

A public method to attempt to lock this container. Returns true if the lock was successful.

....................................................................... A public method to attempt to lock this container. Returns true if the lock was successful.

void QuadraticInterpolator::unlock ( )

A public method to unlock this container

....................................................................... A public method to unlock this container

Member Data Documentation

const double QuadraticInterpolator::pi_ = 3.1415926535897932384626433832795028841971693993751
static

Define constants

QuadType gcp::util::QuadraticInterpolator::type_
protected

The type of ordinate we are interpolating.


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