16 template <
typename Real>
25 int degree,
int numControls);
57 template <
typename Real>
59 Real
const* sampleData,
int degree,
int numControls)
68 LogAssert(dimension >= 1,
"Invalid dimension.");
69 LogAssert(1 <= degree && degree < numControls,
"Invalid degree.");
70 LogAssert(sampleData,
"Invalid sample data.");
71 LogAssert(numControls <= numSamples,
"Invalid number of controls.");
83 Real factor = ((Real)1) / (Real)last;
84 for (
int i = 1; i < last; ++i)
97 Real tMultiplier = ((Real)1) / (Real)(
mNumSamples - 1);
99 int i0, i1, i2, imin, imax, j;
107 for (i1 = 0; i1 < i0; ++i1)
109 ATAMat(i0, i1) = ATAMat(i1, i0);
113 if (i1Max >= mNumControls)
115 i1Max = mNumControls - 1;
118 for (i1 = i0; i1 <= i1Max; ++i1)
120 Real
value = (Real)0;
123 t = tMultiplier * (Real)i2;
124 mBasis.Evaluate(t, 0, imin, imax);
125 if (imin <= i0 && i0 <= imax && imin <= i1 && i1 <= imax)
127 Real b0 =
mBasis.GetValue(0, i0);
128 Real b1 =
mBasis.GetValue(0, i1);
132 ATAMat(i0, i1) =
value;
138 memset(ATMat[0], 0, mNumControls *
mNumSamples *
sizeof(Real));
143 t = tMultiplier * (Real)i1;
144 mBasis.Evaluate(t, 0, imin, imax);
145 if (imin <= i0 && i0 <= imax)
147 ATMat[i0][i1] =
mBasis.GetValue(0, i0);
154 bool solved = ATAMat.template SolveSystem<true>(ATMat[0],
mNumSamples);
155 LogAssert(solved,
"Failed to solve linear system.");
167 Real xValue = ATMat[i0][i1];
191 template <
typename Real>
inline 197 template <
typename Real>
inline 203 template <
typename Real>
inline 209 template <
typename Real>
inline 215 template <
typename Real>
inline 221 template <
typename Real>
inline 227 template <
typename Real>
inline 233 template <
typename Real>
237 mBasis.Evaluate(t, 0, imin, imax);
240 Real basisValue =
mBasis.GetValue(0, imin);
243 position[j] = basisValue * (*source++);
246 for (
int i = imin + 1; i <= imax; ++i)
248 basisValue =
mBasis.GetValue(0, i);
251 position[j] += basisValue * (*source++);
#define LogAssert(condition, message)
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
BSplineCurveFit(int dimension, int numSamples, Real const *sampleData, int degree, int numControls)
GLsizei const GLfloat * value
BasisFunction< Real > const & GetBasis() const
void GetPosition(Real t, Real *position) const
Real const * GetSampleData() const
GLsizei GLsizei GLchar * source
GLenum GLenum GLenum input
Real const * GetControlData() const
std::vector< Real > mControlData
BasisFunction< Real > mBasis
int GetNumSamples() const
int GetNumControls() const