Plotting a Tetrahedron

How can we plot a tetrahedron so we can easily determine if it has vertical sides (this was important for some homework exercises)? Here is my solution using Octave and Maxima. First, I wrote a function for 3D-graphing a simplex (a triangle) given the three vertices in space:

octave:1> function simplex( a, b, c )
>   u = t = [ 0 : .1 : 1]';
>   [ tt, uu ] = meshgrid( t, u );
>
>   vx = a(1) + tt*(b(1)-a(1));
>   vy = a(2) + tt*(b(2)-a(2));
>   vz = a(3) + tt*(b(3)-a(3));
>
>   wx = vx + uu.*(c(1)-vx);
>   wy = vy + uu.*(c(2)-vy);
>   wz = vz + uu.*(c(3)-vz);
>
>   mesh( wx, wy, wz );
> endfunction

With this, the matter is simple. Find the vertices (you could use the solve() function of Maxima if you like). For the planes we did in class today x=0, z=0, x=2y, and x+2y+z=2, the vertices are (0,0,0), (0,1,0), (1,0.5,0), and (0,0,2). Just plot each combination of three.

octave:2> hold on
octave:3> simplex( [0 0 0], [0 1 0], [1 1/2 0] );
octave:4> Warning: empty z range [0:0], adjusting to [-1:1]
simplex( [0 0 0], [0 1 0], [0 0 2] );
octave:5> simplex( [0 0 0], [0 0 2], [1 1/2 0] );
octave:6> simplex( [0 0 2], [0 1 0], [1 1/2 0] );
octave:7> for i = [0:1:360]; eval ( sprintf( "gset view 90, %4.1f", i )); replot; endfor

As the surface rotates, you can clearly see that two of the sides are vertical.

octave:8> gset xlabel "x axis"
octave:9> gset ylabel "y axis"
octave:10> for i = [0:1:360]; eval ( sprintf( "gset view 75, %4.1f", i )); replot; endfor

This assumes we know the corner vertices of the tetrahedron. If you had just the equations for the planes that form each side, you could solve for the vertices using Maxima. Each vertex is the intersection of 3 planes:

(C1) eq1 : x=0;

(D1)                                 x = 0
(C2) eq2 : z=0;

(D2)                                 z = 0
(C3) eq3 : x=2*y;

(D3)                                x = 2 y
(C4) eq4 : x + 2*y + z = 2;

(D4)                            z + 2 y + x = 2
(C5) solve( [eq1,eq2,eq3], [x,y,z] );

(D5)                        [[x = 0, y = 0, z = 0]]
(C6) solve( [eq4,eq2,eq3], [x,y,z] );

                                         1
(D6)                        [[x = 1, y = -, z = 0]]
                                         2
(C7) solve( [eq1,eq4,eq3], [x,y,z] );

(D7)                        [[x = 0, y = 0, z = 2]]
(C8) solve( [eq1,eq2,eq4], [x,y,z] );

(D8)                        [[x = 0, y = 1, z = 0]]