Fast Research Interface Library  Manual and Documentation
src/TypeIRML/TypeIRMLPolynomial.cpp
Go to the documentation of this file.
```00001 //  ---------------------- Doxygen info ----------------------
00047 //  ----------------------------------------------------------
00048 //   For a convenient reading of this file's source code,
00049 //   please use a tab width of four characters.
00050 //  ----------------------------------------------------------
00051
00052
00053
00054 #include <TypeIRMLPolynomial.h>
00055 #include <TypeIRMLMath.h>
00056
00057
00058 //************************************************************************************
00059 // Constructor
00060
00061
00062 TypeIRMLMath::TypeIRMLPolynomial::TypeIRMLPolynomial()
00063 {
00064     a0      = 0.0;
00065     a1      = 0.0;
00066     a2      = 0.0;
00067     DeltaT  = 0.0;
00068     Degree  = 0;
00069 }
00070
00071
00072 //************************************************************************************
00073 // Destructor
00074
00075 TypeIRMLMath::TypeIRMLPolynomial::~TypeIRMLPolynomial()
00076 {}
00077
00078
00079 //************************************************************************************
00080 // SetCoefficients()
00081 // f(x) = a_2 * (t - DeltaT)^2 + a_1 * (t - DeltaT) + a_0
00082
00083 void TypeIRMLMath::TypeIRMLPolynomial::SetCoefficients(     const double    &Coeff2
00084                                                         ,   const double    &Coeff1
00085                                                         ,   const double    &Coeff0
00086                                                         ,   const double    &Diff)
00087 {
00088     a0      = Coeff0;
00089     a1      = Coeff1;
00090     a2      = Coeff2;
00091     DeltaT  = Diff;
00092
00093     if (a2 != 0.0)
00094     {
00095         Degree = 2;
00096         return;
00097     }
00098
00099     if (a1 != 0.0)
00100     {
00101         Degree = 1;
00102         return;
00103     }
00104
00105     Degree = 0;
00106     return;
00107 }
00108
00109
00110 //*******************************************************************************************
00111 // CalculateValue()
00112 // calculates f(t)
00113
00114 double TypeIRMLMath::TypeIRMLPolynomial::CalculateValue(const double &t) const
00115 {
00116     return( ((Degree == 2)?
00117             (a2 * (t - DeltaT) * (t - DeltaT) + a1 * (t - DeltaT) + a0):
00118             ((Degree == 1)?
00119             (a1 * (t - DeltaT) + a0):
00120             (a0))));
00121 }
```
This document was generated with Doxygen on Thu Apr 12 2012 11:18:54. User documentation of the Fast Research Interface Library for the KUKA Lightweight Robot IV by the Stanford Robotics Research Group. Copyright 2010–2012.