Draw two interlocked tetrahedrons defined by a cube using WPF and XAML

My post Platonic Solids Part 2: The tetrahedron shows how to calculate the locations of a tetrahedron's vertices. The example Draw two interlocked tetrahedrons using WPF, XAML, and C# uses those vertices to draw two interlocked tetrahedrons.


The vertex calculations are interesting (if you like geometry), but there's an easier way to find the vertices of two interlocked tetrahedrons. You can use the corners of a cube to define the vertices of two interlocked tetrahedrons as shown in the picture on the right.

Much of this example is similar to Draw two interlocked tetrahedrons using WPF, XAML, and C# except it uses the following code to define its tetrahedrons' vertices and faces.

<!-- Tetrahedron 1 -->
...
<MeshGeometry3D 
Positions="
     1, 1, 1    -1,-1, 1     1,-1,-1
     1, 1, 1    -1, 1,-1    -1,-1, 1
     1, 1, 1     1,-1,-1    -1, 1,-1
    -1,-1, 1    -1, 1,-1     1,-1,-1
"
TriangleIndices="
     0  1  2     3  4  5
     6  7  8     9 10 11
"/>
...

<!-- Tetrahedron 2 -->
...
<MeshGeometry3D 
Positions="
    -1,-1,-1    -1, 1, 1     1, 1,-1
    -1,-1,-1     1,-1, 1    -1, 1, 1
    -1,-1,-1     1, 1,-1     1,-1, 1
     1,-1, 1     1, 1,-1    -1, 1, 1
"
TriangleIndices="
     0  1  2     3  4  5
     6  7  8     9 10 11
"/>
...

If you look carefully at the vertex coordinates, you can see where they lie on the unit cube. The program uses a ScaleTransform3D to scale the coordinates by a factor of 2.5 in the X, Y, and Z directions to make the tetrahedrons fill the viewing area nicely. Download the example for additional details.

   

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.