本文整理汇总了C++中Bezier::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Bezier::clear方法的具体用法?C++ Bezier::clear怎么用?C++ Bezier::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bezier
的用法示例。
在下文中一共展示了Bezier::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sbasis_to_bezier
/** Changes the basis of p to be bernstein.
\param p the Symmetric basis polynomial
\returns the Bernstein basis polynomial
if the degree is even q is the order in the symmetrical power basis,
if the degree is odd q is the order + 1
n is always the polynomial degree, i. e. the Bezier order
sz is the number of bezier handles.
*/
void sbasis_to_bezier (Bezier & bz, SBasis const& sb, size_t sz)
{
if (sb.size() == 0) {
THROW_RANGEERROR("size of sb is too small");
}
size_t q, n;
bool even;
if (sz == 0)
{
q = sb.size();
if (sb[q-1][0] == sb[q-1][1])
{
even = true;
--q;
n = 2*q;
}
else
{
even = false;
n = 2*q-1;
}
}
else
{
q = (sz > 2*sb.size()-1) ? sb.size() : (sz+1)/2;
n = sz-1;
even = false;
}
bz.clear();
bz.resize(n+1);
double Tjk;
for (size_t k = 0; k < q; ++k)
{
for (size_t j = k; j < n-k; ++j) // j <= n-k-1
{
Tjk = binomial(n-2*k-1, j-k);
bz[j] += (Tjk * sb[k][0]);
bz[n-j] += (Tjk * sb[k][1]); // n-k <-> [k][1]
}
}
if (even)
{
bz[q] += sb[q][0];
}
// the resulting coefficients are with respect to the scaled Bernstein
// basis so we need to divide them by (n, j) binomial coefficient
for (size_t j = 1; j < n; ++j)
{
bz[j] /= binomial(n, j);
}
bz[0] = sb[0][0];
bz[n] = sb[0][1];
}