function [xb,xl]=rbfbound(x, w)
%w = rbfbound(xt, x,y)

orig = [0.58;0]; r = 2;
x1 = -10; x2 = -1;

if nargin < 1
	x = [1     0     0    -1     0     0    -2; ...
 	     0     1    -1     0     2    -2     0];
	y = [-1   -1     -1     1     1     1     1];
	w = rbfweight(x, y);
end

figure; hold on;
plotdata(x, y);

xb = zeros(2, 360);
for theta = 1:1:360
	xt = orig + r * [cos(theta/180*pi); sin(theta/180*pi)];
	xb(:,theta) = rbfbndline(xt, orig, x, w);
end;
plot([xb(1,:), xb(1,1)], [xb(2,:), xb(2,1)], 'k-');

xl = zeros(2, 61);
idx = 0;
for i = -3:0.1:3, idx = idx + 1;
	xl(:, idx) = rbfbndline([x2;i], [x1;i], x, w);
end;
plot(xl(1,:), xl(2,:), 'k-');

axis('square');
grid on;

for n = 1:size(x,2);
	text(x(1,n)+0.1, x(2,n)+0.1, [num2str(n)]);
end;
h = text(-3.60, 0.2, '-'); set(h, 'fontsize', 40);
h = text(-1.65,-0.5, '+'); set(h, 'fontsize', 40);
h = text( 0.35, 0.2, '-'); set(h, 'fontsize', 40);

legend('y = +1', 'y = -1', 'boundary');
