function [X,h] = WireFrame(X,Marker,Ax)
% Plot a wireframe connecting adjacent column vectors of X

hold on; 
X = [X X(:,end)];

% House Frame
if nargin < 1
X = [-2 0 0 -1 0 -2 -1 -2 -2; 0 0 2 3 2 2 3 2 0];
Ax = [-5,5,-5,5];
elseif nargin < 2
	Marker = '.r'
	Ax = [-5,5,-5,5];
	elseif nargin == 2
		Ax = [-5,5,-5,5];
	end

h(1) = plot(X(1,:),X(2,:),'.');


% Plot an axis
PlotTheAxis = 0;
if PlotTheAxis > 0
	if nargin < 2
	x1 = 10; y1 = 0;
	x2 = 0;  y2 = 10;
	else
		x1 = Ax(2);
		x2 = Ax(2);
		y1 = Ax(4);
		y2 = Ax(4);
	end
	
	Ax = [-x1, x1; y1, y1]
	
	PlotSegment(Ax(:,1),Ax(:,2),'-w');
	PlotSegment(Ax(:,1),Ax(:,2),'-w');
end

%
axis(Ax)

% Plot the wireframe
hold on;
if nargin > 1; 
	c = Marker;
else
	c = '.r';
end
for i = 1:size(X,2)-1;
	h(i+1) = PlotSegment(X(:,i),X(:,i+1),c);
end

end %function

function [h,A] = PlotSegment(u,v,c);

t = 0:.0001:1;

A = (1-[t;t]).* repmat(u,size(t)) + [t;t] .* repmat(v,size(t));

   h = plot(A(1,:),A(2,:),c);
   end

