How to generate / calculate the vertices of a dodecahedron?

How can I algorithmically generate the vertices of a dodecahedron?

I would like the centroid of the tetrahedron to be at (0, 0, 0) .

+6
source share
4 answers

Since the question is now the main result of a Google search (math cheating - No. 2), I thought that I could also add code.

The full console program is given below and should compile and run and be generally self-evident.

The algorithm is based on Wikipedia article (thanks, mt_ from math.stackoverflow.com )

This code should print the correct list of vertices for you. Your problem is mainly related to the Program.MakeDodecahedron method, however don't just copy and paste it because you need to change this to use your own vertex data structure instead of my mock Vertex object. You can easily use XNA Vector3 , which has a constructor with the same signature as my Vertex . Also because my Vertex.ToString method Vertex.ToString hacked, this program can print an ugly output table when used with Vector3 , so keep that in mind.

Also note that this is a demo (n imprefect). For example, if you create many tetrahedra, you will uselessly re-read constants (for example, the golden ratio) for each call.

With XNA, especially if you use Microsoft.Xna.Framework , you can also easily make your dodecahedron in 3D. You can adapt the code with this tutorial for this purpose.

 using System; using System.Collections.Generic; namespace DodecahedronVertices { class Program { static void Main() { // Size parameter: This is distance of each vector from origin var r = Math.Sqrt(3); Console.WriteLine("Generating a dodecahedron with enclosing sphere radius: " + r); // Make the vertices var dodecahedron = MakeDodecahedron(r); // Print them out Console.WriteLine(" XYZ"); Console.WriteLine(" =========================="); for (var i = 0; i < dodecahedron.Count; i++) { var vertex = dodecahedron[i]; Console.WriteLine("{0,2}:" + vertex, i + 1); } Console.WriteLine("\nDone!"); Console.ReadLine(); } /// <summary> /// Generates a list of vertices (in arbitrary order) for a tetrahedron centered on the origin. /// </summary> /// <param name="r">The distance of each vertex from origin.</param> /// <returns></returns> private static IList<Vertex> MakeDodecahedron(double r) { // Calculate constants that will be used to generate vertices var phi = (float)(Math.Sqrt(5) - 1) / 2; // The golden ratio var a = 1 / Math.Sqrt(3); var b = a / phi; var c = a * phi; // Generate each vertex var vertices = new List<Vertex>(); foreach (var i in new[] { -1, 1 }) { foreach (var j in new[] { -1, 1 }) { vertices.Add(new Vertex( 0, i * c * r, j * b * r)); vertices.Add(new Vertex( i * c * r, j * b * r, 0)); vertices.Add(new Vertex( i * b * r, 0, j * c * r)); foreach (var k in new[] { -1, 1 }) vertices.Add(new Vertex( i * a * r, j * a * r, k * a * r)); } } return vertices; } } /// <summary> /// A placeholder class to store data on a point in space. Don't actually use this, write a better class (or just use Vector3 from XNA). /// </summary> class Vertex { double x; double y; double z; public Vertex(double x, double y, double z) { this.x = x; this.y = y; this.z = z; } public override string ToString() { var s = String.Format("{0,8:F2},{1,8:F2},{2,8:F2}", x, y, z); return s; } } } 

Since my code is probably quite verbose and widespread, I would recommend reading it in that it supports folding for-loops and other code structures.

+3
source

From Wikipedia :

The following Cartesian coordinates define the vertices a of the dodecahedron, centered at the origin and scaled and oriented accordingly:

(± 1, ± 1, ± 1)

(0, ± 1 / φ, ± φ)

(± 1 / φ, ± φ, 0)

(± φ, 0, ± 1 / φ)

where φ = (1 + √5) / 2 is the golden ratio (also written τ) ≈ 1.618. The edge length is 2 / φ = √5 - 1. The contained sphere has a radius of √3.

I find this description more concise and informative than a large piece of C # code. (-:

+6
source

The Cartesian coordinates of the dodecahedron centered at P (0, 0, 0) and the vertices bounded by a sphere of radius r are defined by the expression:

P (± r / √3, ± r / √3, ± r / √3)

P (0, ± r / (√3 * φ), ± (r * φ) / √3)

P (± r / (√3 * φ), ± (r * φ) / √3,0)

P (± (r * φ) / √3,0, ± r / (√3 * φ))

where φ = (1 + √5) / 2 is the golden ratio (also written τ) ≈ 1.618.

+2
source

Here's a Riemannian surface stereographic projection centered at vertex 0. (Sorry, I can't find how to send math symbols)

Where T is the golden ratio, let a = 1 / T ^ 2 and let the complex conjugate pair b + -ic be defined with b = sqrt (5) / 4 and c = sqrt (3) / 4. Rotate these three points 0, 120, and 240 degrees so that you now have nine points, all inside the unit circle.

Match each point with the image outside the unit circle using the map z → -1 / z. Add a point to zero and infinity, and now you have all the vertices of the dodecahedron.

If you need a dodecahedron on a sphere, make a regular stereographic reverse map by making a circle unit on the equator. With the usual inscription method, this also gives a cube or tetrahedron with vertices, but rotates about 37.76 or 22.24 degrees, respectively.

+1
source

Source: https://habr.com/ru/post/914955/


All Articles