KINECT STATS GENERATOR FOR SPORTS VISUALISATION  1.0
QuadCurveFitUtility Class Reference

Contains cramers rule used in trajectory interpolation for solving simulataneous linear regression equation. More...

#include <QuadCurveFitUtility.h>

List of all members.

Public Member Functions

 QuadCurveFitUtility ()
 constructor
 ~QuadCurveFitUtility ()
 dtor
void addPoints (cv::Point2f _inputSet)
 sets the data points
void processParametricPoints3D (std::vector< float > &_inputBuffer, float &o_coeffX)
 processes the data points set from 3D stats class
double getATerm ()
 Gets the a term of the equation ax^2 + bx + c.
double getBTerm ()
 Gets the b term of the equation ax^2 + bx + c.
double getCTerm ()
 Gets c term of the equation ax^2 + bx + c.
double getRSquare ()
 Gets r squared value. goodness measure.

Protected Member Functions

double getSxy (int _nX, int _nY)
 Gets sum of x^nX * y^nY.
double getYMean ()
 gets the y mean for R calculation
double getSStot ()
 gets sum squared total
double getSSerr ()
 gets sum squared error
double getPredictedY (double _x)
 gets the interpolated Y value
double getDifferential (double _x)
 gets 2ax + b value at given point tangent derivative used to calculate instantanoeous velocity

Protected Attributes

std::vector< cv::Point2f > m_dataPoints
 data points set for X/Y/Z and t
std::vector< cv::Point2f > m_dataPointsAfterInterpol
 vector to hold interpolated data
double m_a
 coeeficienct a
double m_b
 coeeficienct b
double m_c
 coeeficienct c

Detailed Description

Contains cramers rule used in trajectory interpolation for solving simulataneous linear regression equation.

Definition at line 12 of file QuadCurveFitUtility.h.


Constructor & Destructor Documentation

constructor

Definition at line 13 of file QuadCurveFitUtility.cpp.

References m_a, m_b, m_c, m_dataPoints, and m_dataPointsAfterInterpol.

{
    m_dataPoints.clear();
    m_dataPointsAfterInterpol.clear();
    m_a = m_b = m_c = 0;

}

dtor

Definition at line 21 of file QuadCurveFitUtility.cpp.

{

}

Member Function Documentation

void QuadCurveFitUtility::addPoints ( cv::Point2f  _inputSet)

sets the data points

Parameters:
[in]_inputSetrepresenting the (t,x)/(t,y)/(t,z)

Definition at line 33 of file QuadCurveFitUtility.cpp.

References m_dataPoints.

{
    m_dataPoints.push_back(_inputSet);
}

+ Here is the caller graph for this function:

Gets the a term of the equation ax^2 + bx + c.

Definition at line 88 of file QuadCurveFitUtility.cpp.

References getSxy(), m_a, m_dataPoints, and MIN_VALUES.

{
    if( m_dataPoints.size() < MIN_VALUES )
    {
        std::cout<<"Atleast 3 data sets required to interpolate" ;
        return 0;
    }

    // notation sjk to mean the sum of x_i^j_i^k.
    double s40 = getSxy( 4, 0 );
    double s30 = getSxy( 3, 0 );
    double s20 = getSxy( 2, 0 );
    double s10 = getSxy( 1, 0 );
    double s00 = (double)m_dataPoints.size();

    double s21 = getSxy( 2, 1 );
    double s11 = getSxy( 1, 1 );
    double s01 = getSxy( 0, 1 );

    // Da / D
    m_a = (s21 * (s20 * s00 - s10 * s10) - s11 * (s30 * s00 - s10 * s20) + s01 * (s30 * s10 - s20 * s20))
                /
                (s40 * (s20 * s00 - s10 * s10) - s30 * (s30 * s00 - s10 * s20) + s20 * (s30 * s10 - s20 * s20));

    return m_a;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Gets the b term of the equation ax^2 + bx + c.

Definition at line 122 of file QuadCurveFitUtility.cpp.

References getSxy(), m_b, m_dataPoints, and MIN_VALUES.

{
    if( m_dataPoints.size() < MIN_VALUES )
    {
        std::cout<<"Atleast 3 data sets required to interpolate" ;
        return 0;
    }


    // notation sjk to mean the sum of x_i^j_i^k.
    double s40 = getSxy( 4, 0 );
    double s30 = getSxy( 3, 0 );
    double s20 = getSxy( 2, 0 );
    double s10 = getSxy( 1, 0 );
    double s00 = (double)m_dataPoints.size();

    double s21 = getSxy( 2, 1 );
    double s11 = getSxy( 1, 1 );
    double s01 = getSxy( 0, 1 );

    //   Db / D
    m_b = (s40 * (s11 * s00 - s01 * s10) - s30 * (s21 * s00 - s01 * s20) + s20 * (s21 * s10 - s11 * s20))
        /
        (s40 * (s20 * s00 - s10 * s10) - s30 * (s30 * s00 - s10 * s20) + s20 * (s30 * s10 - s20 * s20));

    return m_b;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Gets c term of the equation ax^2 + bx + c.

Definition at line 157 of file QuadCurveFitUtility.cpp.

References getSxy(), m_c, m_dataPoints, and MIN_VALUES.

{
    if( m_dataPoints.size() < MIN_VALUES )
    {
        std::cout<<"Atleast 3 data sets required to interpolate" ;
        return 0;
    }


    // notation sjk to mean the sum of x_i^j_i^k.
    double s40 = getSxy( 4, 0 );
    double s30 = getSxy( 3, 0 );
    double s20 = getSxy( 2, 0 );
    double s10 = getSxy( 1, 0 );
    double s00 = (double)m_dataPoints.size();

    double s21 = getSxy( 2, 1 );
    double s11 = getSxy( 1, 1 );
    double s01 = getSxy( 0, 1 );

    //   Dc / D
    m_c = (s40*(s20 * s01 - s10 * s11) - s30*(s30 * s01 - s10 * s21) + s20*(s30 * s11 - s20 * s21))
            /
            (s40 * (s20 * s00 - s10 * s10) - s30 * (s30 * s00 - s10 * s20) + s20 * (s30 * s10 - s20 * s20));

    return m_c;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double QuadCurveFitUtility::getDifferential ( double  _x) [protected]

gets 2ax + b value at given point tangent derivative used to calculate instantanoeous velocity

Definition at line 303 of file QuadCurveFitUtility.cpp.

References getATerm(), and getBTerm().

{
    //2at + b is the differential
    return ((2 * getATerm() *  _x) + (getBTerm()));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double QuadCurveFitUtility::getPredictedY ( double  _x) [protected]

gets the interpolated Y value

Definition at line 298 of file QuadCurveFitUtility.cpp.

References getATerm(), getBTerm(), and getCTerm().

{
    return (getATerm() * pow( _x, 2 )) + (getBTerm() * _x) + getCTerm();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Gets r squared value. goodness measure.

Definition at line 192 of file QuadCurveFitUtility.cpp.

References getSSerr(), getSStot(), m_dataPoints, and MIN_VALUES.

{
    if( m_dataPoints.size() < MIN_VALUES )
    {
        std::cout<<"Atleast 3 data sets required to interpolate" ;
        return 0;
    }

    return (1.0 - getSSerr() / getSStot());

}

+ Here is the call graph for this function:

double QuadCurveFitUtility::getSSerr ( ) [protected]

gets sum squared error

Definition at line 275 of file QuadCurveFitUtility.cpp.

References getPredictedY(), and m_dataPoints.

{
    double ssErr = 0.0;

    //auto pThis = this;

    for(int i = 0;i<m_dataPoints.size();i++)
    {
        ssErr += pow( (m_dataPoints[i].y - getPredictedY( m_dataPoints[i].x)), 2 );
    }

    return ssErr;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double QuadCurveFitUtility::getSStot ( ) [protected]

gets sum squared total

Definition at line 255 of file QuadCurveFitUtility.cpp.

References getYMean(), and m_dataPoints.

{
    double ssTot = 0.0;
    double dYMean = getYMean();

    for(int i = 0;i<m_dataPoints.size();i++)
    {
        ssTot += pow( (m_dataPoints[i].y * dYMean), 2 );
    }

    return ssTot;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double QuadCurveFitUtility::getSxy ( int  _nX,
int  _nY 
) [protected]

Gets sum of x^nX * y^nY.

Definition at line 216 of file QuadCurveFitUtility.cpp.

References m_dataPoints.

{
    double dSxy = 0.0;

    for(int i = 0;i<m_dataPoints.size();i++)
    {
        dSxy += pow(m_dataPoints[i].x,_nX) * pow(m_dataPoints[i].y,_nY);
    }

    return dSxy;
}

+ Here is the caller graph for this function:

double QuadCurveFitUtility::getYMean ( ) [protected]

gets the y mean for R calculation

Definition at line 235 of file QuadCurveFitUtility.cpp.

References m_dataPoints.

{
    double dTotal = 0.0;
    int nCount = 0;
    for(int i = 0;i<m_dataPoints.size();i++)
    {
        dTotal += m_dataPoints[i].y;
        nCount++;
    }

    return dTotal / nCount;
}

+ Here is the caller graph for this function:

void QuadCurveFitUtility::processParametricPoints3D ( std::vector< float > &  _inputBuffer,
float &  o_coeffX 
)

processes the data points set from 3D stats class

Definition at line 310 of file QuadCurveFitUtility.cpp.

References getDifferential(), getPredictedY(), and m_dataPoints.

{
    int i = m_dataPoints.size();

    //std::sort(m_dataPoints)
    std::cout<<"size is:"<<i<<"first:"<<m_dataPoints[0].x<<"::"<<m_dataPoints[0].y<<"last:"<<m_dataPoints[i - 1].x<<"::"<<m_dataPoints[i - 1].y<<"\n";
    double temp = 0;
    if(i != 0)
    {
        temp = m_dataPoints[0].x;
        while(temp <= 1.0)
        {
            std::cout<<" Interpol. X and Y are: "<<temp<<":"<<getPredictedY(temp);
            //m_dataPointsAfterInterpol.push_back(cv::Point2f(temp,getPredictedY(temp)));

            float tempValue = getPredictedY(temp);
            if(!(std::isnan(tempValue)))
            {
                _inputBuffer.push_back(getPredictedY(temp));
            }
            temp = temp + 0.01;
        }

        // get the differential at t = 1.0 which will be our
        // tangent to the impact point
        o_coeffX = getDifferential(1.0);

    }
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


Member Data Documentation

double QuadCurveFitUtility::m_a [protected]

coeeficienct a

Definition at line 27 of file QuadCurveFitUtility.h.

double QuadCurveFitUtility::m_b [protected]

coeeficienct b

Definition at line 29 of file QuadCurveFitUtility.h.

double QuadCurveFitUtility::m_c [protected]

coeeficienct c

Definition at line 31 of file QuadCurveFitUtility.h.

std::vector<cv::Point2f> QuadCurveFitUtility::m_dataPoints [protected]

data points set for X/Y/Z and t

Definition at line 22 of file QuadCurveFitUtility.h.

std::vector<cv::Point2f> QuadCurveFitUtility::m_dataPointsAfterInterpol [protected]

vector to hold interpolated data

Definition at line 24 of file QuadCurveFitUtility.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Enumerator