为什么八面体和立方体的表面积与体积之比是常数,而我的程序没有反映出来?

2024-06-11 23:48:43 发布

您现在位置:Python中文网/ 问答频道 /正文

由于两个柏拉图式实体的问题,我在发表我的论文时遇到了麻烦,我正在为它们的SA:V编码:立方体和八面体

通常,当我们推导出立方体和八面体的SA:V比时,它将分别得出6/a和(3*sqrt(6))/a

当你把这些比率作为一个比率,你会得到一个恒定的非1:1的比率,对于所有大小的区域,那么,我的输出是一个1:1的关系吗

输出(单击链接):

Graph of Ratios:

Table

用户请求、制表和绘图的所有实例中两种形状的相关代码(忽略二十面体代码):第一个实例:

    elif name_of_polyhedron == 'Octahedron':
        a = d/math.sqrt(2)
        SA_vex_octa = ((2*math.sqrt(3))*a**2)
        V_vex_octa = (((math.sqrt(2))/(3))*a**3)
        ratio_vex_octa = (SA_vex_octa/V_vex_octa)
        print('The surface area of your octahedron is as follows:' +str(SA_vex_octa)+ 'm^2')
        print('The volume of your octahedron is as follows:' +str(V_vex_octa)+ 'm^3')
        print('The surface area to volume ratio of your octahedron is as follows:' 
        +str(ratio_vex_octa))
        print('See how your ratio compares below!')
    elif name_of_polyhedron == 'Icosahedron':
        a = 4*(1/(math.sqrt(10+2*math.sqrt(5))))*((1/2)*d)
        SA_vex_icosa = 5*(a**2)*math.sqrt(3)
        V_vex_icosa = (5/12)*(a**3)*(3+sqrt(5))
        ratio_vex_icosa = SA_vex_icosa/V_vex_icosa
        print('The surface area of your icosahedron is as follows:' +str(SA_vex_icosa)+ 'm^2')
        print('The volume of your icosahedron is as follows:' +str(V_vex_icosa)+ 'm^3')
        print('The surface area to volume ratio of your icosahedron is as follows:' 
        +str(ratio_vex_icosa))
        print('See how your ratio compares below!')
    elif name_of_polyhedron == 'Cube':
        a = d/math.sqrt(3)
        SA_vex_cube = 6*a**2
        V_vex_cube = a**3
        ratio_vex_cube = SA_vex_cube/V_vex_cube
        print('The surface area of your cube is as follows:' +str(SA_vex_cube)+ 'm^2')
        print('The volume of your cube is as follows:' +str(V_vex_cube)+ 'm^3')
        print('The surface area to volume ratio of your cube is as follows:' +str(ratio_vex_cube))
        print('See how your ratio compares below!')

#Second Instance

a_4 = d/math.sqrt(2)
SA_vex_octa = (2*math.sqrt(3))*(a_4)**2
V_vex_octa = ((math.sqrt(2))/(3))*(a_4)**3
ratio_vex_octa = SA_vex_octa/V_vex_octa

a_5 = 4*(1/(math.sqrt(10+2*math.sqrt(5))))*((1/2)*d)
SA_vex_icosa = 5*((a_5)**2)*math.sqrt(3)
V_vex_icosa = (5/12)*((a_5)**3)*(3+math.sqrt(5))
ratio_vex_icosa = SA_vex_icosa/V_vex_icosa

a_6 = d/math.sqrt(3)
SA_vex_cube = 6*(a_6)**2
V_vex_cube = (a_6)**3
ratio_vex_cube = SA_vex_cube/V_vex_cube

#Third Instance

a_3 = (2/math.sqrt(6))*d
a_4 = d/math.sqrt(2)
a_5 = (2/(math.sqrt(10+2*math.sqrt(5))))*d
a_6 = d/math.sqrt(3)
a_7 = (2/(math.sqrt(3)*(1+math.sqrt(5)))*d)
a_8 = ((2/(math.sqrt(10+2*math.sqrt(5))))*d)
a_9 = ((2/(math.sqrt(50+22*math.sqrt(5))))*d)
a_10 = ((3/(math.sqrt(3)*(3+math.sqrt(5))))*d)
a_11 = ((2/(math.sqrt(50+22*math.sqrt(5))))*d)
SA_vex_tetra = (((a_3)**2)*math.sqrt(3))
V_vex_tetra = ((((a_3)**3)/12)*math.sqrt(2))
ratio_vex_tetra = [SA_vex_tetra/V_vex_tetra]
SA_vex_octa = (2*math.sqrt(3))*(a_4)**2
V_vex_octa = ((math.sqrt(2))/(3))*(a_4)**3
ratio_vex_octa = SA_vex_octa/V_vex_octa
SA_vex_icosa = 5*((a_5)**2)*math.sqrt(3)
V_vex_icosa = (5/12)*(a_5)**3*(3+math.sqrt(5))
ratio_vex_icosa = SA_vex_icosa/V_vex_icosa
SA_vex_cube = 6*(a_6)**2
V_vex_cube = (a_6)**3
ratio_vex_cube = SA_vex_cube/V_vex_cube

它们出现的表格/图表:

import matplotlib.pyplot as plt
from tabulate import tabulate
z = [('Tetrahedon',a_2,'Platonic',d,SA_vex_tetra,V_vex_tetra,ratio_vex_tetra),
   ('Octahedron',a_2,'Platonic',d,SA_vex_octa,V_vex_octa,ratio_vex_octa),
   ('Icosahedron',a_2,'Platonic',d,SA_vex_icosa,V_vex_icosa,ratio_vex_icosa),
   ('Cube',a_2,'Platonic',d,SA_vex_cube,V_vex_cube,ratio_vex_cube),
   ('Dodecahedron',a_2,'Platonic',d,SA_vex_dodeca,V_vex_dodeca,ratio_vex_dodeca),
   ('Cuboctahedron',a_2,'Archimedes',d,SA_vex_cubocta,V_vex_cubocta,ratio_vex_cubocta),
   ('Rhombicuboctahedron',a_2,'Archimedes',d,SA_vex_rhocubocta,V_vex_rhocubocta,ratio_vex_X), 
   ('Snub Cube',a_2,'Archimedes',d,SA_vex_scube,V_vex_scube,ratio_vex_scube),
   ('Snub Dodecahedron',a_2,'Archimedes',d,SA_vex_sndodeca,V_vex_sndodeca,ratio_vex_sndodeca),
   ('Rhombicosidodecahedron',a_2,'Archimedes',d,SA_vex_ridodeca,V_vex_ridodeca,ratio_vex_ridodeca),
   ('Truncated Octahedron',a_2,'Archimedes',d,SA_vex_ridodeca,V_vex_ridodeca,ratio_vex_sndodeca),
   ('Deltoidal Icositetrahedron','Catalan',a_2,d,SA_vex_delicotetra,V_vex_delicotetra,ratio_vex_X),
   ('Great Dodecahedron',a_1,'Kepler-Poinsot',d,SA_cav_gdodeca,V_cav_gdodeca,ratio_cav_gdodeca),
   ('Great Icosahedron',a_1,'Kepler-Poinsot',d,SA_cav_gicosa,V_cav_gicosa,ratio_cav_gicosa),
   ('Great-Stellated Dodecahedron',a_1,'Kepler-Poinsot',d,SA_cav_gsdodeca,V_cav_gsdodeca,ratio_X_X),
   ('Small-Stellated Dodecahedron',a_1,'Kepler Poinsot',d,SA_cav_ssdodeca,V_cav_ssdodeca,X),
   ('Stellated Octahedron',a_1,'Da Vinci',d,SA_cav_stocta,V_cav_stocta,ratio_cav_stocta),
   ('Medial Rhombic Triacontahedron',a_1,'A-R',(Wenninger)',d,SA_cav_mrtria,V_cav_mrtria,X),
   ('Dodecadodecahedron',a_1,'A-R (Wenninger)',d,SA_cav_ddodeca,V_cav_ddodeca,ratio_cav_ddodeca),
   ('Medial Triambic Icosahedron',a_1,'A-R', (Wenninger)',d,SA_cav_mticosa,V_cav_mticosa,X),
   ('Small Ditrigonal Icosidodecahedron',a_1,'A-R',(Wenninger)',d,SA_cav_sdicosi,V_cav_sdicosi,X),
   ('Excavated Dodecahedron',a_1,'A-R',(Wenninger)',d,SA_cav_exdodeca,V_cav_exdodeca,X),
   ('Sphere',a_12,a_12,d,SA_sphere,V_sphere,ratio_sphere)]
   table_1 = tabulate(z, headers=['Shape','Type','Subtype','C.D. (m)',
         'SA (m^2)','V(m^3)','SA:V'], tablefmt='fancy_grid') #orgtbl or f or pretty
   print(table_1)

Platonic_Array_Ratios = [ratio_vex_tetra,ratio_vex_octa,
                         ratio_vex_icosa,ratio_vex_cube,
                         ratio_vex_dodeca,ratio_sphere]



plt.title('Surface Area to Volume Ratio of Platonic Polyhedra Against Referential Sphere for 
Given 
Diameter')
plt.barh(['Tetrahedron', 'Octahedron', 
        'Icosahedron', 'Cube', 
        'Dodecahedron', 'Sphere'], Platonic_Array_Ratios)
plt.show()

# Platonic
plt.scatter(d,ratio_vex_tetra,label='Tetrahedron', color='b')
plt.scatter(d,ratio_vex_octa,label='Octahedron', color='g')
plt.scatter(d,ratio_vex_icosa,label='Icosahedron', color='y')
plt.scatter(d,ratio_vex_cube,label='Cube', color='m')
plt.scatter(d,ratio_vex_dodeca,label='Dodecahedron', color='c')

plt.scatter(d,ratio_sphere,label='Referential Sphere', color='r')
plt.axvline(x=d_vertical_slash, color='k')

plt.title('Comparison of SA:V of Platonic polyhedra against Referential Sphere with D(m)')
plt.xlabel('Circumspherical Diameter/Diagonal (m)')
plt.ylabel('Ratio Index')

plt.grid(alpha=.4,linestyle='--')

plt.xscale("log")

plt.legend(loc = 1)
plt.show()

我已经仔细地用手工和在线小部件检查了四倍的计算结果……它们都是正确的,并且在程序输出的所有计算中都相互匹配,但仍然有一些错误。似乎一个正在覆盖另一个,但在哪里

注意:此代码中没有错误消息。我也为代码太长而道歉。在某些情况下,为了再现性或只是为了提供更大的上下文,我不得不将所有内容复制并粘贴在一起。X只是一个用于格式化的占位符


Tags: ofyourassapltmathsqrtprint
1条回答
网友
1楼 · 发布于 2024-06-11 23:48:43

您正在计算“给定直径的柏拉图多面体相对于参考球体的表面积体积比”[黑体添加]

因此,在比较立方体和八面体之前,先比较立方体和球体的直径,以及八面体和球体的直径

(我想这意味着外接球;我不打算检查内接球。)

球体的SA/V比为6/d,其中d为直径

边长为a的立方体的最大直径为sqrt(3)a,因此立方体/球体比率为(6/a)/(6/(sqrt(3)a))=sqrt(3)

边长为a的八面体的最大直径为sqrt(2)a,因此八面体/球体比率为(3sqrt(6)/a)/(6/(sqrt(2)a))=sqrt(3)

由于与球体的比较,比率为1:1

相关问题 更多 >