function coords = funcdefn(f,m)
% This function allows the inputing of an R^2 function whose value
% to find on the junction points of a certain embedding of SG into 
% the plane.
%
% support functions: SG.m
%
% INPUT: 
% f - string of a function of x and y 
% m - the number of levels (meaning we have 3^(m+1) points) 
%
% OUTPUT:
% coords - a 3-column matrix holding x values, y values,
% and corresponding f values in the respective columns;
% points in TLR ordering.


% create inline function of x,y
f=inline(char(f),'x','y');

% invoke function to find coordinates for the junction points of SG
% (two columns, giving x and y values)
y=SG(m);

% create a column vector of f values at each junction point
fv=[];
for i=1:1:max(size(y))
  t1=y(i,1); t2=y(i,2);
  fv=[fv ; f(t1,t2)];
end

% optional plotting

%hold off
%for j=1:1:3^m
%    plot3([y(3*j-2:3*j,1); y(3*j-2,1)],[y(3*j-2:3*j,2) ;y(3*j-2,2)],[fv(3*j-2:3*j) ; fv(3*j-2)])
%    hold on
%end

% return 3-column matrix
coords = [y fv] ;