[C# Helper]
Index Books FAQ Contact About Rod
[Beginning Database Design Solutions, Second Edition]

[Beginning Software Engineering, Second Edition]

[Essential Algorithms, Second Edition]

[The Modern C# Challenge]

[WPF 3d, Three-Dimensional Graphics with WPF and C#]

[The C# Helper Top 100]

[Interview Puzzles Dissected]

[C# 24-Hour Trainer]

[C# 5.0 Programmer's Reference]

[MCSD Certification Toolkit (Exam 70-483): Programming in C#]

Title: Platonic Solids Part 4: The octahedron

[Platonic Solids Part 4: The octahedron]


Finding the Octahedron's Vertices

[Platonic Solids Part 4: The octahedron] A platonic octahedron has six triangular faces. Because the edges of the triangles all have the same length, the triangles are equilateral triangles.

If an equilateral triangle has edges of length 1, then its height is [Platonic Solids Part 4: The octahedron] as shown in Figure 1.


[Platonic Solids Part 4: The octahedron] Now consider the pink triangle on the left in Figure 2. Its hypotenuse lies along the altitude of one of the octahedron's equilateral triangles so it has length [Platonic Solids Part 4: The octahedron] as shown on the right in Figure 2.

The base of the pink triangle has length 1/2 so the remaining side has length:

[Platonic Solids Part 4: The octahedron]

[Platonic Solids Part 4: The octahedron] If you place each of the vertices on an axis, you can use the value y to calculate the vertices' coordinates as shown in Figure 3.

The Example Program

The example program uses the following code to generate the octahedron's vertices.

// Return the vertices for a octahedron. private Point3D[] MakeVertices() { double y = 1.0 / Math.Sqrt(2); List points = new List(); points.Add(new Point3D(0, y, 0)); points.Add(new Point3D(y, 0, 0)); points.Add(new Point3D(0, 0, -y)); points.Add(new Point3D(-y, 0, 0)); points.Add(new Point3D(0, 0, y)); points.Add(new Point3D(0, -y, 0)); // Verify that the edges have length 1. VerifyEdgeLengths(1, points.ToArray()); return points.ToArray(); }

This code calculates the value y shown in Figure 2 and then uses it to calculate the vertices' coordinates. It adds each vertex to a list, calls VerifyEdgeLengths to verify the edge lengths, and then returns the points in an array.

The rest of the program's code deals with using WPF to display the octahedron's faces, its edges, and the axes. Download the example and look at the code for details.

Download the example to experiment with it and to see additional details.

© 2009-2023 Rocky Mountain Computer Consulting, Inc. All rights reserved.