在 blender 的 voronoi.c 文件中,变量 float co[2] 是什么?



以下是voronoic .c (https://github.com/martijnberger/blender/blob/master/source/blender/blenlib/intern/voronoi.c)文件中定义的主要结构及其一些导入库:

//from BLI_voronoi.h
typedef struct VoronoiSite {
float co[2];
float color[3];
} VoronoiSite;
typedef struct VoronoiEdge {
struct VoronoiEdge *next, *prev;
float start[2], end[2]; /* start and end points */
/* this fields are used during diagram computation only */
float direction[2];     /* directional vector, from "start", points to "end", normal of |left, right| */
float left[2];          /* point on Voronoi place on the left side of edge */
float right[2];         /* point on Voronoi place on the right side of edge */
float f, g;             /* directional coeffitients satisfying equation y = f * x + g (edge lies on this line) */
/* some edges consist of two parts, so we add the pointer to another part to connect them at the end of an algorithm */
struct VoronoiEdge *neighbour;
} VoronoiEdge;
typedef struct VoronoiTriangulationPoint {
float co[2];
float color[3];
int power;
} VoronoiTriangulationPoint;

代码文件:https://svn.blender.org/svnroot/bf-blender/branches/ge_components/source/blender/blenlib/BLI_voronoi.h

VoronoiSite包含一个颜色,我假设这是每个单元格的颜色,因为对VoronoiSite的引用都包含一个从I = 0到整数sitestotal的循环。一个叫做co的变量,也许是一个二维坐标?

什么是图计算?VoronoiEdge是相当不言自明的,它引用了voronoi细胞的边缘,但是为什么坐标是2D的,而节点在blender中可以上升到4D?我将继续查看voronoic .c脚本来寻找答案。

voronoittriangulationpoint也有co变量int "power"可能是指距离函数a^k + b^k = c^k的k次方,它在voronoi节点中是可调节的。

综上所述,对于BLI_voronoi.h, float co[2]是什么?

我正在绞尽脑汁的另一个结构是来自voronoic的VoronoiEvent。我真的不需要这个问题的答案,但如果有人知道答案就太好了。

//from voronoi.c
typedef struct VoronoiEvent {
struct VoronoiEvent *next, *prev;
int type;       /* type of event (site or circle) */
float site[2];  /* site for which event was generated */
struct VoronoiParabola *parabola;   /* parabola for which event was generated */
} VoronoiEvent;

"Site"或";circle"有点隐晦,我相信它指的是voronoi细胞的形状但指的是具有一系列VoronoiEdge边缘的细胞的形状为site或";circle"这说不通啊。生成事件的抛物线;完全超出了我的任何假设。

我想在unity中实现blender的程序voronoi,但这对我来说有点太高级了,这个答案只是为了让我可以结束这个问题。

最新更新