#include <FourierCoefficient.h>
Public Types | |
numOfCoeffs = 80 | |
enum | { numOfCoeffs = 80 } |
Public Member Functions | |
FourierCoefficient () | |
~FourierCoefficient () | |
long | fourierSynth (JointData::JointID joint, unsigned long time, int cMax, double scalingFactor=1.0) |
long | fourierSynth (JointData *jointData, unsigned long time, int cMax) |
bool | calcLUT (JointData::JointID joint, int cMax) |
bool | calcAllLUTs (int cMax) |
bool | calculate (long *functionValues, JointData::JointID joint) |
bool | calcPhiAndR (int numOfC=numOfCoeffs) |
bool | calcReAndIm (int numOfC=numOfCoeffs) |
bool | merge (FourierCoefficient *fc0, FourierCoefficient *fc1, double w1, FourierCoefficient *fc2, double w2, FourierCoefficient *fc3, double w3, int numOfC) |
bool | merge (FourierCoefficient *fc1, double w1, FourierCoefficient *fc2, double w2, int numOfC) |
double | phaseAlign (JointData::JointID joint) |
Public Attributes | |
int | lengthOfPeriod |
double | real [JointData::numOfJoint][numOfCoeffs] |
double | imaginary [JointData::numOfJoint][numOfCoeffs] |
double | phi [JointData::numOfJoint][numOfCoeffs] |
double | r [JointData::numOfJoint][numOfCoeffs] |
double | functionLUT [JointData::numOfJoint][numOfCoeffs] |
bool | useLookUp [numOfCoeffs] |
Definition at line 20 of file FourierCoefficient.h.
anonymous enum |
FourierCoefficient::FourierCoefficient | ( | ) |
Constructor
init all coefficients to zero
Definition at line 12 of file FourierCoefficient.cpp.
References functionLUT, imaginary, numOfCoeffs, JointData::numOfJoint, phi, r, real, and useLookUp.
FourierCoefficient::~FourierCoefficient | ( | ) |
Destructor
Definition at line 30 of file FourierCoefficient.cpp.
bool FourierCoefficient::calcAllLUTs | ( | int | cMax | ) |
Calculate all LUTs
cMax | Number of coefficients used. |
Definition at line 126 of file FourierCoefficient.cpp.
References calcLUT(), and JointData::numOfJoint.
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
joint | The joint that is described by the function | |
cMax | Number of coefficients used. |
Definition at line 115 of file FourierCoefficient.cpp.
References fourierSynth(), functionLUT, lengthOfPeriod, numOfCoeffs, real, and useLookUp.
Referenced by calcAllLUTs().
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
numOfC | number of coefficients |
Definition at line 245 of file FourierCoefficient.cpp.
References imaginary, JointData::legFR1, JointData::legHL3, 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
numOfC |
Definition at line 259 of file FourierCoefficient.cpp.
References imaginary, JointData::legFR1, JointData::legHL3, phi, r, and real.
Referenced by merge(), and phaseAlign().
bool FourierCoefficient::calculate | ( | long * | functionValues, | |
JointData::JointID | joint | |||
) |
Calculate coefficients from the function values over one period.
functionValues | Pointer to an array containing the function values | |
joint | The joint that is described by the function |
Definition at line 137 of file FourierCoefficient.cpp.
References imaginary, numOfCoeffs, pi2, and real.
Referenced by CJointViewerDlgBar::saveFTSpectrum().
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.
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. |
Definition at line 74 of file FourierCoefficient.cpp.
References b, JointData::data, imaginary, JointData::legFR1, JointData::legHL3, numOfCoeffs, pi2, and real.
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)
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) |
Definition at line 36 of file FourierCoefficient.cpp.
References b, imaginary, numOfCoeffs, pi2, and real.
Referenced by calcLUT().
bool FourierCoefficient::merge | ( | FourierCoefficient * | fc1, | |
double | w1, | |||
FourierCoefficient * | fc2, | |||
double | w2, | |||
int | numOfC | |||
) |
Similar to merge(many parameters) but only merges two sets!
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 |
Definition at line 220 of file FourierCoefficient.cpp.
References calcReAndIm(), JointData::legFR1, JointData::legHL3, phi, pi, pi2, and r.
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
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 |
always use the (direction of) difference with the smaller abs()
Definition at line 190 of file FourierCoefficient.cpp.
References calcReAndIm(), JointData::legFR1, JointData::legHL3, phi, pi, pi2, and r.
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.
joint | reference joint (it is examined |
Definition at line 165 of file FourierCoefficient.cpp.
References calcPhiAndR(), calcReAndIm(), JointData::legFR1, JointData::legHL3, numOfCoeffs, and phi.
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().
double FourierCoefficient::imaginary[JointData::numOfJoint][numOfCoeffs] |
Definition at line 175 of file FourierCoefficient.h.
Referenced by calcPhiAndR(), calcReAndIm(), calculate(), FourierCoefficient(), fourierSynth(), operator<<(), and operator>>().
length of period these coefficients are designed for
Definition at line 171 of file FourierCoefficient.h.
Referenced by calcLUT().
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::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>>().
bool FourierCoefficient::useLookUp[numOfCoeffs] |
Definition at line 185 of file FourierCoefficient.h.
Referenced by calcLUT(), and FourierCoefficient().