In this example, we'll be creating a brand new (to Maya) geometric primitive—a tetrahedron. Tetrahedrons are simple in principle, but would require numerous steps to create using Maya's interface. As such, they make a great candidate for scripting.
We'll be creating a script that will create a tetrahedron of a given edge width as a polygonal mesh.
Before we start writing code, we'll want to make sure that we have a good grasp on the math behind tetrahedrons. A tetrahedron is the simplest regular polyhedron that consists of four faces, each of which is an equilateral triangle.
Each tetrahedron consists of only four points. For convenience, we'll name the three around the base A, B, and C, and the point at the tip D, as in the following illustration:
To make the math easier, we'll set point A to the origin ([0,0,0]). Because every side of the base is of the same length, we can find point B by simply moving along the x axis by the desired edge...