Title: Platonic Solids Part 4: The octahedron
Finding the Octahedron's Vertices
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 as shown in Figure 1.
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 as shown on the right in Figure 2.
The base of the pink triangle has length 1/2 so the remaining side has length:
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.
|