Example for triangles and planes in 3D

Contents

You need to download some m-files

Download the following m-files and put them in the same directory with your other m-files:

format compact        % don't print blank lines between results

(1) Plotting a triangle and stretched triangle

Plot the triangle with vertices (2,1,1),(1,2,3),(0,1,1). Stretch this triangle by a factor of 2 with respect to its centroid and plot it.

az = -60; el = 55;     % good angle for looking at plots
                       % click on "rotate" icon in figure window toolbar,
                       % then Az,El are displayed while dragging with mouse

T1 = [[2;1;1],[1;2;3],[0;1;1]]            % vertices of original triangle
T1s = stretch(T1,2)                       % vertices of stretched triangle

fillpoints(T1,'y.-'); hold on             % plot original triangle with outline
fillpoints(T1s,'y.'); hold off            % plot stretched triangle without outline

nice3d; view(az,el)                       % show from a good angle
alpha(0.8)                                % make transparent
T1 =
     2     1     0
     1     2     1
     1     3     1
T1s =
    3.0000    1.0000   -1.0000
    0.6667    2.6667    0.6667
    0.3333    4.3333    0.3333

(2) Plot three triangles

Plot the three triangles with the following vertices:

T2 = [[1;2;0],[0;0;1],[2;0;1]];
T3 = [[2;0;0],[2;2;0],[2;1;3]];

fillpoints(T1,'y'); hold on                % plot three triangles
fillpoints(T2,'g');
fillpoints(T3,'c'); hold off

nice3d; view(az,el)                        % show from a good angle
alpha(0.8)                                 % make transparent

(3) Draw three planes with the intersection point

Consider the three planes through the three triangles given in (2). Plot stretched versions of these triangles so that you can see the intersectin point

fillpoints(stretch(T1,3),'y'); hold on     % plot three stretched triangles
fillpoints(stretch(T2,3),'g');
fillpoints(stretch(T3,3),'c'); hold off

nice3d; view(az,el)
alpha(0.8)                                 % make transparent