Honeycomb  0.1
Component-Model Framework
Static Public Member Functions | List of all members
honey::Interp_< Real > Class Template Reference

Interpolation math. More...

#include <Quat.h>

Inheritance diagram for honey::Interp_< Real >:
Inheritance graph
[legend]
Collaboration diagram for honey::Interp_< Real >:
Collaboration graph
[legend]

Static Public Member Functions

template<class T >
static T linear (Real t, const T &a, const T &b)
 Linear interpolation. t range is [0,1]. More...
 
static Quat linear (Real t, const Quat &a, const Quat &b)
 
static Transform linear (Real t, const Transform &a, const Transform &b)
 
static Real linearAngle (Real t, Real angleStart, Real angleEnd, optional< int & > rotSign=optnull)
 Linearly interpolate angles along the shortest path. Angles must be normalized. t range is [0,1]. rotSign is the direction rotated: (-ve, +ve, none) = (-1,1,0) More...
 
static void alignDir (Vec3 &dir, const Vec3 &targetDir, Real angleAmount, optional< int & > rotSign=optnull)
 Align a normalized direction towards a target direction, rotating around the Y axis, stepping angleAmount. rotSign is the direction rotated: (-ve, +ve, none) = (-1,1,0) More...
 
template<class T >
static T baryCentric (Real f, Real g, const T &x0, const T &x1, const T &x2)
 Triangular bary-centric interpolation. More...
 
static Quat baryCentric (Real f, Real g, const Quat &q0, const Quat &q1, const Quat &q2)
 
static Transform baryCentric (Real f, Real g, const Transform &tm0, const Transform &tm1, const Transform &tm2)
 
template<class Range , class Seq >
static auto blend (Range &&vals, Seq &&weights_) -> mt_elemOf(vals)
 Linearly blend a range of values by applying an associated weight to each value. If all weights are 0 then the first value is returned. More...
 
static Real sin (Real t, bool smoothIn, bool smoothOut)
 Sin interpolation. More...
 
static Real gaussian (Real x, Real offset, Real scale)
 Gaussian / Normal distribution. The standard distribution parameters are (offset, scale) = (0, 1) More...
 
template<class T >
static MatrixBase< T >::MatrixS gaussian (const MatrixBase< T > &x, const MatrixBase< T > &offset, const MatrixBase< T > &scale)
 Perform gaussian for each element. More...
 
template<class T >
static T bezier (Real t, const T &v0, const T &v1, const T &v2, const T &v3)
 Interpolate along a Bezier curve passing through v0 and v3, using handles (control points) v1 and v2. The handles shape the curve and typically don't lie on it. More...
 
static tuple< Vec3, int > bezierRoots (Real y, Real v0, Real v1, Real v2, Real v3)
 Find roots of bezier function at y-intercept y More...
 
static tuple< Vec2, Vec2bezierNormalizeHandles (const Vec2 &v0, const Vec2 &v1, const Vec2 &v2, const Vec2 &v3)
 Given a bezier curve with dim (time, value), normalize the handles (v1,v2) such that there is only 1 root at any point along the time axis. More...
 
static Real bezierAtTime (Real time, const Vec2 &v0, const Vec2 &v1, const Vec2 &v2, const Vec2 &v3)
 Given a bezier curve with dim (time, value), get value on curve parameterized by time in range [0,1]. More...
 
static Real bezierAngleAtTime (Real time, const Vec2 &v0, const Vec2 &v1, const Vec2 &v2, const Vec2 &v3)
 Similar to bezierAtTime() except the value is interpolated by taking the shortest angular path. More...
 
static void bezierSubdiv (vector< Vec2 > &cs, int index, Real t)
 Subdivide a bezier curve segment at index (4 control points) by curve param 't' [0,1]. Replaces curve segment with equivalent left/right segments (7 control points) More...
 
static Real bezierSubdivAdapt (vector< Vec2 > &cs, int index, Real tol=0.01)
 Adaptively subdivide a bezier curve segment at index (4 control points). Subdivides curve segment until the arc length does not change more than the given tolerance. More...
 
static Matrix4 bezierPatchCoeff (const Matrix4 &val)
 Bezier 2D patch coefficient matrix generator. More...
 
static Real bezierPatch (const Matrix4 &coeff, Real x, Real y)
 Bezier 2D patch interpolation. More...
 
template<class T >
static T catmull (Real t, const T &v0, const T &v1, const T &v2, const T &v3)
 Interpolate along a Catmull-Rom curve passing through v1 and v2, using handles (control points) v0 and v3. The spline (piecewise curve) will pass through all control points. More...
 
static Matrix4 catmullPatchCoeff (const Matrix4 &val)
 Catmull-rom 2D patch coefficient matrix generator. More...
 
static Real catmullPatch (const Matrix4 &coeff, Real x, Real y)
 Catmull-rom 2D patch interpolation. More...
 

Detailed Description

template<class Real>
class honey::Interp_< Real >

Interpolation math.

Member Function Documentation

template<class Real >
void honey::Interp_< Real >::alignDir ( Vec3 dir,
const Vec3 targetDir,
Real  angleAmount,
optional< int & >  rotSign = optnull 
)
static

Align a normalized direction towards a target direction, rotating around the Y axis, stepping angleAmount. rotSign is the direction rotated: (-ve, +ve, none) = (-1,1,0)

template<class Real >
template<class T >
static T honey::Interp_< Real >::baryCentric ( Real  f,
Real  g,
const T &  x0,
const T &  x1,
const T &  x2 
)
inlinestatic

Triangular bary-centric interpolation.

Input -> Output:

(0,0)    -> x0          (1,0) -> x1         (0,1) -> x2
1-f-g==0 -> line x1,x2  (f,0) -> line x0,x1 (0,g) -> line x0,x2
template<class Real >
static Quat honey::Interp_< Real >::baryCentric ( Real  f,
Real  g,
const Quat q0,
const Quat q1,
const Quat q2 
)
inlinestatic
template<class Real >
static Transform honey::Interp_< Real >::baryCentric ( Real  f,
Real  g,
const Transform tm0,
const Transform tm1,
const Transform tm2 
)
inlinestatic
template<class Real >
template<class T >
static T honey::Interp_< Real >::bezier ( Real  t,
const T &  v0,
const T &  v1,
const T &  v2,
const T &  v3 
)
inlinestatic

Interpolate along a Bezier curve passing through v0 and v3, using handles (control points) v1 and v2. The handles shape the curve and typically don't lie on it.

Parameters
tdistance along curve [0-1]
v0start point
v1start handle
v2end handle
v3end point
Returns
interpolated value
template<class Real >
Real honey::Interp_< Real >::bezierAngleAtTime ( Real  time,
const Vec2 v0,
const Vec2 v1,
const Vec2 v2,
const Vec2 v3 
)
static

Similar to bezierAtTime() except the value is interpolated by taking the shortest angular path.

template<class Real >
Real honey::Interp_< Real >::bezierAtTime ( Real  time,
const Vec2 v0,
const Vec2 v1,
const Vec2 v2,
const Vec2 v3 
)
static

Given a bezier curve with dim (time, value), get value on curve parameterized by time in range [0,1].

template<class Real >
auto honey::Interp_< Real >::bezierNormalizeHandles ( const Vec2 v0,
const Vec2 v1,
const Vec2 v2,
const Vec2 v3 
)
static

Given a bezier curve with dim (time, value), normalize the handles (v1,v2) such that there is only 1 root at any point along the time axis.

template<class Real >
static Real honey::Interp_< Real >::bezierPatch ( const Matrix4 coeff,
Real  x,
Real  y 
)
inlinestatic

Bezier 2D patch interpolation.

Parameters
coeffpatch coefficient matrix
xeval point X [0-1]
yeval point Y [0-1]
Returns
interpolated value
See also
bezierPatchCoeff() to generate coeff
template<class Real >
static Matrix4 honey::Interp_< Real >::bezierPatchCoeff ( const Matrix4 val)
inlinestatic

Bezier 2D patch coefficient matrix generator.

Parameters
vala 4x4 grid of control points to interpolate
Return values
patch
See also
bezierPatch() to evaluate patch
template<class Real >
auto honey::Interp_< Real >::bezierRoots ( Real  y,
Real  v0,
Real  v1,
Real  v2,
Real  v3 
)
static

Find roots of bezier function at y-intercept y

Return values
roots
rootCount
template<class Real >
void honey::Interp_< Real >::bezierSubdiv ( vector< Vec2 > &  cs,
int  index,
Real  t 
)
static

Subdivide a bezier curve segment at index (4 control points) by curve param 't' [0,1]. Replaces curve segment with equivalent left/right segments (7 control points)

template<class Real >
Real honey::Interp_< Real >::bezierSubdivAdapt ( vector< Vec2 > &  cs,
int  index,
Real  tol = 0.01 
)
static

Adaptively subdivide a bezier curve segment at index (4 control points). Subdivides curve segment until the arc length does not change more than the given tolerance.

Returns
Bezier curve arc length
template<class Real >
template<class Range , class Seq >
static auto honey::Interp_< Real >::blend ( Range &&  vals,
Seq &&  weights_ 
) -> mt_elemOf(vals)
inlinestatic

Linearly blend a range of values by applying an associated weight to each value. If all weights are 0 then the first value is returned.

template<class Real >
template<class T >
static T honey::Interp_< Real >::catmull ( Real  t,
const T &  v0,
const T &  v1,
const T &  v2,
const T &  v3 
)
inlinestatic

Interpolate along a Catmull-Rom curve passing through v1 and v2, using handles (control points) v0 and v3. The spline (piecewise curve) will pass through all control points.

Parameters
tdistance along curve [0-1]
v0start handle
v1start point
v2end point
v3end handle
Returns
interpolated value
template<class Real >
static Real honey::Interp_< Real >::catmullPatch ( const Matrix4 coeff,
Real  x,
Real  y 
)
inlinestatic

Catmull-rom 2D patch interpolation.

Parameters
coeffpatch coefficient matrix
xeval point X [0-1]
yeval point Y [0-1]
Returns
interpolated value
See also
catmullPatchCoeff() to generate coeff
template<class Real >
static Matrix4 honey::Interp_< Real >::catmullPatchCoeff ( const Matrix4 val)
inlinestatic

Catmull-rom 2D patch coefficient matrix generator.

Parameters
vala 4x4 grid of control points to interpolate
Return values
patch
See also
catmullPatch() to evaluate patch
template<class Real >
static Real honey::Interp_< Real >::gaussian ( Real  x,
Real  offset,
Real  scale 
)
inlinestatic

Gaussian / Normal distribution. The standard distribution parameters are (offset, scale) = (0, 1)

template<class Real >
template<class T >
static MatrixBase<T>::MatrixS honey::Interp_< Real >::gaussian ( const MatrixBase< T > &  x,
const MatrixBase< T > &  offset,
const MatrixBase< T > &  scale 
)
inlinestatic

Perform gaussian for each element.

template<class Real >
template<class T >
static T honey::Interp_< Real >::linear ( Real  t,
const T &  a,
const T &  b 
)
inlinestatic

Linear interpolation. t range is [0,1].

template<class Real >
static Quat honey::Interp_< Real >::linear ( Real  t,
const Quat a,
const Quat b 
)
inlinestatic
template<class Real >
static Transform honey::Interp_< Real >::linear ( Real  t,
const Transform a,
const Transform b 
)
inlinestatic
template<class Real >
Real honey::Interp_< Real >::linearAngle ( Real  t,
Real  angleStart,
Real  angleEnd,
optional< int & >  rotSign = optnull 
)
static

Linearly interpolate angles along the shortest path. Angles must be normalized. t range is [0,1]. rotSign is the direction rotated: (-ve, +ve, none) = (-1,1,0)

template<class Real >
static Real honey::Interp_< Real >::sin ( Real  t,
bool  smoothIn,
bool  smoothOut 
)
inlinestatic

Sin interpolation.

Parameters
tdistance along curve [0,1]
smoothInwhether to accelerate into the curve starting at 0
smoothOutwhether to decelerate out of the curve ending at 1
Returns
interpolated value in range [0,1]

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