home *** CD-ROM | disk | FTP | other *** search
-
- (* :Title: Polytopes *)
-
- (* :Author: Stephen Wolfram *)
-
- (* :Summary: Regular Polygons and Polyhedra *)
-
- (* :Context: Geometry`Polytopes` *)
-
- (* :Package Version: 1.2 *)
-
- (* :Copyright: Copyright 1987,1990 *)
-
- (* :History:
- Modified by E.C.Martin (Wolfram Research), December 1990
- Version 1.1 by Stephen Wolfram (Wolfram Research), February 1987
- *)
-
- (* :Keywords: *)
-
- (* :Source:
- H. S. M. Coxeter, "Regular Polytopes", (Dover, 1973) *)
-
- (* :Warning: none *)
-
- (* :Mathematica Version: 2.0 *)
-
- (* :Limitation: none *)
-
- (* :Discussion: *)
-
-
-
- BeginPackage["Geometry`Polytopes`"]
-
- Vertices::usage =
- "Vertices[polytope] gives the number of vertices of polytope."
- Edges::usage =
- "Edges[polytope] gives the number of edges of polytope."
- Faces::usage=
- "Faces[polytope] gives the number of faces of polytope."
- Coords::usage =
- "Coords[polytope] gives a list of the coordinates of vertices."
- (** Note: edges are not necessarily normalized to unit length **)
- Area::usage =
- "Area[polytope] gives the area of each face with unit edge length."
- Inscribed::usage =
- "Inscribed[polytope] gives the radius of an inscribed circle/sphere."
- Circumscribed::usage =
- "Circumscribed[polytope] gives the radius of a circumscribed
- circle/sphere."
- Volume::usage =
- "Volume[polytope] gives the volume with unit edge length."
- Dual::usage =
- "Dual[p] gives the dual of polytope p (if it exists)."
- Schlafli::usage =
- "Schlafli[p] gives the Schlafli symbol for polytope p."
-
- Map[(Evaluate[#]::"usage" =
- StringJoin[ToString[#], " is a polygon."])&,
- {Digon,Triangle,Square,Pentagon,Hexagon,Heptagon,Octagon,Nonagon,
- Decagon,Undecagon,Dodecagon}]
-
- Map[(Evaluate[#]::"usage" =
- StringJoin[ToString[#], " is a polyhedron."])&,
- {Tetrahedron, Cube, Octahedron, Dodecahedron, Icosahedron}]
-
-
- Begin["`Private`"]
-
-
- (* 2 dimensions *)
-
- Digon = polygon[2]
- Triangle = polygon[3]
- Square = polygon[4]
- Pentagon = polygon[5]
- Hexagon = polygon[6]
- Heptagon = polygon[7]
- Octagon = polygon[8]
- Nonagon = polygon[9]
- Decagon = polygon[10]
- Undecagon = polygon[11]
- Dodecagon = polygon[12]
-
- Vertices[polygon[n_]] ^= n
- Edges[polygon[n_]] ^= n
- Faces[polygon[n_]] ^= 1
- Coords[polygon[n_Integer]] ^:=
- Table[{Cos[2Pi i/n], Sin[2Pi i/n]}, {i,1,n}]
- Area[polygon[n_Integer]] ^= n/(4 Tan[Pi/n])
- Inscribed[polygon[n_Integer]] ^= 1/(2 Tan[Pi/n])
- Circumscribed[polygon[n_Integer]] ^= 1/(2 Sin[Pi/n])
-
-
-
- (* 3 dimensions *)
-
- PT$AllCyc[list_] := Array[RotateLeft[list,#]&, Length[list], 0]
-
- PT$AllSign = Flatten[Array[-1^List[##]&, {2,2,2}, 0], 2]
-
-
- (* Tetrahedron *)
-
- Vertices[Tetrahedron] ^= 4
- Edges[Tetrahedron] ^= 6
- Faces[Tetrahedron] ^= 4
- Coords[Tetrahedron] ^= {{1,1,1}} ~Join~ PT$AllCyc[{1,-1,-1}]
- Area[Tetrahedron] ^= Sqrt[3]/4
- Inscribed[Tetrahedron] ^= Sqrt[6]/12
- Circumscribed[Tetrahedron] ^= Sqrt[6]/4
- Volume[Tetrahedron] ^= Sqrt[2]/12
- Dual[Tetrahedron] ^= Tetrahedron
- Schlafli[Tetrahedron] ^= {3,3}
-
- (* Cube *)
-
- Hexahedron = Cube
-
- Vertices[Cube] ^= 8
- Edges[Cube] ^= 12
- Faces[Cube] ^= 6
- Coords[Cube] ^= PT$AllSign
- Area[Cube] ^= 1
- Inscribed[Cube] ^= 1/2
- Circumscribed[Cube] ^= Sqrt[3]/2
- Volume[Cube] ^= 1
- Dual[Cube] ^= Octahedron
- Schlafli[Cube] ^= {4,3}
-
- (* Octahedron *)
-
- Vertices[Octahedron] ^= 6
- Edges[Octahedron] ^= 12
- Faces[Octahedron] ^= 8
- Coords[Octahedron] ^= PT$AllCyc[{1,0,0}] ~Join~ PT$AllCyc[{-1,0,0}]
- Area[Octahedron] ^= Sqrt[3]/4
- Inscribed[Octahedron] ^= Sqrt[6]/6
- Circumscribed[Octahedron] ^= Sqrt[2]/2
- Volume[Octahedron] ^= Sqrt[2]/3
- Dual[Octahedron] ^= Cube
- Schlafli[Octahedron] ^= {3,4}
-
- (* Dodecahedron *)
-
- Vertices[Dodecahedron] ^= 20
- Edges[Dodecahedron] ^= 30
- Faces[Dodecahedron] ^= 12
- Coords[Dodecahedron] ^=
- PT$AllSign ~Join~
- Flatten[
- Array[PT$AllCyc[{0,(-1)^#1 GoldenRatio^-1,(-1)^#2 GoldenRatio}]&,
- {2,2}],
- 2]
- Area[Dodecahedron] ^= Sqrt[25+10 Sqrt[5]]/4
- Inscribed[Dodecahedron] ^= Sqrt[250+110 Sqrt[5]]/20
- Circumscribed[Dodecahedron] ^= (Sqrt[15]+Sqrt[3])/4
- Volume[Dodecahedron] ^= (15 + 7 Sqrt[5])/4
- Dual[Dodecahedron] ^= Icosahedron
- Schlafli[Dodecahedron] ^= {5,3}
-
- (* Icosahedron *)
-
- Vertices[Icosahedron] ^= 12
- Edges[Icosahedron] ^= 30
- Faces[Icosahedron] ^= 20
- Coords[Icosahedron] ^=
- Flatten[ Array[PT$AllCyc[{0,(-1)^#1 GoldenRatio,(-1)^#2}]&,
- {2,2}],
- 2]
- Area[Icosahedron] ^= Sqrt[3]/4
- Inscribed[Icosahedron] ^= Sqrt[42+18 Sqrt[5]]/12
- Circumscribed[Icosahedron] ^= Sqrt[10+2 Sqrt[5]]/4
- Volume[Icosahedron] ^= 5 (3 + Sqrt[5])/12
- Dual[Icosahedron] ^= Dodecahedron
- Schlafli[Icosahedron] ^= {3,5}
-
- End[]
-
- EndPackage[]
-
-