symm.c

来自「图形处理算法合集3:包括图形处理、帧缓存技术、渲染、矩阵运算、建模方法」· C语言 代码 · 共 37 行

C
37
字号
/***********************************************************Given an s-simplex (with s+1 vertexes) in n dimensions,calculate the vertexes of the kth (0 <= k < (1<<s))subsimplex in the symmetric subdivision of the simplex.Several implementations of the bitCount() function aredescribed in "Of Integers, Fields, and Bit Counting",Paeth and Schilling, Graphics Gems II.Entry:  src_vtx - list of the vertexes of the original simplex  n - each n consecutive floats represents one vertex  s - there are s+1 vertexes in the s-simplex  k - identifies which subsimplex is to be generatedExit:  dst_vtx - list of the vertexes of the kth subsimplex  ***********************************************************/void sym_subsimplex(register float* dst_vtx,                    const float* const src_vtx,                    int n,                    int s,                    int k){  int id[2];  id[1] = n*bitCount(k);  id[0] = 0;    for (int j = 0; j <= s; ++j)    {      for (int i = 0; i < n; ++i)        *dst_vtx++ = (src_vtx[i+id[0]] + src_vtx[i+id[1]]) / 2.0;      id[!(k&1)] += n;      k >>= 1;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?