HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Spline Class Reference

#include <UT_Spline.h>

Public Member Functions

 UT_Spline ()
 
 ~UT_Spline ()
 
int64 getMemoryUsage (bool inclusive) const
 Return the amount of memory owned by this UT_Spline in bytes. More...
 
UT_SPLINE_BASIS getGlobalBasis () const
 Query the basis or knot length of the spline. More...
 
int getVectorSize () const
 
int getKnotLength () const
 
fpreal64 getTension () const
 
void setGlobalBasis (UT_SPLINE_BASIS b)
 
void setAllBases (UT_SPLINE_BASIS b)
 
void setSize (int nkeys, int vector_size)
 
void setTension (fpreal64 t)
 
void setBasis (int key, UT_SPLINE_BASIS b)
 
fpreal normalizeParameter (fpreal parm, fpreal t0, fpreal t1, int t0_index) const
 
fpreal solveSpline (fpreal parm, const UT_Array< fpreal > &knots, int *parm_knot_segment=nullptr, int order=0) const
 
void setValue (int key, const fpreal32 *value, int size)
 
void setValue (int key, const fpreal64 *value, int size)
 
bool evaluate (fpreal t, fpreal32 *result, int size, UT_ColorType interp_space, int order=0) const
 
bool evaluate (fpreal t, fpreal64 *result, int size, UT_ColorType interp_space, int order=0) const
 
bool evaluateMulti (fpreal t, fpreal32 *result, int n, UT_ColorType interp_space, int knot_segment_hint=-1, int order=0) const
 
bool evaluateMulti (fpreal t, fpreal64 *result, int n, UT_ColorType interp_space, int knot_segment_hint=-1, int order=0) const
 

Static Public Member Functions

template<typename T >
static T evalCubic (T kt, T dt, T iv, T im, T ov, T om, int order=0)
 
template<typename T >
static T evalQuintic (T kt, T dt, T iv, T im, T ia, T ov, T om, T oa, int order=0)
 
static fpreal64 getMonotoneSlopeFC (fpreal64 v_cur, fpreal64 t_cur, fpreal64 v_prev, fpreal64 t_prev, fpreal64 v_next, fpreal64 t_next)
 
static fpreal64 getMonotoneSlopePA (fpreal64 v_cur, fpreal64 t_cur, fpreal64 v_prev, fpreal64 t_prev, fpreal64 v_next, fpreal64 t_next)
 

Detailed Description

The Linear & Catmull-Rom splines expect a parametric coordinate for evaluation between 0 and 1. The Catmull-Rom spline requires additional key values at the beginning and end of the spline to evaluate the slopes of the Hermite spline properly.

The LinearSolve only works on scalar values. It will compute the parametric coordinate associated with the value passed in. This can be used to simulate non-uniform keys on the spline.

Definition at line 721 of file UT_Spline.h.

Constructor & Destructor Documentation

UT_Spline::UT_Spline ( )
UT_Spline::~UT_Spline ( )

Member Function Documentation

template<typename T >
static T UT_Spline::evalCubic ( T  kt,
T  dt,
T  iv,
T  im,
T  ov,
T  om,
int  order = 0 
)
inlinestatic

Given the keys surrounding a channel segment, evaluate it as cubic hermite spline. This function assumes dt > 0. kt is [0,1] which maps over the dt time interval. The order-th derivative with respect to kt is returned. In particular, for order == 0 (default), the value is returned.

Definition at line 840 of file UT_Spline.h.

template<typename T >
static T UT_Spline::evalQuintic ( T  kt,
T  dt,
T  iv,
T  im,
T  ia,
T  ov,
T  om,
T  oa,
int  order = 0 
)
inlinestatic

Given the keys surrounding a channel segment, evaluate it as a quintic hermite spline. See evalCubic above.

Definition at line 864 of file UT_Spline.h.

bool UT_Spline::evaluate ( fpreal  t,
fpreal32 result,
int  size,
UT_ColorType  interp_space,
int  order = 0 
) const

Evaluate the spline using the global basis. When interp_space is not UT_RGB, then values are treated as UT_RGBA and converted into the desired color space before being interpolated. The result is always returned as UT_RGBA.

If order == 0, the value is returned. If order == 1, the derivative with respect to t is returned.

bool UT_Spline::evaluate ( fpreal  t,
fpreal64 result,
int  size,
UT_ColorType  interp_space,
int  order = 0 
) const

Evaluate the spline using the global basis. When interp_space is not UT_RGB, then values are treated as UT_RGBA and converted into the desired color space before being interpolated. The result is always returned as UT_RGBA.

If order == 0, the value is returned. If order == 1, the derivative with respect to t is returned.

bool UT_Spline::evaluateMulti ( fpreal  t,
fpreal32 result,
int  n,
UT_ColorType  interp_space,
int  knot_segment_hint = -1,
int  order = 0 
) const

Evaluate the spline using multiple basis types depending on t. Also unlike evaluate(), evaluateMulti() doesn't require extra keys for Catmull-Rom on the ends. It always evaluates using a 0 slope at the ends.

If order == 0, the value is returned. If order == 1, the derivative with respect to t is returned.

bool UT_Spline::evaluateMulti ( fpreal  t,
fpreal64 result,
int  n,
UT_ColorType  interp_space,
int  knot_segment_hint = -1,
int  order = 0 
) const

Evaluate the spline using multiple basis types depending on t. Also unlike evaluate(), evaluateMulti() doesn't require extra keys for Catmull-Rom on the ends. It always evaluates using a 0 slope at the ends.

If order == 0, the value is returned. If order == 1, the derivative with respect to t is returned.

UT_SPLINE_BASIS UT_Spline::getGlobalBasis ( ) const
inline

Query the basis or knot length of the spline.

Definition at line 730 of file UT_Spline.h.

int UT_Spline::getKnotLength ( ) const
inline

Definition at line 732 of file UT_Spline.h.

int64 UT_Spline::getMemoryUsage ( bool  inclusive) const

Return the amount of memory owned by this UT_Spline in bytes.

static fpreal64 UT_Spline::getMonotoneSlopeFC ( fpreal64  v_cur,
fpreal64  t_cur,
fpreal64  v_prev,
fpreal64  t_prev,
fpreal64  v_next,
fpreal64  t_next 
)
static

Return monotone cubic Hermite slopes at the current knot given the previous and next knots. Fritsch-Carlson (local) method. It gives relatively good looking C1 curves but might not give a C2 solution even if it exists.

  1. Fritsch, F.N., Carlson, R.E., Monotone piecewise cubic interpolant, SIAM J. Numer. Anal., 17(1980), 238-246.
static fpreal64 UT_Spline::getMonotoneSlopePA ( fpreal64  v_cur,
fpreal64  t_cur,
fpreal64  v_prev,
fpreal64  t_prev,
fpreal64  v_next,
fpreal64  t_next 
)
static

Paul Kupan's method. Similar to Fritsch-Carlson method except it gives more visually pleasing results when the intervals next to the knot are uneven.

  1. Kupan, P.A., Monotone Interpolant Built with Slopes Obtained by Linear Combination, Studia Universitatis Babes-Bolyai Mathematica, 53(2008), 59-66.
fpreal64 UT_Spline::getTension ( ) const
inline

Definition at line 733 of file UT_Spline.h.

int UT_Spline::getVectorSize ( ) const
inline

Definition at line 731 of file UT_Spline.h.

fpreal UT_Spline::normalizeParameter ( fpreal  parm,
fpreal  t0,
fpreal  t1,
int  t0_index 
) const

Given the position within the two knots and the first knot index number, normalize the position from knot-length domain to unit domain.

void UT_Spline::setAllBases ( UT_SPLINE_BASIS  b)

Sets the spline's global basis to b, and also set the basis of every knot to b.

void UT_Spline::setBasis ( int  key,
UT_SPLINE_BASIS  b 
)

Set the basis for the given key index. This will also set the global basis.

void UT_Spline::setGlobalBasis ( UT_SPLINE_BASIS  b)
inline

Definition at line 735 of file UT_Spline.h.

void UT_Spline::setSize ( int  nkeys,
int  vector_size 
)

Construction of the spline object. All values are initialized to 0. Warning, calling setSize() will clear all existing values.

void UT_Spline::setTension ( fpreal64  t)

Cubic splines may have a "tension". The tension defaults to 0.5 which results in Catmull-Rom splines.

void UT_Spline::setValue ( int  key,
const fpreal32 value,
int  size 
)

Once the spline has been constructed, the values need to be set. It is possible to change values between evaluations.

void UT_Spline::setValue ( int  key,
const fpreal64 value,
int  size 
)

Once the spline has been constructed, the values need to be set. It is possible to change values between evaluations.

fpreal UT_Spline::solveSpline ( fpreal  parm,
const UT_Array< fpreal > &  knots,
int parm_knot_segment = nullptr,
int  order = 0 
) const

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