vetexofpolyhedron.htm

来自「电脑图学(Computer Graphics)是资料结构、演算法与数学的应用」· HTM 代码 · 共 223 行 · 第 1/2 页

HTM
223
字号
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">Vt[0] = new Point3D(0, r, 0); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">Vt[1] = new Point3D(0, -r/3, r*2*sq2/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">Vt[2] = new Point3D(r*sq2/sq3, -r/3, -r*sq2/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">Vt[3] = new Point3D(-r*sq2/sq3, -r/3, -r*sq2/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;</span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">int[][] ord = {{0, 1, 2}, {0, 2, 3}, {0, 3, 1}, {1, 3, 2}};</span><br>
</div>
<h2> 正六面体</h2>

有一正六面体其中心在原点,如下所示: <br>
<img style="width: 268px; height: 257px;" alt="" src="images/vetexOfPolyhedron-3.jpg"><br>
<br>
由顶点(0, r, 0)所延伸出来的錂线有三条,为了计算方便,将两个顶点置于同一XY平面上,所以錂线所接的各顶点经计算后如下所示:<br>
<img style="width: 501px; height: 198px;" alt="" src="images/vetexOfPolyhedron-4.jpg"><br>
<br>
其它未定出的顶点皆以原点对称于这四个顶点,对称于原点其实就是将(x, y, z)都乘上负号,假设有个方法是minus()是进行这项工作,则其它顶点的计算及面的索引阵列如下所示,其中NVt表示顶点数,对正六面体而言是8:<br>
<div style="margin-left: 40px;"><span style="font-weight: bold; font-family: Courier New,Courier,monospace;">double sq2 = Math.sqrt(2.0), sq3 = Math.sqrt(3.0); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">Vt[0] = new Point3D(0, r, 0); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">Vt[1] = new Point3D(0, r/3, r*2*sq2/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">Vt[2] = new Point3D(r*sq2/sq3, r/3, -r*sq2/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">Vt[3] = new Point3D(-r*sq2/sq3, r/3, -r*sq2/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;</span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">for(int i = 0; i &lt; NVt; i++) </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp; Vt[NVt/2+i] = minus(Vt[i]); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">int[][] ord = {{0, 1, 7, 2}, {0, 2, 5, 3}, {0, 3, 6, 1}, </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{4,
6, 3, 5}, {4, 7, 1, 6}, {4, 5, 2, 7}};</span><br>
</div>
<br>
<h2> 正八面体</h2>

依以上同样的道理,可以定出正八面体的一组基本顶点,不过正八面体的中心的三个顶点可以调整至XYZ三轴上,如下所示:<br>
<img style="width: 273px; height: 227px;" alt="" src="images/vetexOfPolyhedron-5.jpg"><br>
<br>
正八面体的顶点配置方式与顶点索引阵列,提供以下的程式作参考,其中NVt?表示顶点数,对正八面体而言是6:<br>
<div style="margin-left: 40px;"><span style="font-weight: bold; font-family: Courier New,Courier,monospace;">Vt[0] = new Point3D(0, r, 0); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">Vt[1] = new Point3D(0, 0, r); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">Vt[2] = new Point3D(r, 0, 0); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;</span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">for(int i = 0; i &lt; NVt; i++) </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp; Vt[NVt/2+i] = minus(Vt[i]); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;</span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">int[][] ord = {{0, 1, 2}, {0, 2, 4}, {0, 4, 5}, {0, 5, 1}, </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{3, 5, 4}, {3, 1, 5}, {3, 2, 1}, {3, 4, 2}};</span><br>
</div>
<br>
<h2> 正十二面体</h2>

下图为正十二面体的图形:<br>
<img style="width: 288px; height: 286px;" alt="" src="images/vetexOfPolyhedron-6.jpg"><br>
<br>
正十二面体的对称顶点有十对,顶点配置与顶点索引阵列如下所示,其中NVt表示顶点数,对正十二面体而言是20:<br>
<div style="margin-left: 40px;"><span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;double sq3=Math.sqrt(3.0),sq5=Math.sqrt(5.0); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[0] = new PointD3(0,r,0); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[1] = new PointD3(0,r*sq5/3,r*2/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[2] = new PointD3(r*sq3/3,r*sq5/3,-r/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[3] = new PointD3(-r*sq3/3,r*sq5/3,-r/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[4] = new PointD3(r*sq3/3,r/3,r*sq5/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[5] = new PointD3(r*t1*sq3/3,r/3,r*t2*t2/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[6] = new PointD3(r*t2*sq3/3,r/3,-r*t1*t1/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[7] = new PointD3(-r*t2*sq3/3,r/3,-r*t1*t1/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[8] = new PointD3(-r*t1*sq3/3,r/3,r*t2*t2/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[9] = new PointD3(-r*sq3/3,r/3,r*sq5/3); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;for(int i = 0; i &lt; NVt/2; i++) </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp; Vt[NVt/2+i] = minus(Vt[i]); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;</span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;int[][]ord = </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {{ 0, 1, 4, 5, 2},{ 0, 2, 6, 7, 3},{ 0, 3, 8, 9, 1}, </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { 1, 9,16,17, 4},{ 2, 5,18,19, 6},{ 3, 7,14,15, 8}, </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {10,12,15,14,11},{10,13,17,16,12},{10,11,19,18,13}, </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {11,14, 7, 6,19},{12,16, 9, 8,15},{13,18, 5, 4,17}};</span><br>
</div>
<br>
<h2> 正二十面体</h2>

下图为正二十面体的图形: <br>
<img style="width: 280px; height: 289px;" alt="" src="images/vetexOfPolyhedron-7.jpg"><br>
<br>
正二十面体的对称顶点有六对,顶点配置与顶点索引阵列如下所示,其中NVt表示顶点数,对正二十面体而言是12:<br>
<div style="margin-left: 40px;"><span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;double sq5=Math.sqrt(5.0); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;double t1 = (sq5+1)/2, t2 = (sq5-1)/2; </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[0] = new PointD3(0,r,0); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[1] = new PointD3(0,r/sq5,r*2/sq5); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[2] = new PointD3(r*Math.sqrt(t1/sq5),r/sq5,r*t2/sq5); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[3] = new PointD3(r*Math.sqrt(t2/sq5),r/sq5,-r*t1/sq5); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[4] = new PointD3(-r*Math.sqrt(t2/sq5),r/sq5,-r*t1/sq5); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;Vt[5] = new PointD3(-r*Math.sqrt(t1/sq5),r/sq5,r*t2/sq5); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;for(int i = 0; i&lt;NVt/2; i++) </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp; Vt[NVt/2+i] = minus(Vt[i]); </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;</span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;int[][]ord = </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {{0, 1,2},{0, 2,3},{0, 3,4},{ 0, 4, 5},{ 0,5, 1}, </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {1,10,2},{2,11,3},{3, 7,4},{ 4, 8, 5},{ 5,9, 1}, </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {6, 8,7},{6, 9,8},{6,10,9},{ 6,11,10},{ 6,7,11}, </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;">
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {7, 8,4},{8, 9,5},{9,10,1},{10,11, 2},{11,7, 3}};</span><br>
</div>
&nbsp;<br>
<br>
由以上,只要一个变数r,就可以订出所有的正多面体顶点,当然所牺牲的就是一些运算时间了。<br>
<br>






</body>
</html>

⌨️ 快捷键说明

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