Platonic Solids Part 4: The octahedron

[octahedron]


Finding the Octahedron’s Vertices

[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 [octahedron] as shown in Figure 1.



[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 [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:


[octahedron]

[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 Example   Follow me on Twitter   RSS feed   Donate




About RodStephens

Rod Stephens is a software consultant and author who has written more than 30 books and 250 magazine articles covering C#, Visual Basic, Visual Basic for Applications, Delphi, and Java.
This entry was posted in algorithms, graphics, mathematics, wpf and tagged , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *