Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# FourierCoefficient Class Reference

This class contains a set of fourier coefficients as well as methods transform them from and to a period of function values. More...

`#include <FourierCoefficient.h>`

List of all members.

## Public Types
enum | { numOfCoeffs = 80 }
## Public Member Functions
| FourierCoefficient ()
| Constructor.
| ~FourierCoefficient ()
| Destructor.
long | fourierSynth (JointData::JointID joint, unsigned long time, int cMax, double scalingFactor=1.0)
| Synthesizes the value of the original function for a given joint using the fourier coefficients.
long | fourierSynth (JointData *jointData, unsigned long time, int cMax)
| Like the other fourierSynth, a change to the joint parameter and no return value.
bool | calcLUT (JointData::JointID joint, int cMax)
| Calculate LUT for the function values so they don't have to be computed every time the synth.
bool | calcAllLUTs (int cMax)
| Calculate all LUTs.
bool | calculate (long *functionValues, JointData::JointID joint)
| Calculate coefficients from the function values over one period.
bool | calcPhiAndR (int numOfC=numOfCoeffs)
| Calculates phi and r for the first numOfC coefficients only Calculates the coefficients in the exponential form, i.e.
bool | calcReAndIm (int numOfC=numOfCoeffs)
| Calculates the coefficients in the vector form, i.e.
bool | merge (FourierCoefficient *fc0, FourierCoefficient *fc1, double w1, FourierCoefficient *fc2, double w2, FourierCoefficient *fc3, double w3, int numOfC)
| Takes 1+3=4 sets of Fourier coefficients and averages them according to the weights.
bool | merge (FourierCoefficient *fc1, double w1, FourierCoefficient *fc2, double w2, int numOfC)
| Similar to merge(many parameters) but only merges two sets!
double | phaseAlign (JointData::JointID joint)
| Function shifts all phases so that the 1 Hz frequency of the joint is a sine function starting at t=0 (i.e.
## Public Attributes
int | lengthOfPeriod
| length of period these coefficients are designed for
double | real [JointData::numOfJoint][numOfCoeffs]
| real and imaginary parts of the coefficients
double | imaginary [JointData::numOfJoint][numOfCoeffs]
double | phi [JointData::numOfJoint][numOfCoeffs]
| alternative representation: length r and phase phi of the coefficients
double | r [JointData::numOfJoint][numOfCoeffs]
double | functionLUT [JointData::numOfJoint][numOfCoeffs]
| LUT that stores the function calculated from the coeffs.
bool | useLookUp [numOfCoeffs]

## Detailed Description

This class contains a set of fourier coefficients as well as methods transform them from and to a period of function values.

Definition at line 20 of file FourierCoefficient.h.

## Member Enumeration Documentation

anonymous enum

  | Enumeration values:
  numOfCoeffs |
Definition at line 23 of file FourierCoefficient.h.

## Constructor & Destructor Documentation

FourierCoefficient::FourierCoefficient | ( |  | ) |

| Constructor. init all coefficients to zero Definition at line 12 of file FourierCoefficient.cpp. References functionLUT, imaginary, numOfCoeffs, phi, r, real, and useLookUp.

FourierCoefficient::~FourierCoefficient | ( |  | ) |

| Destructor. Definition at line 30 of file FourierCoefficient.cpp.

## Member Function Documentation

long FourierCoefficient::fourierSynth | ( | JointData::JointID | joint,
|  | unsigned long | time,
|  | int | cMax,
|  | double | scalingFactor = 1.0
| ) |

  | Synthesizes the value of the original function for a given joint using the fourier coefficients. A scaling factor is added. This allows the amplitude of the curve to be changed while keeping the origin/offset constant. This factor is also used for inverting the direction of the function (in essence playing the function backward if the factor is smaller than 0) Parameters:
  joint | The joint for which the synthesis is calculated.
  time | Time (in the format returned by "getSystemTime"). This time is used to generate the curves as a function of that time.
  cMax | Number of coefficients used. Small numbers result in a low pass behavior, numbers larger than numOfCoeffs/2 result in oversampling effects. (This is due to the fact that a continous Fourier (back) transformation is calculated from descrete FT coefficients.)
  scalingFactor | is used to vary the amplitude of the wave without touching the offset. 1.0 = 100%, values greater than 1 possible. Negative numbers will be interpreted as running the function backwards (negative time line)
Returns: The synthesized function value. Definition at line 36 of file FourierCoefficient.cpp. References imaginary, numOfCoeffs, pi2, and real. Referenced by calcLUT().

long FourierCoefficient::fourierSynth | ( | JointData * | jointData,
|  | unsigned long | time,
|  | int | cMax
| ) |

  | Like the other fourierSynth, a change to the joint parameter and no return value. In contrast to the above, a reference to the entire joint data array is passed in order to minimize function calls. All joint values are computed in one go. Also scalingfactor is no longer used. don't need it, really. Parameters:
  jointData | Array of joint datas to be calculated.
  time | This time is used to generate the curves as a function of that time.
  cMax | Number of coefficients used.
Returns: nothing Definition at line 74 of file FourierCoefficient.cpp. References JointData::data, imaginary, numOfCoeffs, pi2, and real.

bool FourierCoefficient::calcLUT | ( | JointData::JointID | joint,
|  | int | cMax
| ) |

  | Calculate LUT for the function values so they don't have to be computed every time the synth. is used Parameters:
  joint | The joint that is described by the function
  cMax | Number of coefficients used.
Returns: true if successful, false if failed Definition at line 115 of file FourierCoefficient.cpp. References fourierSynth(), functionLUT, lengthOfPeriod, numOfCoeffs, real, and useLookUp. Referenced by calcAllLUTs().

Here is the call graph for this function:

bool FourierCoefficient::calcAllLUTs | ( | int | cMax | ) |

  | Calculate all LUTs. Parameters:
  cMax | Number of coefficients used.
Returns: true if successful, false if failed Definition at line 126 of file FourierCoefficient.cpp. References calcLUT().

Here is the call graph for this function:

bool FourierCoefficient::calculate | ( | long * | functionValues,
|  | JointData::JointID | joint
| ) |

  | Calculate coefficients from the function values over one period. Parameters:
  functionValues | Pointer to an array containing the function values
  joint | The joint that is described by the function
Returns: true if successful, false if failed Definition at line 137 of file FourierCoefficient.cpp. References imaginary, numOfCoeffs, pi2, and real.

bool FourierCoefficient::calcPhiAndR | ( | int | numOfC = numOfCoeffs | ) |

  | Calculates phi and r for the first numOfC coefficients only Calculates the coefficients in the exponential form, i.e. z = R * exp (i*phi), from the "vector" representation z = x + iy Parameters:
  numOfC | number of coefficients
Returns: true if successful, false if failed Definition at line 245 of file FourierCoefficient.cpp. References imaginary, phi, r, and real. Referenced by phaseAlign().

bool FourierCoefficient::calcReAndIm | ( | int | numOfC = numOfCoeffs | ) |

  | Calculates the coefficients in the vector form, i.e. z = x + iy, from the exponential representation z = R * exp (i*phi) Calculates the real and imaginary parts for the first numOfC coefficients Parameters:
  numOfC |
Returns: true if successful, false if failed Definition at line 259 of file FourierCoefficient.cpp. References imaginary, phi, r, and real. Referenced by merge(), and phaseAlign().

bool FourierCoefficient::merge | ( | FourierCoefficient * | fc0,
|  | FourierCoefficient * | fc1,
|  | double | w1,
|  | FourierCoefficient * | fc2,
|  | double | w2,
|  | FourierCoefficient * | fc3,
|  | double | w3,
|  | int | numOfC
| ) |

  | Takes 1+3=4 sets of Fourier coefficients and averages them according to the weights. negative weights are interpreted relativly to fc0, a weight=1 means: go from fc0 100% into direction fcn, so fc=fc0+w1*(fc1-fc0)+w2*(fc2-fc0)+... Takes an parameter that determines the accuracy of the merge, i.e. the number of coefficients that are merged Parameters:
  fc0 | Fourier Coefficient set 0 ("stand" would be useful)
  fc1 | Fourier Coefficient set 1
  w1 | the weigth of set 1
  fc2 | Fourier Coefficient set 2
  w2 | the weigth of set 2
  fc3 | Fourier Coefficient set 3
  w3 | the weigth of set 3
  numOfC | the number of coefficients (starting from the first) that should be merged
Returns: true if successful, false if failed always use the (direction of) difference with the smaller abs() Definition at line 190 of file FourierCoefficient.cpp. References calcReAndIm(), phi, pi, pi2, and r.

Here is the call graph for this function:

bool FourierCoefficient::merge | ( | FourierCoefficient * | fc1,
|  | double | w1,
|  | FourierCoefficient * | fc2,
|  | double | w2,
|  | int | numOfC
| ) |

  | Similar to merge(many parameters) but only merges two sets! Parameters:
  fc1 | Fourier Coefficient set 1
  w1 | the weigth of set 1
  fc2 | Fourier Coefficient set 2
  w2 | the weigth of set 2
  numOfC | the number of coefficients (starting from the first) that should be merged
Returns: true if successful, false if failed Definition at line 220 of file FourierCoefficient.cpp. References calcReAndIm(), phi, pi, pi2, and r.

Here is the call graph for this function:

double FourierCoefficient::phaseAlign | ( | JointData::JointID | joint | ) |

  | Function shifts all phases so that the 1 Hz frequency of the joint is a sine function starting at t=0 (i.e. there is no cosine part).This is necessary when using different function since they usually are not coherent. Coherence may be desirable in order to merge or superimpose two given functions. Parameters:
  joint | reference joint (it is examined
Returns: phaseShift how much the current function is out of phase with respect to a 1Hz sine Definition at line 165 of file FourierCoefficient.cpp. References calcPhiAndR(), calcReAndIm(), numOfCoeffs, and phi.

Here is the call graph for this function:

## Member Data Documentation

int FourierCoefficient::lengthOfPeriod

| length of period these coefficients are designed for Definition at line 171 of file FourierCoefficient.h. Referenced by calcLUT().

double FourierCoefficient::real[JointData::numOfJoint][numOfCoeffs]

| real and imaginary parts of the coefficients Definition at line 174 of file FourierCoefficient.h. Referenced by calcLUT(), calcPhiAndR(), calcReAndIm(), calculate(), FourierCoefficient(), fourierSynth(), operator<<(), and operator>>().

double FourierCoefficient::imaginary[JointData::numOfJoint][numOfCoeffs]

| Definition at line 175 of file FourierCoefficient.h. Referenced by calcPhiAndR(), calcReAndIm(), calculate(), FourierCoefficient(), fourierSynth(), operator<<(), and operator>>().

double FourierCoefficient::phi[JointData::numOfJoint][numOfCoeffs]

| alternative representation: length r and phase phi of the coefficients Definition at line 179 of file FourierCoefficient.h. Referenced by calcPhiAndR(), calcReAndIm(), FourierCoefficient(), merge(), and phaseAlign().

double FourierCoefficient::r[JointData::numOfJoint][numOfCoeffs]

| Definition at line 180 of file FourierCoefficient.h. Referenced by calcPhiAndR(), calcReAndIm(), FourierCoefficient(), and merge().

double FourierCoefficient::functionLUT[JointData::numOfJoint][numOfCoeffs]

| LUT that stores the function calculated from the coeffs. Definition at line 183 of file FourierCoefficient.h. Referenced by calcLUT(), and FourierCoefficient().

bool FourierCoefficient::useLookUp[numOfCoeffs]

| Definition at line 185 of file FourierCoefficient.h. Referenced by calcLUT(), and FourierCoefficient().

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

- Tools/Math/FourierCoefficient.h
- Tools/Math/FourierCoefficient.cpp