ImFusion SDK 4.3
Curve Class Reference

#include <ImFusion/Base/Curve.h>

Interpolation and fitting of a 1D curve. More...

Detailed Description

Interpolation and fitting of a 1D curve.

If no x values are provided, equal-spaced data locations within 0..1 are used. Interpolation is done with Hermite cubic splines and conditioning to avoid overshoot of the curve.

Public Member Functions

 Curve (const std::vector< double > &y)
 Creates curve with equal-spaced data values to interpolate.
 
 Curve (const std::vector< double > &x, const std::vector< double > &y)
 Creates curve with arbitrary data positions and values.
 
 Curve (const std::vector< vec3 > &points)
 
bool fit (int n, bool adaptConst=false, bool optimize=false)
 Fit curve using desired dimension, optionally optimizing point locations.
 
const std::vector< double > & x () const
 Access to the support points of the curve.
 
const std::vector< double > & y () const
 Access to the function values of the curve.
 

Curve and error evaluation

Note
Perform an evaluation or error computation only after a successful run of fit(). Otherwise invalid results are returned.
double evaluate (double x) const
 
std::vector< double > evaluate (const std::vector< double > &x) const
 Evaluate the curve function at multiple locations.
 
void evaluate (std::vector< vec3 > &points) const
 Evaluate the curve at multiple locations and write the result back in the same vector.
 
std::vector< double > evaluate (int n) const
 Evaluate the curve with a chosen resolution.
 
double error (const std::vector< double > &y) const
 Compute the mean error of the curve and the provided regular spaced data.
 
double error (const std::vector< double > &x, const std::vector< double > &y) const
 Compute the mean error of the curve and the provided data in x and y.
 

Member Function Documentation

◆ fit()

bool fit ( int n,
bool adaptConst = false,
bool optimize = false )

Fit curve using desired dimension, optionally optimizing point locations.

Returns
False if no data point locations given in m_x, true otherwise.

◆ evaluate() [1/2]

double evaluate ( double x) const

Evaluate the curve function at a single location

◆ evaluate() [2/2]

std::vector< double > evaluate ( int n) const

Evaluate the curve with a chosen resolution.

The curve is evaluated with n samples in a regular grid defined by the minimum and maximum of the data point locations (not necessarily 0..1).


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close