[探讨]正二十面体的顶点取值
[探讨]正二十面体的坐标取值
编辑: from: www.open-gl.org
红皮书中举了个绘制正二十面体的例子,部分代码如下
(参见“2.10 创建多边形表面模型的一些提示”)
An Example: Building an Icosahedron:
#define X .[***********]
#define Z .[***********]
static GLfloat vdata[12][3] = {
{-X, 0.0, Z}, {X, 0.0, Z}, {-X, 0.0, -Z}, {X, 0.0, -Z},
{0.0, Z, X}, {0.0, Z, -X}, {0.0, -Z, X}, {0.0, -Z, -X},
{Z, X, 0.0}, {-Z, X, 0.0}, {Z, -X, 0.0}, {-Z, -X, 0.0}
};
static GLuint tindices[20][3] = {
{1,4,0}, {4,9,0}, {4,5,9}, {8,5,4}, {1,8,4},
{1,10,8}, {10,3,8}, {8,3,5}, {3,2,5}, {3,7,2},
{3,10,7}, {10,6,7}, {6,11,7}, {6,0,11}, {6,1,0},
{10,1,6}, {11,0,9}, {2,11,9}, {5,2,9}, {11,2,7}
};
int i;
glBegin(GL_TRIANGLES);
for (i = 0; i
/* color information here */
glVertex3fv(&vdata[tindices[i][0]][0]);
glVertex3fv(&vdata[tindices[i][1]][0]);
glVertex3fv(&vdata[tindices[i][2]][0]);
}
glEnd();
========================================
#define X .[***********]#define Z .[***********]
原版以及中文版关于这两个常量的注释:
The strange numbers X and Z are chosen so that the distance from theorigin to any of the vertices of the icosahedron is 1.0.
我们为X 和Y 选择了两个似乎很奇怪的数,其用意在于使原点到这二十面体的每个顶点的距离均为1.0。
至于这两个常量怎么来的,只能自己查了。
在wikipedia找到了完整的注释,以及更多的扩展图形
英文的解释要全面的多 中文对照(页面未完善) http://zh.wikipedia.org/wiki/
正二十面體
若以正二十面体的中心为原点,
各顶点的坐标分别为
(0,±1,±Φ)
(±1,±Φ,0)
(±Φ,0,±1)
在此Φ = (1+√5)/2,即黄金分割数。
因此,这些顶点能组成一些黄金矩形。
黄金分割数计算公式的源头可以参考百科 http://baike.baidu.com/view/45073.htm一种是通过斐波那契数列算得近似值 一种是通过几何代数的方式求出公式 黄金比=(√5-1)/2(√5+1)/2 和(√5-1)/2互为倒数 所以 1 : (√5+1)/2 =(√5-1)/2
这是一组黄金分割数
取其中一个黄金矩形片面作为分析:x=1 , y=(√5+1)/2
中心(0,0)
这里 L=sqrt(x*x+y*y) ≈ 1.[1**********]031
为了使得顶点距离中心的距离 L2= 1,
将x,y取值分别/ L
得:
常量X=1/L≈0.[**************]
Y=(√5+1)/2/L≈0.[1**********]204
和红皮书实例中给出的X,Y基本一致,精度值不同