GCGlib
0.04.228
GCG Graphics Engine
|
Class for Legendre 2D polynomials computation. More...
#include <gcg.h>
Public Member Functions | |
bool | setBasisDegree (unsigned int degree) |
Sets the maximum degree of the polynomials of the basis. The number of polynomials = (degree + 1)*(degree+2)/2. More... | |
bool | setNumberOfSamples (unsigned int nsamplesX, unsigned int nsamplesY) |
Sets the number of samples in X and Y directions for the discretization of polynomial functions. Call it (or call synchBasisWithFile()) BEFORE using getDiscreteValue(), projectSignal(), reconstructSignal() or basisInformation(). This method computes all polynomial basis vectors which might be slow if current degree is big. More... | |
unsigned int | getNumberOfCoefficients () |
Returns the number of coefficients used in 2D polynomial projection/reconstruction. More... | |
bool | synchBasisWithFile (const char *filename, unsigned int nsamplesX, unsigned int nsamplesY) |
Loads the basis functions of current degree, discretized with nsamplesX * nsamplesY elements, stored in the given file. All missing polynomials of the file are discretized and saved for further use. This function sychronizes file and memory polynomial functions and can considerably save time. Use this function instead of setNumberOfSamples() to avoid the computation of all basis functions that might be stored in the file. More... | |
NUMTYPE | getPointValue (unsigned int i, unsigned int j, NUMTYPE x, NUMTYPE y) |
Computes the value Pi,j(x,y), where i+j <= degree, are the polynomial degrees in X and Y axe, and x, y in [-1, 1] * [-1, 1] are the coordinates of the point to be evaluated. More... | |
NUMTYPE | getIntegralValue (unsigned int i, unsigned int j, NUMTYPE xmin, NUMTYPE xmax, NUMTYPE ymin, NUMTYPE ymax) |
Computes the integral of the polynomial Pi,j in the region [xmin, xmax] * [ymin, ymax]. More... | |
NUMTYPE | getDiscreteValue (unsigned int i, unsigned int j, unsigned int ix, unsigned int iy) |
Compute normalized value Pi,j(ix, iy), where i+j <= degree, are the polynomial degrees in x and y, and ix in [0, nsamplesX-1], and iy in [0, nsamplesY-1] are the coordinates of the sample of a uniform discretization of the domain [-1, 1] * [-1, 1] with nsamplesX * nsamplesY samples. Call setNumberOfSamples() or synchBasisWithFile() to set the number of samples to be used. More... | |
bool | projectSignal (int atX, int atY, gcgDISCRETE2D< float > *vector, gcgDISCRETE1D< NUMTYPE > *outputcoef) |
Computes the ((degree-2) * (degree-1)) / 2) coefficients of the projection of the 2D vector (as 2D signal) on a discretized polynomial basis. Only nsamplesX * nsamplesY elements starting at (atX, atY) are used. The coefficients are stored in the array outputcoef (as 1D signal) that is adjusted to have (degree+2)* (degre+1)/2 elements. Call setNumberOfSamples() to set the number of samples to be used. More... | |
bool | reconstructSignal (int atX, int atY, gcgDISCRETE1D< NUMTYPE > *inputcoef, gcgDISCRETE2D< float > *outputvector) |
Computes the nsamplesX * nsamplesY components of a 2D vector, using the (degree+1)*(degree+2)/2 coefficients given in array inputcoef (as 1D signal). The components are stored in the 2D array outputvector (as 2D signal) starting at position (atX, atY). Call setNumberOfSamples() or synchBasisWithFile() to set the number of samples to be used. More... | |
bool | basisInformation (const char *filename, bool checkorthogonality, bool savefunctionsasimages) |
Output basis information with current degree for numerical analysis. Saves information of the orthogonality of the basis with nsamplesX * nsamplesY elements. More... | |
Public Member Functions inherited from gcgCLASS | |
void * | operator new (size_t size) |
Defines a new operator to be used by instatiations of GCGlib classes instead the global one. More... | |
void * | operator new (size_t size, const std::nothrow_t &) throw () |
Defines a new operator to be used by instantiations of GCGlib classes instead the global one. Returns a NULL pointer instead of throwing an exception if an error occurs. More... | |
void * | operator new[] (size_t size) |
Defines a new operator to be used by GCGlib array allocations instead the global one. More... | |
void * | operator new[] (size_t size, const std::nothrow_t &) throw () |
Defines a new operator to be used by vector allocations instead the global one. More... | |
void | operator delete (void *p) |
Defines a delete operator to free instances of GCGlib classes instead the global one. It is designed to match the new operator. More... | |
void | operator delete (void *p, const std::nothrow_t &) throw () |
Defines a delete operator to free instances of GCGlib classes instead the global one. It is designed to match the new operator. More... | |
void | operator delete[] (void *p) |
Defines a delete operator to free instances of arrays for GCGlib classes instead the global one. It is designed to match the new[] operator. More... | |
void | operator delete[] (void *p, const std::nothrow_t &) throw () |
Defines a delete operator to free instances of arrays for GCGlib classes instead the global one. It is designed to match the new[] operator. More... | |
Public Attributes | |
unsigned int | degree |
Degree of the polynomials. Read-only. See setBasisDegree(). | |
unsigned int | nsamplesX |
Current samples in X direction. Read-only. See setNumberOfSamples(). | |
unsigned int | nsamplesY |
Current samples in Y direction. Read-only. See setNumberOfSamples(). | |
Class for Legendre 2D polynomials computation.
NUMTYPE | Type of the samples representing the signal. Supported types: float or double. |
Use gcgLEGENDREBASIS2D<float> for single precision and gcgLEGENDREBASIS2D<double> for double precision. Methods for projection and reconstruction are avalaible. The performance of the numeric methods can be verified by using the basisInformation() method.
bool gcgLEGENDREBASIS2D< NUMTYPE >::basisInformation | ( | const char * | filename, |
bool | checkorthogonality, | ||
bool | savefunctionsasimages | ||
) |
Output basis information with current degree for numerical analysis. Saves information of the orthogonality of the basis with nsamplesX * nsamplesY elements.
[in] | filename | name of output text file. Call setNumberOfSamples() or synchBasisWithFile() to set the number of samples to be used. |
[in] | checkorthogonality | if true, computes the internal product of all functions of the basis. This can be time consuming. |
[in] | savefunctionsasimages | if true, saves the function basis as gray scale images to be visually checked. |
NUMTYPE gcgLEGENDREBASIS2D< NUMTYPE >::getDiscreteValue | ( | unsigned int | i, |
unsigned int | j, | ||
unsigned int | ix, | ||
unsigned int | iy | ||
) |
Compute normalized value Pi,j(ix, iy), where i+j <= degree, are the polynomial degrees in x and y, and ix in [0, nsamplesX-1], and iy in [0, nsamplesY-1] are the coordinates of the sample of a uniform discretization of the domain [-1, 1] * [-1, 1] with nsamplesX * nsamplesY samples. Call setNumberOfSamples() or synchBasisWithFile() to set the number of samples to be used.
[in] | i | degree of the polynomial function in X direction. |
[in] | j | degree of the polynomial function in Y direction. |
[in] | ix | index of the sample in X. Must be in the interval [0 nsamplesX - 1]. |
[in] | iy | index of the sample in Y. Must be in the interval [0 nsamplesY - 1]. |
NUMTYPE gcgLEGENDREBASIS2D< NUMTYPE >::getIntegralValue | ( | unsigned int | i, |
unsigned int | j, | ||
NUMTYPE | xmin, | ||
NUMTYPE | xmax, | ||
NUMTYPE | ymin, | ||
NUMTYPE | ymax | ||
) |
Computes the integral of the polynomial Pi,j in the region [xmin, xmax] * [ymin, ymax].
[in] | i | degree of the polynomial function in X direction. |
[in] | j | degree of the polynomial function in Y direction. |
[in] | xmin | inferior limit of the interval in X. |
[in] | xmax | superior limit of the interval in X. |
[in] | ymin | inferior limit of the interval in Y. |
[in] | ymax | superior limit of the interval in Y. |
|
virtual |
Returns the number of coefficients used in 2D polynomial projection/reconstruction.
Implements gcgBASIS2D< NUMTYPE >.
NUMTYPE gcgLEGENDREBASIS2D< NUMTYPE >::getPointValue | ( | unsigned int | i, |
unsigned int | j, | ||
NUMTYPE | x, | ||
NUMTYPE | y | ||
) |
Computes the value Pi,j(x,y), where i+j <= degree, are the polynomial degrees in X and Y axe, and x, y in [-1, 1] * [-1, 1] are the coordinates of the point to be evaluated.
[in] | i | degree of the polynomial function in X direction. |
[in] | j | degree of the polynomial function in Y direction. |
[in] | x | abcissa coordinate of the point to be evaluated. Must be in the interval [-1, 1] |
[in] | y | coordinate of the point to be evaluated. Must be in the interval [-1, 1] |
|
virtual |
Computes the ((degree-2) * (degree-1)) / 2) coefficients of the projection of the 2D vector (as 2D signal) on a discretized polynomial basis. Only nsamplesX * nsamplesY elements starting at (atX, atY) are used. The coefficients are stored in the array outputcoef (as 1D signal) that is adjusted to have (degree+2)* (degre+1)/2 elements. Call setNumberOfSamples() to set the number of samples to be used.
[in] | atX | origin X coordinate of the signal for this projection (relative to vector). |
[in] | atY | origin Y coordinate of the signal for this projection (relative to vector). |
[in] | vector | array (as 2D signal) containing components of the 2D vector to be projected onto the basis. |
[out] | outputcoef | array (as 1D signal) that receives the computed coefficients. It is adjusted to have (degree+2)*(degre+1)/2 elements. |
Implements gcgBASIS2D< NUMTYPE >.
|
virtual |
Computes the nsamplesX * nsamplesY components of a 2D vector, using the (degree+1)*(degree+2)/2 coefficients given in array inputcoef (as 1D signal). The components are stored in the 2D array outputvector (as 2D signal) starting at position (atX, atY). Call setNumberOfSamples() or synchBasisWithFile() to set the number of samples to be used.
[in] | atX | origin X coordinate of the signal for this projection (relative to outputvector). |
[in] | atY | origin Y coordinate of the signal for this projection (relative to outputvector). |
[in] | inputcoef | array (as 1D signal) of (degree+1)*(degree+2)/2 coefficients representing the vector to be reconstructed. |
[out] | outputvector | 2D array (as 2D signal) that receives the reconstructed vector. Must have room for nsamplesX * nsamplesY elements. |
Implements gcgBASIS2D< NUMTYPE >.
bool gcgLEGENDREBASIS2D< NUMTYPE >::setBasisDegree | ( | unsigned int | degree | ) |
Sets the maximum degree of the polynomials of the basis. The number of polynomials = (degree + 1)*(degree+2)/2.
[in] | degree | maximum degree of the polynomial basis. |
bool gcgLEGENDREBASIS2D< NUMTYPE >::setNumberOfSamples | ( | unsigned int | nsamplesX, |
unsigned int | nsamplesY | ||
) |
Sets the number of samples in X and Y directions for the discretization of polynomial functions. Call it (or call synchBasisWithFile()) BEFORE using getDiscreteValue(), projectSignal(), reconstructSignal() or basisInformation(). This method computes all polynomial basis vectors which might be slow if current degree is big.
[in] | nsamplesX | number of points in X. |
[in] | nsamplesY | number of points in Y. |
bool gcgLEGENDREBASIS2D< NUMTYPE >::synchBasisWithFile | ( | const char * | filename, |
unsigned int | nsamplesX, | ||
unsigned int | nsamplesY | ||
) |
Loads the basis functions of current degree, discretized with nsamplesX * nsamplesY elements, stored in the given file. All missing polynomials of the file are discretized and saved for further use. This function sychronizes file and memory polynomial functions and can considerably save time. Use this function instead of setNumberOfSamples() to avoid the computation of all basis functions that might be stored in the file.
[in] | filename | name of the file containing discretized polynomial basis. |
[in] | nsamplesX | number of points in X. |
[in] | nsamplesY | number of points in Y. |