Foundation (CVFoundation.dll) 15.0
2D curve functions

Export of 2D curve functions. More...

Data Structures

struct  CVFAlignment2DResult
 
struct  CVFAlignmentConfiguration
 

Functions

cvbres_t CVFAlignCurves2D (const CVIPointD *Curve, cvbdim_t CurveLength, const CVIPointD *CurveToBeAligned, cvbdim_t CurveToBeAlignedLength, const CVFAlignmentConfiguration &Config, CVFAlignment2DResult &Result)
 Aligns two 2D curves via an iterative closest point method considering consensus correspondence for better shape alignment. More...
 
cvbres_t CVFCalculateEnclosedArea (const CVIPointD *Curve, cvbdim_t CurveLength, double *EnclosedArea)
 Calculates the enclosed area of the given curve. More...
 
cvbres_t CVFCalculateQuadraticDifferencesToClosestPoint (const CVIPointD *Curve, cvbdim_t CurveLength, const CVIPointD *Points, cvbdim_t PointsLength, double *Differences)
 Calculates the quadratic distance of Points to closest point of given Curve (Points of Curve - Points). More...
 
cvbres_t CVFCalculateSignedDifferences (const CVIPointD *Curve, cvbdim_t CurveLength, const CVIPointD *Points, cvbdim_t PointsLength, double *SignedDifferences)
 Calculates signed differences along the y axis of given points to curve (Curve - Points). More...
 
cvbres_t CVFIntersectCurve2DWithLine (const CVIPointD *Curve, cvbdim_t CurveLength, CVIPointD Normal, double DistanceToOrigin, cvbdim_t IntersectionPointsLength, CVIPointD *IntersectionPoints, cvbdim_t &IntersectionPointsCalculatedLength)
 Intersects a 2D curve with a line. More...
 
cvbres_t CVFMerge2Curves (const CVIPointD *CurveLHS, cvbdim_t CurveLengthLHS, const CVIPointD *CurveRHS, cvbdim_t CurveLengthRHS, cvbbool_t sort, cvbdim_t CurveOutAllocatedLength, CVIPointD *CurveOut, cvbdim_t &CurveOutLength)
 Merges two curves into one curve with interpolation. More...
 
cvbres_t CVFResampleCurve2D (const CVIPointD *Curve, cvbdim_t CurveLength, cvbdim_t ResampledCurveLength, CVIPointD *ResampledCurve)
 Resamples a 2-dimensional curve via linear interpolation assuming that the "speed" of the time mapping is constant. More...
 

Detailed Description

Export of 2D curve functions.

Function Documentation

◆ CVFAlignCurves2D()

cvbres_t CVFAlignCurves2D ( const CVIPointD Curve,
cvbdim_t  CurveLength,
const CVIPointD CurveToBeAligned,
cvbdim_t  CurveToBeAlignedLength,
const CVFAlignmentConfiguration Config,
CVFAlignment2DResult Result 
)

Aligns two 2D curves via an iterative closest point method considering consensus correspondence for better shape alignment.

The method used here is a version of the ICP (iterative closest point) method. It uses a consensus metric to find the correspondence between points to stabilize the iterations needed in the alignment method. It supports only rigid transformations for the alignment. If not enough points within a given consens are found a classical ICP step is performed by finding correspondences solely based on nearest neighbours without any feasibility check.

Attention
Memory of size CurveLength*sizeof(CVIPointD) bytes has to be allocated by the caller for Curve! Same for CurveToBeAligned and CurveToBeAlignedLength.
Parameters
[in]CurveReference curve.
[in]CurveLengthLength of Curve.
[in]CurveToBeAlignedCurve to be aligned to Curve.
[in]CurveToBeAlignedLengthLength of CurveToBeAligned.
[in]ConfigConfiguration of alignment.
[out]ResultAlignment result.
Returns

◆ CVFCalculateEnclosedArea()

cvbres_t CVFCalculateEnclosedArea ( const CVIPointD Curve,
cvbdim_t  CurveLength,
double *  EnclosedArea 
)

Calculates the enclosed area of the given curve.

Uses the shoelace algorithm to calculate the enclosed area of the given curve. All points are assumed to be in order, clockwise or anticlockwise will not affect the outcome. This algorithm can only handle not self intersecting curves, e.g. a figure eight curve will not work with this algorithm.

For numerical stabilization all points are shifted to be centered around the origin.

If the curve is not closed, i.e. the first and last point in the given point set don't match, the curve is closed automatically by connecting the first and last point.

Note
The points on the curve are evaluated in the order in which they are listed. We assume an ordered point set (not ordered by axis, but ordered according to the curve).
Parameters
[in]CurveCurve.
[in]CurveLengthLength of Curve.
[out]EnclosedAreaThe enclosed of the given Curve as double.
Returns

◆ CVFCalculateQuadraticDifferencesToClosestPoint()

cvbres_t CVFCalculateQuadraticDifferencesToClosestPoint ( const CVIPointD Curve,
cvbdim_t  CurveLength,
const CVIPointD Points,
cvbdim_t  PointsLength,
double *  Differences 
)

Calculates the quadratic distance of Points to closest point of given Curve (Points of Curve - Points).

Note
The points have to be ordered by time, i.e. two consecutive points must adjoin another on the curve.

For the calculation of the signed differences the curve is assumed to be infinite. It is extended at the starting and endpoint.

Attention
Memory of size PointsLength*sizeof(double) bytes has to be allocated by the caller for Differences!
Parameters
[in]CurveCurve.
[in]CurveLengthLength of Curve.
[in]PointsPoints.
[in]PointsLengthLength of Points.
[out]DifferencesArray of length PointsLength to receive differences.
Returns

◆ CVFCalculateSignedDifferences()

cvbres_t CVFCalculateSignedDifferences ( const CVIPointD Curve,
cvbdim_t  CurveLength,
const CVIPointD Points,
cvbdim_t  PointsLength,
double *  SignedDifferences 
)

Calculates signed differences along the y axis of given points to curve (Curve - Points).

Note
The points have to be ordered by time, i.e. two consecutive points must adjoin another on the curve.

For the calculation of the signed differences the curve is assumed to be infinite. It is extended at the starting and endpoint.

Attention
Memory of size PointsLength*sizeof(double) bytes has to be allocated by the caller for SignedDifferences!
Parameters
[in]CurveCurve.
[in]CurveLengthLength of Curve.
[in]PointsPoints.
[in]PointsLengthLength of Points.
[out]SignedDifferencesArray of length PointsLength to receive signed differences.
Returns

◆ CVFIntersectCurve2DWithLine()

cvbres_t CVFIntersectCurve2DWithLine ( const CVIPointD Curve,
cvbdim_t  CurveLength,
CVIPointD  Normal,
double  DistanceToOrigin,
cvbdim_t  IntersectionPointsLength,
CVIPointD IntersectionPoints,
cvbdim_t &  IntersectionPointsCalculatedLength 
)

Intersects a 2D curve with a line.

The line is defined by the hessian normal form:

normal* x = d, with | Normal | = 1 and d > 0.

Note
The points have to be ordered by time, i.e. two consecutive points must adjoin another on the curve.

The curve is finite. It starts and ends at the first and last point respectively.

Attention
Memory of size CurveLength*sizeof(CVIPointD) bytes has to be allocated by the caller for IntersectionPoints. The number of intersection points IntersectionPointsLength will be calculated with this function and will be lower than CurveLength.
Parameters
[in]CurveCurve to be intersected.
[in]CurveLengthLength of Curve.
[in]NormalNormal of line (Hessian normal form).
[in]DistanceToOriginDistance of line to origin (Hessian normal form).
[in]IntersectionPointsLengthLength of IntersetionPoints allocated by the caller.
[out]IntersectionPointsArray which receives calculated intersection points.
[out]IntersectionPointsCalculatedLengthNumber of calculated intersection points.
Returns

◆ CVFMerge2Curves()

cvbres_t CVFMerge2Curves ( const CVIPointD CurveLHS,
cvbdim_t  CurveLengthLHS,
const CVIPointD CurveRHS,
cvbdim_t  CurveLengthRHS,
cvbbool_t  sort,
cvbdim_t  CurveOutAllocatedLength,
CVIPointD CurveOut,
cvbdim_t &  CurveOutLength 
)

Merges two curves into one curve with interpolation.

Takes two curves and merges them into one combined curve. If they overlap, an interpolation method is used to find a suitable approximation. This interpolation is done when switching between the two curves while the points are interleaved. The order in which the points are interleaved is defined by the closest neighbour for each point from CurveRHS to CurveLHS.

This method works with curves in 2D.

If sort is set true, then the best starting point of the two possible starting points (each of the given curve statrint points is a valid choice). This means, the algorithm checks which starting point from the two staring points is the best starting point for the merged curve. To make this decision the distance from each possible starting point to the other given curve is calculated and the point with the highest distance is taken as the overall starting point for the new generated merged curve. This method does work well for regular curves (not self intercepting curves). It can be switched off to save computation time if the caller is sure about the correct order.

Note
The points on the curve are evaluated in the order in which they are listed. We assume an ordered point set (not ordered by axis, but ordered according to the curve).
Parameters
[in]CurveLHSLeft hand side curve. This curve is assumed starting point if sort is false.
[in]CurveLengthLHSLength of CurveLHS.
[in]CurveRHSright hand side curve
[in]CurveLengthRHSLength of CurveRHS
[in]sortBoolean to decide if left and right order of the two curves is to be found by the algorithm.
[in]CurveOutAllocatedLengthLength of CurveOut allocated by the caller. The maximum possible length of a merged curve is the sum of lengths of both input curves, the minimum length is the maximum length of both input curves.
[out]CurveOutMerged curve
[out]CurveOutLengthlength of the merged curve
Returns

◆ CVFResampleCurve2D()

cvbres_t CVFResampleCurve2D ( const CVIPointD Curve,
cvbdim_t  CurveLength,
cvbdim_t  ResampledCurveLength,
CVIPointD ResampledCurve 
)

Resamples a 2-dimensional curve via linear interpolation assuming that the "speed" of the time mapping is constant.

Note
The points have to be ordered by time, i.e. two consecutive points must adjoin another on the curve.
Attention
Memory of size ResampledCurveLength*sizeof(CVIPointD) bytes has to be allocated by the caller for ResampledCurve!
Parameters
[in]CurveCurve to be resampled.
[in]CurveLengthLength of Curve.
[in]ResampledCurveLengthLength of ResampledCurve.
[out]ResampledCurveArray of length ResampledCurveLength to receive resampled curve.
Returns