VTK  9.7.20260922
TriCnBasis.h
Go to the documentation of this file.
1// Bernstein-Bezier basis functions of arbitrary order on the reference triangle.
2//
3// The barycentric Bernstein polynomials of degree n are indexed by a
4// multi-index (b0, b1, b2) of non-negative integers summing to n:
5//
6// B_b(lambda) = n!/(b0! b1! b2!) lambda0^b0 lambda1^b1 lambda2^b2
7//
8// Writing this as n! * prod_t (lambda_t^{b_t} / b_t!) lets each factor be built
9// by the recurrence w_m = w_{m-1} lambda / m, which avoids pow() and any
10// factorial helper - neither of which is portable to the GLSL these kernels are
11// also compiled to.
12//
13// Unlike the Lagrange basis these do not interpolate their control values
14// except at the three corners, but they are non-negative and sum to one, so the
15// surface lies within the convex hull of its control points.
16//
17// The multi-index is enumerated with b1 (the r-axis) varying fastest, matching
18// the convention the Lagrange bases use. Note that the triangle's parameter
19// space is the barycentric one, so unlike the prismatic shapes there is no
20// change of variables here.
21RealT nfact = 1.;
22for (int mm = 2; mm <= order[0]; ++mm)
23{
24 nfact *= RealT(mm);
25}
26
27WORKSPACE(RealT, bary, 3);
28bary[0] = 1. - rr - ss;
29bary[1] = rr;
30bary[2] = ss;
31
32// wval[k * (n + 1) + m] holds lambda_k^m / m!.
33WORKSPACE(RealT, wval, 3 * (order[0] + 1));
34for (int kk = 0; kk < 3; ++kk)
35{
36 int base = kk * (order[0] + 1);
37 wval[base] = 1.;
38 for (int mm = 1; mm <= order[0]; ++mm)
39 {
40 wval[base + mm] = wval[base + mm - 1] * bary[kk] / RealT(mm);
41 }
42}
43
44int idx = 0;
45for (int i2 = 0; i2 <= order[0]; ++i2)
46{
47 for (int i1 = 0; i1 <= order[0] - i2; ++i1)
48 {
49 int i0 = order[0] - i1 - i2;
50 basis[idx++] = nfact * wval[i0] * wval[(order[0] + 1) + i1] * wval[2 * (order[0] + 1) + i2];
51 }
52}
int idx
Definition HexCnBasis.h:79
RealT nfact
Definition TetCnBasis.h:8
bary[0]
Definition TetCnBasis.h:15
WORKSPACE(RealT, bary, 3)
basis[0]
Definition CellC0Basis.h:1