Rotate a tetrahedron using XAML and C#

rotate a tetrahedron

This example is similar to Rotate a 3D cube using XAML and C# except it shows how to build and rotate a tetrahedron instead of a cube. See the previous example for the basics.


This example uses the following XAML code to define the tetrahedron’s vertices and triangles.

<!-- Tetrahedron -->
<MeshGeometry3D 
    Positions="
       0, 0, 1.15470053837925150,
      -1, 0, -0.57735026918962584,
       1, 0, -0.57735026918962584,
       0, 1.6329931618554521, 0
    "
    TriangleIndices="
       3 1 0    3 2 1
       3 0 2    0 1 2
    " />
</GeometryModel3D.Geometry>

These points produce a tetrahedron with edges of length 2. The result is fairly small so this program includes the following transformation to enlarge the tetrahedron by a factor of 2.

<GeometryModel3D.Transform>
    <ScaleTransform3D ScaleX="2" ScaleY="2" ScaleZ="2" />
</GeometryModel3D.Transform>

Download the example (and see the previous examples) for additional details.


Download Example   Follow me on Twitter   RSS feed   Donate




This entry was posted in graphics, wpf, XAML and tagged , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

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