VTK  9.7.20260922
EdgeCnBasis.h
Go to the documentation of this file.
1// Bernstein-Bezier basis functions of arbitrary order on the reference edge.
2//
3// The Bernstein polynomials are defined on [0, 1] while the reference edge is
4// parameterized over [-1, 1], so the coordinate is mapped with x = (rr + 1)/2:
5//
6// B_{n,k}(x) = C(n,k) x^k (1-x)^(n-k)
7//
8// Unlike a Lagrange basis these do not interpolate their control values except
9// at the two ends of the edge, but they are non-negative and sum to one, so the
10// curve lies within the convex hull of its control points.
11//
12// The powers and the binomial coefficient are accumulated rather than computed
13// with pow() and a binomial() helper. Neither is portable to GLSL, where these
14// kernels are also compiled: there is no binomial(), and pow(0, 0) is undefined
15// there - which is exactly what the ends of the edge would ask for.
16RealT xx = 0.5 * (rr + 1.);
17RealT yy = 1. - xx;
18
19WORKSPACE(RealT, xpow, order[0] + 1);
20WORKSPACE(RealT, ypow, order[0] + 1);
21// xpow[k] holds x^k and ypow[k] holds (1-x)^(n-k).
22xpow[0] = 1.;
23for (int kk = 1; kk <= order[0]; ++kk)
24{
25 xpow[kk] = xpow[kk - 1] * xx;
26}
27ypow[order[0]] = 1.;
28for (int kk = order[0] - 1; kk >= 0; --kk)
29{
30 ypow[kk] = ypow[kk + 1] * yy;
31}
32
33// C(n,k+1) = C(n,k) (n-k)/(k+1), so the coefficient comes along for free.
34RealT coeff = 1.;
35for (int kk = 0; kk <= order[0]; ++kk)
36{
37 basis[kk] = coeff * xpow[kk] * ypow[kk];
38 coeff = coeff * RealT(order[0] - kk) / RealT(kk + 1);
39}
ypow[order[0]]
Definition EdgeCnBasis.h:27
xpow[0]
Definition EdgeCnBasis.h:22
RealT xx
Definition EdgeCnBasis.h:16
WORKSPACE(RealT, xpow, order[0]+1)
RealT coeff
Definition EdgeCnBasis.h:34
RealT yy
Definition EdgeCnBasis.h:17
basis[0]
Definition CellC0Basis.h:1