#include <BernsteinPolynomial.h>
Collaboration diagram for mathglpp::GLBernsteinPolynomial:
They are called evaluators in the OpenGL API.
Definition at line 35 of file BernsteinPolynomial.h.
Public Member Functions | |
GLBernsteinPolynomial (GLuint n) | |
Create a bernstein polynomial of order at least n. | |
~GLBernsteinPolynomial () | |
Default destructor. | |
void | setOrder (GLuint) |
Use to ensure that the polynomial is capable of using the desired order. | |
const GLfloat | get (const GLuint order, const GLuint c, const GLfloat u) |
Get interpolation product for control point c, where c = [0,. | |
const void | getVector (const GLuint order, const GLfloat u, GLfloat *vec) |
Get interpolation product vector for all control points c, where u = [0,1] This is normally used for post multiplying with a control point matrix. | |
GLBernsteinPolynomial (GLuint n) | |
Create a bernstein polynomial of order at least n. | |
~GLBernsteinPolynomial () | |
Default destructor. | |
void | setOrder (GLuint) |
Use to ensure that the polynomial is capable of using the desired order. | |
const GLfloat | get (const GLuint order, const GLuint c, const GLfloat u) |
Get interpolation product for control point c, where c = [0,. | |
const void | getVector (const GLuint order, const GLfloat u, GLfloat *vec) |
Get interpolation product vector for all control points c, where u = [0,1] This is normally used for post multiplying with a control point matrix. | |
Protected Member Functions | |
void | extendPascal (GLuint) |
Extends Pascal's triangle as needed. | |
const GLuint | getCoeff (const GLuint order, const GLuint choice) |
This is exactly the same as "c choose n" in statistics. | |
void | extendPascal (GLuint) |
Extends Pascal's triangle as needed. | |
const GLuint | getCoeff (const GLuint order, const GLuint choice) |
This is exactly the same as "c choose n" in statistics. |
mathglpp::GLBernsteinPolynomial::GLBernsteinPolynomial | ( | GLuint | n | ) |
Create a bernstein polynomial of order at least n.
Definition at line 27 of file GLBernsteinPolynomial.cpp.
References extendPascal().
00028 { 00029 if(ord >= pascalsTriangle.size() ) 00030 extendPascal(ord); 00031 }
Here is the call graph for this function:
mathglpp::GLBernsteinPolynomial::~GLBernsteinPolynomial | ( | ) |
mathglpp::GLBernsteinPolynomial::GLBernsteinPolynomial | ( | GLuint | n | ) |
Create a bernstein polynomial of order at least n.
mathglpp::GLBernsteinPolynomial::~GLBernsteinPolynomial | ( | ) |
Default destructor.
void mathglpp::GLBernsteinPolynomial::setOrder | ( | GLuint | ) |
Use to ensure that the polynomial is capable of using the desired order.
Definition at line 37 of file GLBernsteinPolynomial.cpp.
References extendPascal().
00038 { 00039 if(ord >= pascalsTriangle.size()) 00040 extendPascal(ord); 00041 }
Here is the call graph for this function:
const GLfloat mathglpp::GLBernsteinPolynomial::get | ( | const GLuint | order, | |
const GLuint | c, | |||
const GLfloat | u | |||
) |
Get interpolation product for control point c, where c = [0,.
..,order] & u = [0,1]
Definition at line 71 of file GLBernsteinPolynomial.cpp.
00072 { 00073 assert(choice <= order); 00074 00075 if(choice == 0) 00076 { 00077 if( u <= 0.0000001 ) 00078 return 1; 00079 else 00080 if( u >= 0.9999999 ) 00081 return 0; 00082 else 00083 return pow(GLfloat(1-u), GLint(order)); 00084 } 00085 else 00086 if(choice == order) 00087 { 00088 if( u <= 0.0000001 ) 00089 return 0; 00090 else 00091 if( u >= 0.9999999 ) 00092 return 1; 00093 else 00094 return pow((GLfloat)u, (GLint)choice); 00095 } 00096 else 00097 if( u <= 0.0000001 ) 00098 return 0; 00099 else 00100 if( u >= 0.9999999 ) 00101 return 0; 00102 else 00103 return pascalsTriangle[order][choice] 00104 * pow((GLfloat)u, (GLint)choice) 00105 * pow((GLfloat)(1-u), (GLint)(order - choice)); 00106 }
const void mathglpp::GLBernsteinPolynomial::getVector | ( | const GLuint | order, | |
const GLfloat | u, | |||
GLfloat * | vec | |||
) |
Get interpolation product vector for all control points c, where u = [0,1] This is normally used for post multiplying with a control point matrix.
Definition at line 108 of file GLBernsteinPolynomial.cpp.
00109 { 00110 assert(vec); 00111 for(register GLuint i = 0; i < order; ++i) 00112 vec[i] = get(order,i,u); 00113 }
void mathglpp::GLBernsteinPolynomial::extendPascal | ( | GLuint | ) | [protected] |
Extends Pascal's triangle as needed.
Definition at line 43 of file GLBernsteinPolynomial.cpp.
Referenced by GLBernsteinPolynomial(), and setOrder().
00044 { 00045 if(pascalsTriangle.size() < 2) 00046 { 00047 std::vector<GLuint> row; 00048 row.push_back(1); 00049 00050 pascalsTriangle.push_back(row); 00051 row.push_back(1); 00052 pascalsTriangle.push_back(row); 00053 } 00054 00055 if(level >= pascalsTriangle.size() ) 00056 { 00057 std::vector<GLuint> row; 00058 row.push_back(1); 00059 00060 for(register GLuint i = 1; i < pascalsTriangle.size(); ++i) 00061 row.push_back( pascalsTriangle[pascalsTriangle.size()-1][i-1] + 00062 pascalsTriangle[pascalsTriangle.size()-1][i] ); 00063 00064 row.push_back(1); 00065 pascalsTriangle.push_back(row); 00066 00067 extendPascal(level); 00068 } 00069 }
const GLuint mathglpp::GLBernsteinPolynomial::getCoeff | ( | const GLuint | order, | |
const GLuint | choice | |||
) | [inline, protected] |
This is exactly the same as "c choose n" in statistics.
Definition at line 61 of file BernsteinPolynomial.h.
void mathglpp::GLBernsteinPolynomial::setOrder | ( | GLuint | ) |
Use to ensure that the polynomial is capable of using the desired order.
const GLfloat mathglpp::GLBernsteinPolynomial::get | ( | const GLuint | order, | |
const GLuint | c, | |||
const GLfloat | u | |||
) |
Get interpolation product for control point c, where c = [0,.
..,order] & u = [0,1]
const void mathglpp::GLBernsteinPolynomial::getVector | ( | const GLuint | order, | |
const GLfloat | u, | |||
GLfloat * | vec | |||
) |
Get interpolation product vector for all control points c, where u = [0,1] This is normally used for post multiplying with a control point matrix.
void mathglpp::GLBernsteinPolynomial::extendPascal | ( | GLuint | ) | [protected] |
Extends Pascal's triangle as needed.
const GLuint mathglpp::GLBernsteinPolynomial::getCoeff | ( | const GLuint | order, | |
const GLuint | choice | |||
) | [inline, protected] |
This is exactly the same as "c choose n" in statistics.
Definition at line 62 of file GLBernsteinPolynomial.h.