golib
0.5
|
Curve representation. More...
#include <gocurve.h>
Public Member Functions | |
goCurve (goSize_t dim=2) | |
goCurve (const goCurve< T > &) | |
goCurve (const goList< goMath::Vector< T > > &) | |
goCurve (const goMath::Matrix< T > &confMatrix) | |
goCurve & | operator= (const goCurve< T > &) |
virtual bool | setPoints (const goList< goMath::Vector< T > > &) |
Set the point list. More... | |
virtual bool | setPoints (const goMath::Matrix< T > &) |
Set points from the rows of a configuration matrix. More... | |
bool | setPoints (typename goList< goMath::Vector< T > >::ConstElement *sourceBegin, goIndex_t sourcePointCount, goIndex_t destPointCount, bool closed=false) |
Resamples new points uniformly from given source points and sets the resampled points to this curve. More... | |
bool | setPoints (typename goList< goMath::Vector< T > >::ConstElement *sourceBegin, goIndex_t sourcePointCount, bool closed=false) |
Set points from source list. More... | |
bool | resample (goIndex_t pointCount, goList< goMath::Vector< T > > &ret) const |
bool | resample (goIndex_t pointCount, goCurve< T > &ret) const |
bool | getGradNorm (goArray< goFloat > &diffNorm) const |
bool | getGrad (goList< goMath::Vector< T > > &diff) const |
bool | getCurvNorm (goArray< goFloat > &curvNorm) const |
bool | getTurningFunction (goMath::Vector< T > &ret) const |
Turning function. More... | |
goDouble | getLength () const |
Calculate the length of the curve. More... | |
goDouble | euclideanDistance (const goCurve< T > &other, bool forward=true) const |
Calculate euclidean distance between two curves. More... | |
bool | sample (goDouble position, goMath::Vector< T > &ret) const |
Sample a point from the curve polygon. More... | |
bool | resample (goDouble start, goDouble end, goSize_t samples, goList< goMath::Vector< T > > &ret) const |
Resample from start to end given in length parameters. More... | |
bool | readASCII (FILE *f) |
Read curve points from ASCII C file stream into this curve. More... | |
bool | readASCII (const char *filename) |
bool | writeASCII (FILE *f) const |
bool | writeASCII (const char *filename) const |
bool | readASCIISimple (const char *filename, goSize_t dimension, bool closed) |
Read from a simple ASCII file (like for gnuplot) More... | |
goSize_t | removeDuplicates () |
goSize_t | removeCloseDuplicates (goDouble epsilon) |
virtual bool | callObjectMethod (int methodID, goObjectMethodParameters *param=NULL) |
Call an object method by identifier. More... | |
virtual bool | writeObjectFile (FILE *f) const |
Write the object to a file as goCurve. More... | |
virtual bool | readObjectFile (FILE *f) |
Read an object from a file as goCurve. More... | |
![]() | |
goPointCloud (goSize_t dim=2) | |
goPointCloud (const goPointCloud< T > &) | |
goPointCloud (const goList< goMath::Vector< T > > &) | |
goPointCloud (const goMath::Matrix< T > &) | |
goPointCloud< T > & | operator= (const goPointCloud< T > &) |
bool | operator!= (const goPointCloud< T > &other) const |
bool | operator== (const goPointCloud< T > &other) const |
goIndex_t | getPointCount () const |
Get number of points. More... | |
goList< goMath::Vector< T > > & | getPoints () |
Get list of points. More... | |
const goList< goMath::Vector< T > > & | getPoints () const |
Get list of points. More... | |
void | addPoint (const goMath::Vector< T > &p) |
Adds point to this cloud. More... | |
void | setChanged () |
goSize_t | getDim () const |
bool | getCenterOfMass (goMath::Vector< T > &comRet) const |
Calculates the center of mass of the point cloud. More... | |
bool | translate (const goMath::Vector< T > &d) |
Translate all points. More... | |
bool | scale (T s) |
Scale all points. More... | |
void | getConfigurationMatrix (goMath::Matrix< T > &cmRet) const |
Get matrix containing the point coordinates. More... | |
void | getConfigurationVector (goMath::Vector< T > &cvRet) const |
Get configuration vector. More... | |
bool | getPrincipalAxes2D (goMath::Vectorf &a1, goMath::Vectorf &a2, const goArray< goFloat > *weights=0) const |
Calculate 2 principal axes. More... | |
bool | getPrincipalAxes (goMath::Matrix< T > &axes) const |
bool | unitScale (goFloat factor=1.0f) |
template<class matrixT > | |
bool | transform (const matrixT &m) |
void | affineTransform (const goMath::Matrix< T > &m) |
![]() | |
goObjectBase () | |
Constructor. | |
virtual | ~goObjectBase () |
Destructor. More... | |
const char * | getClassName () const |
Returns the class name. More... | |
int | getClassID () const |
virtual goSize_t | memoryUsage () const |
Returns the size of this object or some measure of its memory consumption. More... | |
void | setObjectName (const char *name) |
Set name string for an object. More... | |
void | setObjectName (const goString &name) |
Set name string for an object. More... | |
const goString & | getObjectName () const |
Get the object name. More... | |
void | connectObject (goObjectBase *object) |
Connects an object to this object. More... | |
void | disconnectObject (const goObjectBase *object) |
Disconnects an object from this object. | |
virtual bool | queueObjectMethod (int methodID, goObjectMethodParameters *param=NULL, bool blocking=false) |
Enqueue a method call to an internal list of methods. More... | |
bool | callQueuedMethods () |
Call all queued methods. More... | |
Static Public Member Functions | |
static goDouble | getLength (const goList< goMath::Vector< T > > &pl) |
static bool | resample (typename goList< goMath::Vector< T > >::ConstElement *begin, goIndex_t pointCount, goIndex_t resamplePointCount, goList< goMath::Vector< T > > &ret, bool closedCurve) |
static bool | resampleLinear (typename goList< goMath::Vector< T > >::ConstElement *begin, goIndex_t pointCount, goIndex_t resamplePointCount, goList< goMath::Vector< T > > &ret, bool closedCurve) |
static bool | readASCII (FILE *f, goList< goMath::Vector< T > > &ret) |
Read curve points from an ASCII C file stream. More... | |
static bool | writeASCII (FILE *f, const goList< goMath::Vector< T > > &ret) |
Write point list in ASCII. More... | |
static goSize_t | removeDuplicates (goList< goMath::Vector< T > > &pl) |
Removes duplicate entries in the point list. More... | |
static goSize_t | removeCloseDuplicates (goList< goMath::Vector< T > > &pl, goDouble epsilon) |
Removes one of two consecutive when they are not more than epsilon apart. More... | |
static bool | filter (const goFloat *mask, goSize_t size, goSize_t center, goList< goMath::Vector< T > > &pl, goSize_t count=1) |
Filter the curve points with a linear filter mask. More... | |
![]() | |
static bool | getCenterOfMass (const goFixedArray< goMath::Vector< T > > &, goMath::Vector< T > &comRet) |
static bool | getPrincipalAxes (const goFixedArray< goMath::Vector< T > > &, goMath::Matrix< T > &axes) |
static bool | readASCII (const char *filename, goSize_t dimension, goList< goMath::Vector< T > > &pointList) |
Protected Member Functions | |
virtual void | receiveObjectMessage (const goObjectMessage &message) |
Receive a message. More... | |
![]() | |
void | setClassID (int id) |
Sets the class name. | |
void | printClassMessage (const char *msg) |
Sets the class name. More... | |
void | printClassMessage (goString &msg) |
Prints an informational message to the calling console. More... | |
void | sendObjectMessage (int messageID, void *data=NULL) |
Sends a message to all connected objects. | |
void | sendObjectMessage (goObjectBase *object, int messageID, void *data=NULL) |
Sends a message to a specific object. | |
Curve representation.
|
virtual |
Call an object method by identifier.
See the file goobjectmessage.h for messages and add messages there if needed. External applications building on this class should use identifiers starting with GO_OBJECTMETHOD_USER.
methodID | ID of the method. See goobjectmethod.h |
param | Pointer to parameters for the method, if any. |
Reimplemented from goPointCloud< T >.
goDouble goCurve< T >::euclideanDistance | ( | const goCurve< T > & | other, |
bool | forward = true |
||
) | const |
Calculate euclidean distance between two curves.
No transformations are applied to either curve, except reversal if the forward parameter is false. The distance is simply the sum of the distances between each point pair of the two curves.
other | Other curve. Must have same point count as this curve. |
forward | If false, the other curve will be reversed when calculating (the object itself ist not altered). Default is true. |
|
static |
Filter the curve points with a linear filter mask.
mask | Mask. |
size | Size of the mask. |
center | Center index of the mask. |
pointList | The points. |
count | The number of times to apply the filter mask (default: 1) |
goDouble goCurve< T >::getLength | ( | ) | const |
Calculate the length of the curve.
bool goCurve< T >::getTurningFunction | ( | goMath::Vector< T > & | ret | ) | const |
Turning function.
The turning function contains for each point p_i the angle between (p_{i-1},p_i) and (p_i,p_{i+1}). In case of non-closed curves, the first entry is defined to be zero, and there is one less entries than there are points. The turning function can be either positive or negative, depending on whether the corresponding point triple forms a triangle that turns clockwise or counterclockwise.
bool goCurve< T >::readASCII | ( | FILE * | f | ) |
Read curve points from ASCII C file stream into this curve.
f | C file stream. |
|
static |
Read curve points from an ASCII C file stream.
The curve points are expected in this format:
Silently assumes dimension is 2. ... curve\n <integer: number of points>\n <float: x coordinate point 1> <float: y coordinate point 1>\n ....
f | C stream pointer. |
ret | Contains points after method returns with true. |
bool goCurve< T >::readASCIISimple | ( | const char * | filename, |
goSize_t | dimension, | ||
bool | closed | ||
) |
Read from a simple ASCII file (like for gnuplot)
Each line starting with # is treated as comment as in goPointCloud<T>::readASCII().
filename | Name of the file. |
dimension | Dimension of the points (i.e. numbers per line). This may be less than the number of entries per line actually in the file, but it may not be larger. |
closed | If true, the point list will be closed. |
|
virtual |
Read an object from a file as goCurve.
f | Valid, open file. |
Reimplemented from goPointCloud< T >.
|
protectedvirtual |
Receive a message.
This function gets called each time another object "sends" a message to this object. Reimplement this in order to allow derived classes to react to messages.
Reimplemented from goPointCloud< T >.
|
static |
Removes one of two consecutive when they are not more than epsilon apart.
pl | |
epsilon |
|
static |
Removes duplicate entries in the point list.
pl | Point list. |
bool goCurve< T >::resample | ( | goDouble | start, |
goDouble | end, | ||
goSize_t | samples, | ||
goList< goMath::Vector< T > > & | ret | ||
) | const |
Resample from start to end given in length parameters.
start | Start (curve goes from 0.0 to getLength()) |
end | End |
samples | Number of samples |
ret | List of points for the result. |
|
static |
begin | |
pointCount | |
resamplePointCount | |
ret |
bool goCurve< T >::sample | ( | goDouble | position, |
goMath::Vector< T > & | ret | ||
) | const |
Sample a point from the curve polygon.
Interpolates linearly to sample points from the polygon defined by the points of this curve.
This is quite slow since potentially all points are searched, but appears to work.
position | Position on the curve in [0,this->getLength()] |
ret | On return, contains the point at position. |
|
virtual |
Set the point list.
points | List of points. This list will be deep-copied into the internal list. |
Reimplemented from goPointCloud< T >.
|
virtual |
Set points from the rows of a configuration matrix.
m | Matrix, each row containing one point. |
Reimplemented from goPointCloud< T >.
bool goCurve< T >::setPoints | ( | typename goList< goMath::Vector< T > >::ConstElement * | sourceBegin, |
goIndex_t | sourcePointCount, | ||
bool | closed = false |
||
) |
Set points from source list.
sourceBegin | First element of a point list. |
sourcePointCount | Number of points to copy. |
closed | If true, this curve's point list will be closed. |
bool goCurve< T >::setPoints | ( | typename goList< goMath::Vector< T > >::ConstElement * | sourceBegin, |
goIndex_t | sourcePointCount, | ||
goIndex_t | destPointCount, | ||
bool | closed = false |
||
) |
Resamples new points uniformly from given source points and sets the resampled points to this curve.
sourceBegin | First list element of source points. |
sourcePointCount | Number of source points. |
destPointCount | Number of points you want in this goCurve. |
closed | If true, assume the source and destination shall be closed. If false, they are open. |
|
static |
Write point list in ASCII.
Like readASCII(), assumes pointT is of size 2 at least (e.g. goPoint). This is sufficient so far, but extend if needed.
f | |
pointList |
|
virtual |
Write the object to a file as goCurve.
f | Valid, open file. |
Reimplemented from goPointCloud< T >.