golib  0.5
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
goCurve< T > Class Template Reference

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)
 
goCurveoperator= (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...
 
- Public Member Functions inherited from goPointCloud< T >
 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)
 
- Public Member Functions inherited from goObjectBase
 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 goStringgetObjectName () 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 Public Member Functions inherited from goPointCloud< T >
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...
 
- Protected Member Functions inherited from goObjectBase
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.
 

Detailed Description

template<class T>
class goCurve< T >

Curve representation.

Member Function Documentation

◆ callObjectMethod()

template<class T >
bool goCurve< T >::callObjectMethod ( int  methodID,
goObjectMethodParameters param = NULL 
)
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.

Note
Reimplement this in sub-classes as needed. The method should return true if the method call was successful. Values can also be returned through the goObjectMethodParameters* param.
Parameters
methodIDID of the method. See goobjectmethod.h
paramPointer to parameters for the method, if any.
Returns
True if successful, false otherwise.

Reimplemented from goPointCloud< T >.

◆ euclideanDistance()

template<class 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.

Parameters
otherOther curve. Must have same point count as this curve.
forwardIf false, the other curve will be reversed when calculating (the object itself ist not altered). Default is true.
Returns
Distance between this and other. If negative, an error occured (probably unequal point counts).

◆ filter()

template<class T >
bool goCurve< T >::filter ( const goFloat *  mask,
goSize_t  size,
goSize_t  center,
goList< goMath::Vector< T > > &  pointList,
goSize_t  count = 1 
)
static

Filter the curve points with a linear filter mask.

Parameters
maskMask.
sizeSize of the mask.
centerCenter index of the mask.
pointListThe points.
countThe number of times to apply the filter mask (default: 1)
Returns
True if successful, false otherwise.

◆ getLength()

template<class T >
goDouble goCurve< T >::getLength ( ) const

Calculate the length of the curve.

Returns
The length of the curve, i.e. the sum of the line segments connecting the given points on the curve. If the point list is closed, the curve is treated as closed and the line segment connecting the first and last point is added to the sum.

◆ getTurningFunction()

template<class T >
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.

Returns
True if successful, false otherwise.

◆ readASCII() [1/2]

template<class T >
bool goCurve< T >::readASCII ( FILE *  f)

Read curve points from ASCII C file stream into this curve.

See also
Static member readASCII.
Parameters
fC file stream.
Returns
True if successful, false otherwise.

◆ readASCII() [2/2]

template<class T >
bool goCurve< T >::readASCII ( FILE *  f,
goList< goMath::Vector< T > > &  ret 
)
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 ....

Parameters
fC stream pointer.
retContains points after method returns with true.
Returns
True if successful, false otherwise. Check log.

◆ readASCIISimple()

template<class T >
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().

Parameters
filenameName of the file.
dimensionDimension 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.
closedIf true, the point list will be closed.
Returns
True if successful, false otherwise. Also check the log file.

◆ readObjectFile()

template<class T >
bool goCurve< T >::readObjectFile ( FILE *  f)
virtual

Read an object from a file as goCurve.

Parameters
fValid, open file.
Returns
True if successful, false otherwise.

Reimplemented from goPointCloud< T >.

◆ receiveObjectMessage()

template<class T >
void goCurve< T >::receiveObjectMessage ( const goObjectMessage message)
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 >.

◆ removeCloseDuplicates()

template<class T >
goSize_t goCurve< T >::removeCloseDuplicates ( goList< goMath::Vector< T > > &  pl,
goDouble  epsilon 
)
static

Removes one of two consecutive when they are not more than epsilon apart.

Parameters
pl
epsilon
Returns
Number of removed points.

◆ removeDuplicates()

template<class T >
goSize_t goCurve< T >::removeDuplicates ( goList< goMath::Vector< T > > &  pl)
static

Removes duplicate entries in the point list.

Parameters
plPoint list.
Returns
Total number of removed entries.

◆ resample()

template<class T >
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.

Note
Remember that resampling does not preserve the original points except the first and last!
Parameters
startStart (curve goes from 0.0 to getLength())
endEnd
samplesNumber of samples
retList of points for the result.
Returns
True if successful, false otherwise.

◆ resampleLinear()

template<class T >
bool goCurve< T >::resampleLinear ( typename goList< goMath::Vector< T > >::ConstElement *  begin,
goIndex_t  pointCount,
goIndex_t  resamplePointCount,
goList< goMath::Vector< T > > &  ret,
bool  closedCurve 
)
static
Note
This uses linear splines. The original points are interpolated.
Parameters
begin
pointCount
resamplePointCount
ret
Returns
True if successful, false otherwise.

◆ sample()

template<class T >
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.

Parameters
positionPosition on the curve in [0,this->getLength()]
retOn return, contains the point at position.
Returns
True if successful, false otherwise (check logfile).

◆ setPoints() [1/4]

template<class T >
bool goCurve< T >::setPoints ( const goList< goMath::Vector< T > > &  points)
virtual

Set the point list.

Parameters
pointsList of points. This list will be deep-copied into the internal list.

Reimplemented from goPointCloud< T >.

◆ setPoints() [2/4]

template<class T >
bool goCurve< T >::setPoints ( const goMath::Matrix< T > &  m)
virtual

Set points from the rows of a configuration matrix.

Parameters
mMatrix, each row containing one point.
Returns
True if successful, false otherwise.

Reimplemented from goPointCloud< T >.

◆ setPoints() [3/4]

template<class T >
bool goCurve< T >::setPoints ( typename goList< goMath::Vector< T > >::ConstElement *  sourceBegin,
goIndex_t  sourcePointCount,
bool  closed = false 
)

Set points from source list.

Parameters
sourceBeginFirst element of a point list.
sourcePointCountNumber of points to copy.
closedIf true, this curve's point list will be closed.
Returns
True if successful, false otherwise.

◆ setPoints() [4/4]

template<class T >
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.

Parameters
sourceBeginFirst list element of source points.
sourcePointCountNumber of source points.
destPointCountNumber of points you want in this goCurve.
closedIf true, assume the source and destination shall be closed. If false, they are open.
Returns
True if successful, false otherwise.

◆ writeASCII()

template<class T >
bool goCurve< T >::writeASCII ( FILE *  f,
const goList< goMath::Vector< T > > &  pointList 
)
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.

Parameters
f
pointList
Returns

◆ writeObjectFile()

template<class T >
bool goCurve< T >::writeObjectFile ( FILE *  f) const
virtual

Write the object to a file as goCurve.

Parameters
fValid, open file.
Returns
True if successful, false otherwise.

Reimplemented from goPointCloud< T >.


The documentation for this class was generated from the following files: